Path loaders
Loaders for PathBuckets.
The Loaders in this module are used to
load and save objects identified by a unique Path.
For saving objects, these loaders rely on checking the type of the
object for can_save and
save methods. For loading objects,
these loaders rely on checking the file extension of the path for
can_load and
load methods.
class PathLoader
#
A Loader for loading and saving
objects indentified by a Path.
name: str
classvar
#
The name of the loader.
def can_load(key, /, *, check=None)
abstractmethod
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
abstractmethod
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def save(obj, key)
abstractmethod
classmethod
#
class NPYLoader
#
Bases: PathLoader[ndarray]
A Loader for loading and
saving np.ndarrays.
This loader supports the following file extensions:
".npy"
This loader supports the following types:
name: ClassVar
classvar
attr
#
The name of the loader.
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
Source code in src/amltk/store/paths/path_loaders.py
class PDLoader
#
Bases: PathLoader[DataFrame | Series]
A Loader for loading and
saving pd.DataFrames.
This loader supports the following file extensions:
".csv"".parquet"".pdpickle"
This loader supports the following types:
pd.DataFramepd.Series- Only to".pdpickle"files
Multiindex support
There is currently no multi-index support as we explicitly
use index_col=0 when loading a ".csv" file. This is
because we assume that the first column is the index to
prevent Unamed columns from being created.
Series support
There is currently limited support for pandas series as once written to csv/parquet, they are converted to a dataframe with a single column. See this issue
Please consider using ".pdpickle" instead.
name: ClassVar
classvar
attr
#
The name of the loader.
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
Source code in src/amltk/store/paths/path_loaders.py
def save(obj, key)
classmethod
#
Source code in src/amltk/store/paths/path_loaders.py
class JSONLoader
#
Bases: PathLoader[dict | list]
A Loader for loading and
saving dicts and lists to JSON.
This loader supports the following file extensions:
".json"
This loader supports the following types:
name: ClassVar
classvar
attr
#
The name of the loader.
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
Source code in src/amltk/store/paths/path_loaders.py
class YAMLLoader
#
Bases: PathLoader[dict | list]
A Loader for loading and
saving dicts and lists to YAML.
This loader supports the following file extensions:
".yaml"".yml"
This loader supports the following types:
name: ClassVar
classvar
attr
#
The name of the loader.
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
Source code in src/amltk/store/paths/path_loaders.py
class PickleLoader
#
Bases: PathLoader[Any]
A Loader for loading and
saving any object to a pickle file.
This loader supports the following file extensions:
".pkl"
This loader supports the following types:
- object
Picklability
This loader uses Python's built-in pickle module
to save and load objects. This means that the object must be
picklable in order to be saved and loaded. If the
object is not picklable, then an error will be raised when
attempting to save or load the object.
name: ClassVar
classvar
attr
#
The name of the loader.
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
Source code in src/amltk/store/paths/path_loaders.py
class TxtLoader
#
Bases: PathLoader[str]
A Loader for loading and
saving strs to text files.
This loader supports the following file extensions:
".text"".txt"
This loader supports the following types:
name: ClassVar
classvar
attr
#
The name of the loader.
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |
class ByteLoader
#
Bases: PathLoader[bytes]
A Loader for loading and
saving bytes to binary files.
This loader supports the following file extensions:
".bin"".bytes"
This loader supports the following types:
def can_load(key, /, *, check=None)
classmethod
#
Return True if this loader supports the resource at key.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key used to identify the resource
TYPE:
|
check |
If the loader can support loading a specific type of object.
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
Source code in src/amltk/store/paths/path_loaders.py
def can_save(obj, key)
classmethod
#
Return True if this loader can save this object.
This is used to determine which loader to use when loading a resource from a key.
| PARAMETER | DESCRIPTION |
|---|---|
obj |
The object to save.
TYPE:
|
key |
The key used to identify the resource
TYPE:
|
Source code in src/amltk/store/paths/path_loaders.py
def load(key)
classmethod
#
Load an object from the given key.
| PARAMETER | DESCRIPTION |
|---|---|
key |
The key to load the object from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The loaded object. |