src/core/common/environment.py
def validate_dataframe_or_path(cls, value: EnvInputAttr) -> pd.DataFrame:
        """
        Transforms an input into the expected type for the parameter. In case a file it's provided
        it's content is converted into a pandas DataFrame.

        Args:
            value (EnvInputAttr): Value to be validated (Union[pd.DataFrame, Path, str]).

        Raises:
            FileNotFoundError: When the provided value is a non-existent Path.
            NotImplementedError: When the provided value is not supported.

        Returns:
            pd.DataFrame: Validated attribute value.
        """

        def read_index(value_file: Path) -> pd.DataFrame:
            """Function applicable to time-series in Pandas."""
            time_series = pd.read_csv(value_file, sep="\t")
            if time_series.isnull().values.any():
                msg = f"NaNs detected in time series {value_file}"
                raise ValueError(msg)
            time_series["date"] = pd.to_datetime(time_series["date"])
            time_series.set_index("date", inplace=True)
            return time_series

        if isinstance(value, pd.DataFrame):
            return value
        if isinstance(value, str):
            value = Path(value)
        if isinstance(value, Path):
            if not value.is_file():
                raise FileNotFoundError(value)
            return read_index(value)
        raise NotImplementedError(f"Validator not available for type {type(value)}")

        Transforms an input into the expected type for the parameter. In case a file it's provided
        it's content is converted into a pandas DataFrame.

        Args:
            value (EnvInputAttr): Value to be validated (Union[pd.DataFrame, Path, str]).

        Raises:
            FileNotFoundError: When the provided value is a non-existent Path.
            NotImplementedError: When the provided value is not supported.

        Returns:
            pd.DataFrame: Validated attribute value.
        
Transforms an input into the expected type for the parameter. In case a file it's provided
it's content is converted into a pandas DataFrame.
Transforms an input into the expected type for the parameter . In case a file it ' s provided it ' s content is converted into a pandas DataFrame .
def validate_dataframe_or_path(cls, value: EnvInputAttr) -> pd.DataFrame:
        def read_index(value_file: Path) -> pd.DataFrame:
            time_series = pd.read_csv(value_file, sep="\t")
            if time_series.isnull().values.any():
                msg = f"NaNs detected in time series {value_file}"
                raise ValueError(msg)
            time_series["date"] = pd.to_datetime(time_series["date"])
            time_series.set_index("date", inplace=True)
            return time_series
        if isinstance(value, pd.DataFrame):
            return value
        if isinstance(value, str):
            value = Path(value)
        if isinstance(value, Path):
            if not value.is_file():
                raise FileNotFoundError(value)
            return read_index(value)
        raise NotImplementedError(f"Validator not available for type {type(value)}")
def validate_dataframe_or_path ( cls , value : EnvInputAttr ) -> pd . DataFrame : def read_index ( value_file : Path ) -> pd . DataFrame : """Function applicable to time-series in Pandas.""" time_series = pd . read_csv ( value_file , sep = "\t" ) if time_series . isnull ( ) . values . any ( ) : msg = f"NaNs detected in time series {value_file}" raise ValueError ( msg ) time_series [ "date" ] = pd . to_datetime ( time_series [ "date" ] ) time_series . set_index ( "date" , inplace = True ) return time_series if isinstance ( value , pd . DataFrame ) : return value if isinstance ( value , str ) : value = Path ( value ) if isinstance ( value , Path ) : if not value . is_file ( ) : raise FileNotFoundError ( value ) return read_index ( value ) raise NotImplementedError ( f"Validator not available for type {type(value)}" )
Transforms an input into the expected type for the parameter.
Transforms an input into the expected type for the parameter .
"""
        Transforms an input into the expected type for the parameter. In case a file it's provided
        it's content is converted into a pandas DataFrame.

        Args:
            value (EnvInputAttr): Value to be validated (Union[pd.DataFrame, Path, str]).

        Raises:
            FileNotFoundError: When the provided value is a non-existent Path.
            NotImplementedError: When the provided value is not supported.

        Returns:
            pd.DataFrame: Validated attribute value.
        """ """Function applicable to time-series in Pandas."""
Validated attribute value.
Validated attribute value .
pd.DataFrame
When the provided value is a non-existent Path.
When the provided value is a non - existent Path .
FileNotFoundError
When the provided value is not supported.
When the provided value is not supported .
NotImplementedError
cls
value
EnvInputAttr
Value to be validated (Union[pd.DataFrame, Path, str]).
Value to be validated ( Union [ pd . DataFrame Path str ] ) .