DataSource¶
A module for representing and managing data sources. It defines an abstract base class for data sources as well as concrete implementations with serialization and deserialization functionality.
- class algomancy_data.datasource.DataClassification(*values)[source]¶
Bases:
StrEnum- MASTER_DATA = 'master_data'¶
- DERIVED_DATA = 'derived_data'¶
- DUMMY_DATA = 'dummy_data'¶
- class algomancy_data.datasource.BaseDataSource(ds_type, name=None, validation_messages=None, ds_id=None, creation_datetime=None)[source]¶
Bases:
ABCBase class for data sources.
This class serves as a base for defining different types of data sources. It provides basic attributes and methods to handle data source IDs, creation timestamps, names, and validation messages. It also defines abstract methods that should be implemented by derived classes to handle data serialization and derivation.
- validation_messages¶
List of validation messages for the data source.
- Type:
List[ValidationMessage] | None
- property name: str¶
- property id¶
- property creation_datetime¶
- derive(new_data_key)[source]¶
Creates a derived object with a given new key.
This method generates a duplicate of the current object with the same data and sets a new key for it, effectively creating a derived object with a different identifier.
- Parameters:
new_data_key (
str) – The new key to assign to the derived object.- Returns:
A new instance of the same class with the derived data and updated key.
- Return type:
Type of the calling class
- initialize_data_parameters()[source]¶
Declare per-scenario knobs this data source exposes.
Subclasses override to return a populated
BaseParameterSetwith whichever typed parameters make sense for the dataset (date range, region filter, etc.). The framework persists user-supplied values on each scenario and hands them to the algorithm viaBaseAlgorithm.set_data_paramsbeforerun(); the algorithm decides whether and how to act on them.The default returns
EmptyParameters()so existing data sources keep working with no edits.- Returns:
- A fresh template describing this data source’s
parameters. Callers populate values via
set_validated_values.
- Return type:
- class algomancy_data.datasource.DataSource(ds_type, name=None, validation_messages=None, ds_id=None, creation_datetime=None)[source]¶
Bases:
BaseDataSource- tables: dict[str, DataFrame]¶
- to_json()[source]¶
Serializes the DataSource object to JSON format. This is useful for creating human-readable downloadable content in a Dash app.
- Returns:
The serialized DataSource as JSON string
- Return type:
str