openmmtools.storage.iodrivers.StorageIODriver¶
- class openmmtools.storage.iodrivers.StorageIODriver(file_name, access_mode=None)[source]¶
Abstract class to define the basic functions any storage driver needs to read/write to the disk. The specific driver for a type of storage should be a subclass of this with its own encoders and decoders for specific file types.
Each type of variable codec should subclass
Codec
which has the minimumwrite
,read
, andappend
methods- Parameters:
- file_namestring
Name of the file to read/write to of a given storage type
- access_modestring or None, Default None, accepts ‘w’, ‘r’, ‘a’
Define how to access the file in either write, read, or append mode None should behave like Python “a+” in which a file is created if not present, or opened in append if it is. How this is implemented is up to the subclass
- Attributes:
access_mode
Access mode of file on disk
file_name
File name of on hard drive
Methods
add_metadata
(name, value[, path])Function to add metadata to the file.
close
()Instruct how to safely close down the file.
create_storage_variable
(path, type_key)Create a new variable on the disk and at the path location and store it as the given type.
get_directory
(path[, create])Get a directory-like object located at path from disk.
get_storage_variable
(path)Get a variable IO object from disk at path.
set_codec
(type_key, codec)Add new codifier to the specific driver class.
Methods
__init__
(file_name[, access_mode])add_metadata
(name, value[, path])Function to add metadata to the file.
close
()Instruct how to safely close down the file.
create_storage_variable
(path, type_key)Create a new variable on the disk and at the path location and store it as the given type.
get_directory
(path[, create])Get a directory-like object located at path from disk.
get_storage_variable
(path)Get a variable IO object from disk at path.
set_codec
(type_key, codec)Add new codifier to the specific driver class.
Attributes
access_mode
Access mode of file on disk
file_name
File name of on hard drive