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
Implement transaction action plugins #13842
base: main
Are you sure you want to change the base?
Conversation
Currently deciding where to add hooks. I started by adding a single generic The meat happens in
These are duplicated for unlink & link. So we have something like eight possible hooks:
The API is split between Actions (unaware of the transaction order) and ActionGroups (which are directly handled by the transaction). I'll need to prototype a bit more to see how this looks like. |
The other alternative is to forget about the
Still eight hooks, which don't guarantee execution order, and would force plugins to inspect the |
@@ -332,3 +333,48 @@ def conda_settings(): | |||
aliases=("example_option_alias",), | |||
) | |||
""" | |||
|
|||
@_hookspec | |||
def conda_transaction_action(self) -> Iterable[CondaTransactionAction]: |
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.
Per pluggy parlance hooks should be plural since they are implemented not as singular instances but always as a list, or in our case generators as we're using yield
|
||
|
||
@dataclass | ||
class CondaTransactionAction: |
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.
action action 💥
Ay further comments here @jezdez (or anyone from @conda/conda-core)? If not I think I'll proceed with the solution described at #13842 (comment). |
That's going to set in stone the un-API that The tricky thing is that we're trying extend different API levels, that are stacked and have different constraints, some related to the transaction order, some not. That's going to make things a lot harder for plugin authors to understand how to build reasonable plugins without breaking the API. We don't neccearily need a pre and post step for every action (3. below), e.g. calling a hook plugin for every file that is being handled sounds risky in terms of performance for example. While calling a plugin with the list of files that the action is about to be taken, that might not be as problematic. There are three level all weirdly intertwined:
Those are just for data preperation, I wonder if those could also be done with pre and post solver plugins?
|
Thanks for the detailed reply @jezdez! I need to think a little bit more about it, but for now:
The limitation I see there is that the post-solve hook is run before the IO work has started. For example, directories might not be in place yet, nor the artifacts have been downloaded, etc. For example, if I want to write some files, I could anticipate where to write it (but we don't have any info about the target prefix the solver was passed!). However, if for some reason the transaction fails (bad download, disk full, etc), there won't be any rollbacks for the post-solve actions. This hook is for me more useful to prevent the transaction from happening, before IO work begins. So in a nutshell, what do you think it's the sweet spot here? I think we can forget about your level (1), focus on number (2), and then at some point tackle (3) in a refactor. |
Description
Closes #13795
Checklist - did you ...
news
directory (using the template) for the next release's release notes?