You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All classes within the Dir API should be able to provide instant access to a file through the File API, for example:
fromfluke.storageimportLocalDir# Reference a directory through the "Dir" API.dir=LocalDir(dir='path/to/dir')
# Gain access to the "File" API through a "Dir" method, e.g. ``get_file``.file=dir.get_file(path='path/to/file')
# Interact with a file through the "File" API.size=file.get_size()
In the case of remote directories/files, all File instances generated by such method should have the following properties:
1. All files should share the same connection with the directory that generated them.
It should not be required for the user to explicitly close each generated file instance. Closing the directory should be enough. For example:
fromfluke.storageimportRemoteDir# Reference remote directory.dir=RemoteDir(auth=auth, path='/path/to/remote/dir/')
# Reference remote file.file=dir.get_file(path='file.txt')
# Close connection.dir.close()
# This should throw an error since connection has been closed.size=file.get_size()
Similarly when using a context manager:
fromfluke.storageimportRemoteDirauth=RemoteAuth.from_password(**credentials)
withRemoteDir(auth=auth, path='/path/to/remote/dir/') asdir:
file=dir.get_file(path='file.txt')
# This should throw an error since connection has been closed.size=file.get_size()
2. A "File" instance and the "Dir" instance that generated it should have access to the same metadata.
fromfluke.storageimportRemoteDir# Reference remote directory.dir=RemoteDir(auth=auth, path='/path/to/remote/dir/')
# Reference remote files.file=dir.get_file(path='file.txt')
# Set metadata through "file"file.set_metadata({'name': 'file.txt'})
# Access metadata through "dir".metadata=dir.get_metadata('file.txt') # equals {'name': 'file.txt'}
3. A "File" instance and the "Dir" instance that generated it should have access to the same cache.
fromfluke.storageimportRemoteDir# Reference directory and enable caching.withRemoteDir(auth=auth, path='/path/to/remote/dir/', cache=True) asdir:
# Get size of directory.dir_size=dir.get_size()
# Reference a file.file=dir.get_file(path='file.txt')
# File size should be fetched from the cache.file_size=file.get_size()
The text was updated successfully, but these errors were encountered:
All classes within the Dir API should be able to provide instant access to a file through the File API, for example:
In the case of remote directories/files, all File instances generated by such method should have the following properties:
1. All files should share the same connection with the directory that generated them.
It should not be required for the user to explicitly close each generated file instance. Closing the directory should be enough. For example:
Similarly when using a context manager:
2. A "File" instance and the "Dir" instance that generated it should have access to the same metadata.
3. A "File" instance and the "Dir" instance that generated it should have access to the same cache.
The text was updated successfully, but these errors were encountered: