Skip to content

POC: Sketch of localfilesystem and commiting #8

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

Merged
merged 6 commits into from
Aug 13, 2018

Conversation

martindurant
Copy link
Member

@mariusvniekerk , suggesting here is where you might want to work something out.
This contains minimal stuff for method aliasing (simplest possible), an actual example file-system for local work, and a hacky "transaction" that writes to temporary files, moving to final destination when the transaction is over.
As usual, everything I happened to code here is up for altering or criticism.

In [7]: with fs.transaction():
   ...:     with fs.open('./temp', 'wb') as f:
   ...:         f.write(b'hi')
   ...:     print(fs.ls('.'))
   ...: print(fs.ls('.'))
   ...:
   ...:
[]
['/Users/mdurant/temp/temp']

@martindurant
Copy link
Member Author

(and a prod to make the aliases work with docstrings, please :) )

Martin Durant added 2 commits July 17, 2018 10:32
@mariusvniekerk
Copy link
Contributor

mariusvniekerk commented Aug 13, 2018

Yeah i think that would probably work as a minimal example.

I think the interesting thing for distributed filesystems would be to consider making the actual transaction class itself a thing that can be moved around.

This is easily achievable by implementers by making fs.transaction() return an object with a __enter__ and __exit__. Though i guess we can already serialize the AbstractFilesystem instead.

Not entirely sure if we want to be as strict by default?

fsspec/spec.py Outdated
ac = kwargs.pop('autocommit', not self._intrans)
f = self._open(path, mode=mode, block_size=block_size,
autocommit=ac, **kwargs)
if not ac:
Copy link
Member Author

@martindurant martindurant Aug 13, 2018

Choose a reason for hiding this comment

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

Should autocommit be necessarily True if _intrans isn't set, and should we avoid collecting up instances that might never be cleared?

Copy link
Contributor

Choose a reason for hiding this comment

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

autocommit only applies to writing at __exit__ so i think its a sane default in terms of user expectations

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats more explicit. 👍

@martindurant
Copy link
Member Author

OK, going to merge this now for further iteration. Of course, it does not yet explicitly deal with distributed transactions, since the file objects within a Transaction are not necessarily pickleable (but they should be, in this context) - however, you would be able to call FileSystem.current().transaction.complete(True|False) within any worker.

@martindurant martindurant merged commit e3576de into master Aug 13, 2018
@martindurant martindurant deleted the local_and_commit branch August 13, 2018 18:41
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.

2 participants