plaid.storage.common.reader¶
plaid.storage.common.reader
¶
Common storage reader utilities.
This module provides common utilities for reading dataset metadata, problem definitions, and other auxiliary files from disk or downloading them from Hugging Face Hub.
plaid.storage.common.reader.load_infos_from_disk
¶
Load dataset information from a YAML file stored on disk.
Parameters:
-
path(Union[str, Path]) –Directory path containing the
infos.yamlfile.
Returns:
-
Infos(Infos) –Validated dataset infos object.
Source code in plaid/storage/common/reader.py
plaid.storage.common.reader.load_problem_definitions_from_disk
¶
Load ProblemDefinitions from a local dataset directory.
This function reads all serialized ProblemDefinition files located in the
problem_definitions/ subdirectory under path and reconstructs them
into ProblemDefinition objects.
Each file is loaded using ProblemDefinition.from_path and inserted into
a dictionary keyed by the YAML filename stem.
Expected local layout
Parameters:
-
path(Union[str, Path]) –Root dataset directory containing the
problem_definitions/folder.
Returns:
-
dict[str, ProblemDefinition] | None–dict[str, ProblemDefinition] | None: Mapping from problem definition filename stems to loaded
ProblemDefinitionobjects.
Source code in plaid/storage/common/reader.py
plaid.storage.common.reader.load_constants_from_disk
¶
Load constant features stored under a dataset's "constants" directory.
The function expects the following layout under
Parameters:
-
path(str | Path) –Root dataset directory that contains the "constants" folder.
Returns:
-
tuple(tuple[dict[str, dict[str, Any]], dict[str, dict[str, Any]]]) –A 2-tuple
(flat_cst, constant_schema)whereflat_cstandconstant_schemaare bothdict[str, dict[str, Any]]. Numeric constants are returned asnp.memmaparrays backed bydata.mmap. String constants are returned as one-element numpy arrays of Python strings decoded using ASCII. If a layout entry isNone, the returned value isNone.
Raises:
-
FileNotFoundError–If the expected "constants" directory or required files are missing.
Source code in plaid/storage/common/reader.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
plaid.storage.common.reader.load_metadata_from_disk
¶
Load dataset metadata from disk.
Parameters:
-
path(Union[str, Path]) –Directory path containing the metadata files.
Returns:
-
tuple[dict[str, Any], dict[str, Any], dict[str, Any], dict[str, Any]]–tuple[dict[str, Any], dict[str, Any], dict[str, Any], dict[str, Any]]: - flat_cst: constant features dictionary (numeric constants kept as file-backed
np.memmap) - variable_schema: variable schema dictionary - constant_schema: constant schema dictionary - cgns_types: CGNS types dictionary
Source code in plaid/storage/common/reader.py
plaid.storage.common.reader.load_infos_from_hub
¶
Load dataset infos from the Hugging Face Hub.
Downloads the infos.yaml file from the specified repository and parses it
into a validated :class:Infos.
Parameters:
-
repo_id(str) –The repository ID on the Hugging Face Hub.
Returns:
-
Infos(Infos) –Validated dataset infos object.
Source code in plaid/storage/common/reader.py
plaid.storage.common.reader.load_problem_definitions_from_hub
¶
Load ProblemDefinitions from Hugging Face Hub.
Parameters:
-
repo_id(str) –The repository ID on the Hugging Face Hub.
Returns:
-
Optional[dict[str, ProblemDefinition]]–Optional[list[ProblemDefinition]]: List of loaded problem definitions, or None if not found.
Source code in plaid/storage/common/reader.py
plaid.storage.common.reader.load_metadata_from_hub
¶
Load dataset metadata from Hugging Face Hub.
Parameters:
-
repo_id(str) –The repository ID on the Hugging Face Hub.
Returns:
-
tuple[dict[str, Any], dict[str, Any], dict[str, Any], dict[str, Any]]–tuple[dict[str, Any], dict[str, Any], dict[str, Any], dict[str, Any]]: - flat_cst: constant features dictionary (numeric constants are materialized to in-memory arrays) - variable_schema: variable schema dictionary - constant_schema: constant schema dictionary - cgns_types: CGNS types dictionary