-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
@@ -49,7 +49,7 @@ pub enum ConflictResolution { | |||
} | |||
|
|||
#[async_trait] | |||
pub trait ConflictSolver { | |||
pub trait ConflictSolver: Send + Sync { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 🤷
Closes #374