Backend¶
backend
¶
Backend module for handling file IO in flepimop2.
BackendABC(backend_model)
¶
Bases: ABC
Abstract base class for flepimop2 file IO backends.
Initialize the backend with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_model
|
dict[str, Any]
|
The configuration dictionary for the backend. |
required |
Source code in src/flepimop2/backend/abc.py
16 17 18 19 20 21 22 | |
read(run_meta)
¶
Read a numpy array from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
The numpy array read from storage. |
Source code in src/flepimop2/backend/abc.py
34 35 36 37 38 39 40 41 42 43 44 | |
save(data, run_meta)
¶
Save a numpy array to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
NDArray[float64]
|
The numpy array to save. |
required |
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
Source code in src/flepimop2/backend/abc.py
24 25 26 27 28 29 30 31 32 | |
build(config)
¶
Build a BackendABC from a configuration dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any]
|
Configuration dictionary. The dict must contains a 'module' key, which will be used to lookup the Backend module path. The module will have "flepimop2.backend." prepended. |
required |
Returns:
| Type | Description |
|---|---|
BackendABC
|
The constructed backend instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the built backend is not an instance of BackendABC. |
Source code in src/flepimop2/backend/abc.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
abc
¶
Abstract base class for flepimop2 file IO backends.
BackendABC(backend_model)
¶
Bases: ABC
Abstract base class for flepimop2 file IO backends.
Initialize the backend with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend_model
|
dict[str, Any]
|
The configuration dictionary for the backend. |
required |
Source code in src/flepimop2/backend/abc.py
16 17 18 19 20 21 22 | |
read(run_meta)
¶
Read a numpy array from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[float64]
|
The numpy array read from storage. |
Source code in src/flepimop2/backend/abc.py
34 35 36 37 38 39 40 41 42 43 44 | |
save(data, run_meta)
¶
Save a numpy array to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
NDArray[float64]
|
The numpy array to save. |
required |
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
Source code in src/flepimop2/backend/abc.py
24 25 26 27 28 29 30 31 32 | |
build(config)
¶
Build a BackendABC from a configuration dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any]
|
Configuration dictionary. The dict must contains a 'module' key, which will be used to lookup the Backend module path. The module will have "flepimop2.backend." prepended. |
required |
Returns:
| Type | Description |
|---|---|
BackendABC
|
The constructed backend instance. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the built backend is not an instance of BackendABC. |
Source code in src/flepimop2/backend/abc.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
csv
¶
CSV backend for flepimop2.
CsvBackend(root)
¶
Bases: BackendABC
CSV backend for saving numpy arrays to CSV files.
Initialize the CSV backend with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
PathLike[str] | None
|
Base output directory for CSV files. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the 'root' is not a string or Path. |
Source code in src/flepimop2/backend/csv.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
build(root=None)
¶
Build a CsvBackend from a configuration dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
PathLike[str] | None
|
Base output directory for CSV files. 'module' key, which will be used to lookup the Backend module path. The module will have "flepimop2.backends." prepended. |
None
|
Returns:
| Type | Description |
|---|---|
BackendABC
|
The constructed csv backend. |
Source code in src/flepimop2/backend/csv.py
77 78 79 80 81 82 83 84 85 86 87 88 89 | |