Bucket¶
Module for bucket object.
-
class
qarnot.bucket.
Bucket
(connection, name, create=True)[source]¶ Bases:
qarnot.storage.Storage
Represents a resource/result bucket.
This class is the interface to manage resources or results from a
qarnot.bucket.Bucket
.Note
A
Bucket
must be created withqarnot.connection.Connection.create_bucket()
or retrieved withqarnot.connection.Connection.buckets()
,qarnot.connection.Connection.retrieve_bucket()
, orqarnot.connection.Connection.retrieve_or_create_bucket()
.Note
Paths given as ‘remote’ arguments, (or as path arguments for
Bucket.directory()
) must be valid unix-like paths.-
__init__
(connection, name, create=True)[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
list_files
()[source]¶ List files in the bucket
Return type: list( S3.ObjectSummary
)Returns: A list of ObjectSummary resources
-
directory
(directory='')[source]¶ List files in a directory of the bucket according to prefix.
Return type: list( S3.ObjectSummary
)Returns: A list of ObjectSummary resources
-
sync_directory
(directory, verbose=False, remote=None)[source]¶ Synchronize a local directory with the remote buckets.
Parameters: Warning
Local changes are reflected on the server, a file present on the bucket but not in the local directory will be deleted from the bucket.
A file present in the directory but not in the bucket will be uploaded.
Note
The following parameters are used to determine whether synchronization is required :
- name
- size
- sha1sum
-
sync_files
(files, verbose=False, remote=None)[source]¶ Synchronize files with the remote buckets.
Parameters: Dictionary key is the remote file path while value is the local file path.
Warning
Local changes are reflected on the server, a file present on the bucket but not in the local directory will be deleted from the bucket.
A file present in the directory but not in the bucket will be uploaded.
Note
The following parameters are used to determine whether synchronization is required :
- name
- size
- sha1sum
-
add_file
(local_or_file, remote=None)[source]¶ Add a local file or a Python File on the storage.
Note
You can also use object[remote] = local
Parameters:
-
get_all_files
(output_dir, progress=None)[source]¶ Get all files from the storage.
Parameters: Raises: - qarnot.exceptions.MissingBucketException – the bucket is not on the server
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
Warning
Will override output_dir content.
-
get_file
(remote, local=None, progress=None)[source]¶ Get a file from the storage. Create needed subfolders.
Parameters: Return type: Returns: The name of the output file.
Raises: ValueError – no such file
-
add_directory
(local, remote='')[source]¶ Add a directory to the storage. Does not follow symlinks. File hierarchy is preserved.
Parameters: Raises: IOError – not a valid directory
-
update
(flush=False)[source]¶ Update object from remote endpoint
Parameters: flush (bool) – bypass cache
-
delete_file
(remote)[source]¶ Delete a file from the storage.
Parameters: remote (str) – the name of the remote file
-
uuid
¶ Bucket identifier
-
description
¶ Bucket identifier
-