dtoolcore.storagebroker¶
Disk storage broker.
-
class
dtoolcore.storagebroker.
BaseStorageBroker
[source]¶ Base storage broker class defining the required interface.
-
add_item_metadata
(handle, key, value)[source]¶ Store the given key:value pair for the item associated with handle.
Parameters: - handle – handle for accessing an item before the dataset is frozen
- key – metadata key
- value – metadata value
-
get_annotation
(annotation_name)[source]¶ Return value of the annotation associated with the key.
Returns: annotation (string, int, float, bool) Raises: DtoolCoreAnnotationKeyError if the annotation does not exist
-
get_item_abspath
(identifier)[source]¶ Return absolute path at which item content can be accessed.
Parameters: identifier – item identifier Returns: absolute path from which the item content can be accessed
-
get_item_metadata
(handle)[source]¶ Return dictionary containing all metadata associated with handle.
In other words all the metadata added using the
add_item_metadata
method.Parameters: handle – handle for accessing an item before the dataset is frozen Returns: dictionary containing item metadata
-
has_admin_metadata
()[source]¶ Return True if the administrative metadata exists.
This is the definition of being a “dataset”.
-
classmethod
list_dataset_uris
(base_uri, config_path)[source]¶ Return list containing URIs in location given by base_uri.
Return list of tags.
-
post_freeze_hook
()[source]¶ Post
dtoolcore.ProtoDataSet.freeze()
cleanup actions.This method is called at the end of the
dtoolcore.ProtoDataSet.freeze()
method.In the
dtoolcore.storage_broker.DiskStorageBroker
it removes the temporary directory for storing item metadata fragment files.
-
pre_freeze_hook
()[source]¶ Pre
dtoolcore.ProtoDataSet.freeze()
actions.This method is called at the beginning of the
dtoolcore.ProtoDataSet.freeze()
method.It may be useful for remote storage backends to generate caches to remove repetitive time consuming calls
-
put_annotation
(annotation_name, annotation)[source]¶ Set/update value of the annotation associated with the key.
Raises: DtoolCoreAnnotationTypeError if the type of the value is not str, int, float or bool.
-
put_item
(fpath, relpath)[source]¶ Put item with content from fpath at relpath in dataset.
Missing directories in relpath are created on the fly.
Parameters: - fpath – path to the item on disk
- relpath – relative path name given to the item in the dataset as a handle
Returns: the handle given to the item
-
-
class
dtoolcore.storagebroker.
DiskStorageBroker
(uri, config_path=None)[source]¶ Storage broker to interact with datasets on local disk storage.
The
dtoolcore.ProtoDataSet
class uses thedtoolcore.storage_broker.DiskStorageBroker
to construct datasets by writing to disk and thedtoolcore.DataSet
class uses it to read datasets from disk.-
add_item_metadata
(handle, key, value)[source]¶ Store the given key:value pair for the item associated with handle.
Parameters: - handle – handle for accessing an item before the dataset is frozen
- key – metadata key
- value – metadata value
-
get_item_abspath
(identifier)[source]¶ Return absolute path at which item content can be accessed.
Parameters: identifier – item identifier Returns: absolute path from which the item content can be accessed
-
get_item_metadata
(handle)[source]¶ Return dictionary containing all metadata associated with handle.
In other words all the metadata added using the
add_item_metadata
method.Parameters: handle – handle for accessing an item before the dataset is frozen Returns: dictionary containing item metadata
-
has_admin_metadata
()[source]¶ Return True if the administrative metadata exists.
This is the definition of being a “dataset”.
-
hasher
= <dtoolcore.filehasher.FileHasher object>¶ Attribute used by
dtoolcore.ProtoDataSet
to write the hash function name to the manifest.
-
key
= 'file'¶ Attribute used to define the type of storage broker.
-
classmethod
list_dataset_uris
(base_uri, config_path)[source]¶ Return list containing URIs in location given by base_uri.
Return list of tags.
-
post_freeze_hook
()[source]¶ Post
dtoolcore.ProtoDataSet.freeze()
cleanup actions.This method is called at the end of the
dtoolcore.ProtoDataSet.freeze()
method.In the
dtoolcore.storage_broker.DiskStorageBroker
it removes the temporary directory for storing item metadata fragment files.
-
pre_freeze_hook
()[source]¶ Pre
dtoolcore.ProtoDataSet.freeze()
actions.This method is called at the beginning of the
dtoolcore.ProtoDataSet.freeze()
method.It may be useful for remote storage backends to generate caches to remove repetitive time consuming calls
-
put_item
(fpath, relpath)[source]¶ Put item with content from fpath at relpath in dataset.
Missing directories in relpath are created on the fly.
Parameters: - fpath – path to the item on disk
- relpath – relative path name given to the item in the dataset as a handle, i.e. a Unix-like relpath
Returns: the handle given to the item
-