Data Handler¶
DataHandler()
¶
Base class to handle connection and data acquisition.
This is an abstract class and it's methods shall be defined in subclasses for each data source type.
Source code in echo_dataimporter/handler.py
def __init__(self) -> None:
"""Base class constructor. Will define self.pg_conn_props to connect to performance_db."""
self.perfdb = PerfDB(application_name=f"{type(self).__name__}:{socket.gethostname()}")
self.scada_conn_props: SqlHandler = None # this should be defined in __init__ of subclass
alarm_definitions(object_types=None)
abstractmethod
¶
Method that returns the definitions of alarms in the data source
Source code in echo_dataimporter/handler.py
@abstractmethod
def alarm_definitions(self, object_types: list[str] | None = None) -> pd.DataFrame:
"""Method that returns the definitions of alarms in the data source"""
alarm_history(object_name, period, subperiod_length=None, alarm_types=None)
abstractmethod
¶
Method that returns the history of alarms for one object in the data source
Source code in echo_dataimporter/handler.py
@abstractmethod
def alarm_history(
self,
object_name: str,
period: DateTimeRange,
subperiod_length: relativedelta | None = None,
alarm_types: list[Literal["A", "W", "S"]] | None = None,
) -> pd.DataFrame:
"""Method that returns the history of alarms for one object in the data source"""
feature_definitions(object_types=None)
abstractmethod
¶
Method that returns the definitions of features in the data source
Source code in echo_dataimporter/handler.py
@abstractmethod
def feature_definitions(self, object_types: list[str] | None = None) -> pd.DataFrame:
"""Method that returns the definitions of features in the data source"""
feature_values(object_name, features_df, period, subperiod_length)
abstractmethod
¶
Method that returns the time series of features for an object in the data source.
The returned DataFrame must have timestamp as index and feature names as columns.
Source code in echo_dataimporter/handler.py
@abstractmethod
def feature_values(
self,
object_name: str,
features_df: pd.DataFrame,
period: DateTimeRange,
subperiod_length: relativedelta,
) -> pd.DataFrame:
"""Method that returns the time series of features for an object in the data source.
The returned DataFrame must have timestamp as index and feature names as columns.
"""
object_types()
abstractmethod
¶
Method that returns the possible object types in the data source
Source code in echo_dataimporter/handler.py
@abstractmethod
def object_types(self) -> pd.DataFrame:
"""Method that returns the possible object types in the data source"""
objects(object_types=None)
abstractmethod
¶
Method that returns the possible objects in the data source
Source code in echo_dataimporter/handler.py
@abstractmethod
def objects(self, object_types: list[str] | None = None) -> pd.DataFrame:
"""Method that returns the possible objects in the data source"""