Skip to content

base

logger = logging.getLogger(__name__) module-attribute

Metadata

Bases: DataFetcher

Source code in src/recnexteval/datasets/metadata/base.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Metadata(DataFetcher):
    config: ClassVar[MetadataConfig] = MetadataConfig()

    def __init__(
        self,
        filename: Optional[str] = None,
        base_path: Optional[str] = None,
    ) -> None:
        self.base_path = base_path if base_path else self.config.default_base_path
        logger.debug(f"{self.name} being initialized with '{self.base_path}' as the base path.")

        self.filename = filename if filename else self.config.default_filename
        if not self.filename:
            raise ValueError("No filename specified, and no default known.")

        safe_dir(self.base_path)
        logger.debug(f"{self.name} is initialized.")

    def load(self) -> pd.DataFrame:
        """Load the metadata from file and return it as a DataFrame.

        Returns:
            DataFrame containing the metadata.
        """
        return self._load_dataframe()

config = MetadataConfig() class-attribute

base_path = base_path if base_path else self.config.default_base_path instance-attribute

filename = filename if filename else self.config.default_filename instance-attribute

IS_BASE = True class-attribute instance-attribute

name property

Name of the object's class.

:return: Name of the object's class :rtype: str

file_path property

File path of the dataset.

processed_cache_path property

Path for cached processed data.

load()

Load the metadata from file and return it as a DataFrame.

Returns:

Type Description
DataFrame

DataFrame containing the metadata.

Source code in src/recnexteval/datasets/metadata/base.py
32
33
34
35
36
37
38
def load(self) -> pd.DataFrame:
    """Load the metadata from file and return it as a DataFrame.

    Returns:
        DataFrame containing the metadata.
    """
    return self._load_dataframe()

fetch_dataset()

Check if dataset is present, if not download

Source code in src/recnexteval/datasets/base.py
39
40
41
42
43
44
45
def fetch_dataset(self) -> None:
    """Check if dataset is present, if not download"""
    if os.path.exists(self.file_path):
        logger.debug("Data file is in memory and in dir specified.")
        return
    logger.debug(f"{self.name} dataset not found in {self.file_path}.")
    self._download_dataset()

fetch_dataset_force()

Force re-download of the dataset.

Source code in src/recnexteval/datasets/base.py
47
48
49
50
def fetch_dataset_force(self) -> None:
    """Force re-download of the dataset."""
    logger.debug(f"{self.name} force re-download of dataset.")
    self._download_dataset()