-
Notifications
You must be signed in to change notification settings - Fork 364
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
Support stateful transactions by allowing to pass keyword arguments #1517
Comments
Thanks for thinking about this. I don't immediately know how, but I feel what you want should be doable without breaking the current API, perhaps with some context or other FS instance-level state |
Thanks for the tip. We ended up defining a This is obviously a bit hacky, but without opening up e.g. a context argument slot in |
I have thought of a very nice use case for this. When writing zarr stores, there is a mixture of ".z" metadata small text metadata files and larger binary files being written. So, it would be nice to specilise the transaction to only capture paths which meet some pattern. Even better would be to modify/wrap the ls/dircache behaviour so that while the transaction is live, these files can be found, and without asking the remote store. |
Sounds great. Our use case is essentially a write to a git-ish branch, which needs metadata like repository, branch name, and some flags. It's a mixed bag between positionals and keyword arguments. If you want to take a look, our implementation can be found here. We're also interested in listing files in transaction, even though we might not be able to use them, since we do not use the Of course, I'm happy to support on any part, or specifically the ls() part if you like. |
Actually, transactions could use a general workup. At the moment, they only refer to files written using open(), which means that you might get transactional writing with pipe_file if it depends on open() (e.g., memory), but probably not. Instead, we should queue pipe and put calls and send them async if possible on completion. Your transaction does some or all of this already, since you have a definite temporary place in the remote to write to. |
You may be interested in #1531 , a different take on write transactions. |
A file system's corresponding transaction class has been a class attribute since #1424.
However, the
fsspec.transaction.Transaction
interface is currently stateless. For someone trying to roll a transaction class that takes some state in the constructor, this results in incompatibilities that can break some of fsspec's most important features, e.g. like so:Question is, would you support moving from the current "transactions as properties" approach to a more functional approach allowing for state passing to the respective transaction class?
The text was updated successfully, but these errors were encountered: