Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python learns to detect conflicts and rebase #420

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mpiannucci
Copy link
Contributor

@mpiannucci mpiannucci commented Nov 29, 2024

Closes #374

  • Tests
  • Docs

@@ -49,7 +49,7 @@ pub enum ConflictResolution {
}

#[async_trait]
pub trait ConflictSolver {
pub trait ConflictSolver: Send + Sync {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for use in async python

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm this smells bad to me. Can we demand Send + Sync in the usage point instead?

@@ -16,6 +16,7 @@ use crate::{

use super::{Conflict, ConflictResolution, ConflictSolver};

#[derive(Clone, Debug)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python is annoying to implement without this (accepting a union as argument to method)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, I forgot to add those

@@ -350,6 +350,30 @@ async def async_merge(self, changes: bytes) -> None:
"""
return await self._store.async_merge(changes)

def rebase(self, solver: ConflictDetector | BasicConflictSolver) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should write a few paragraphs of design document on this. Two topics would be:

  • how much do we want to expose of the solvers? This methods for example requires adding here when different strategies are created, and doesn't allow for users to extend the mechanisms (which I'd love some day)
  • how do we expose the results of the conflict detector. This is going to be important, I expect most production jobs to at least report to logs the conflicts when they find them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should. For 1: I think we can used subclassing/inheritance to solve this in Python probably.

I wanted to start this PR as a jumping off point, cuz I agree there is a lot to figure out here in terms of the API

@@ -275,6 +279,56 @@ class StoreConfig:
"""
...

class VersionSelection:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better than an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how Rust enums map unfortunately (i think, I'll confirm)

Basic(PyBasicConflictSolver),
}

impl AsRef<dyn ConflictSolver + 'static> for PyConflictSolver {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks weird. I wonder why you need it. If you do, I think this probably should have a generic timeline instead of static. Something like

impl<'a> AsRef<dyn ConflictSolver + 'a> for .....

on_user_attributes_conflict=icechunk.VersionSelection.use_ours(),
)

store_b.rebase(solver)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase fails in the this test as unsolveable 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conflict detection and rebase
2 participants