Class - DataSource#
- class openfl.federated.data.sources.data_source.DataSource(type, name)[source]#
Bases:
ABCBase class for different types of data sources.
- Parameters:
type (DataSourceType)
name (str)
- type#
The storage type of the data source
- Type:
- name#
The name of the data source
- Type:
str
- __init__(type, name)[source]#
Initialize a DataSource.
- Parameters:
type (DataSourceType) – The storage type of the data source.
name (str) – The name of the data source.
Methods
__init__(type, name)Initialize a DataSource.
compute_file_hash(path)Compute the hash of the object or file.
Enumerate all files in the data source.
from_dict(ds_dict)Create a DataSource from a dictionary.
is_valid_hash_function(func)read_blob(path)Read a blob from the data source.
to_dict()Convert the object to a dictionary using the serialization rules.
- abstract compute_file_hash(path)[source]#
Compute the hash of the object or file.
- Parameters:
path (str) – Path to the file.
- Returns:
The file’s hash.
- Return type:
str
- abstract enumerate_files()[source]#
Enumerate all files in the data source.
- Yields:
str – The file path.
- Return type:
Generator[str, None, None]
- abstract classmethod from_dict(ds_dict)[source]#
Create a DataSource from a dictionary.
- Parameters:
ds_dict (dict) – The dictionary to convert.
- Returns:
The created DataSource.
- Return type: