ts_shape.loader.metadata.metadata_json_loader
¤
Classes:
-
MetadataJsonLoader
–Load metadata JSON of shape:
MetadataJsonLoader
¤
into a pandas DataFrame with flattened config columns.
Parameters:
-
json_data
¤Any
) –Supported shapes: - dict of columns with index-maps: {"uuid": {"0": ...}, "label": {...}, "config": {...}} - dict of columns with lists: {"uuid": [...], "label": [...], "config": [...]} - list of records: [{"uuid": ..., "label": ..., "config": {...}}, ...]
-
strict
¤bool
, default:True
) –If True, enforce presence of required keys and unique UUIDs.
Methods:
-
filter_by_label
–Filter rows by a set or sequence of labels.
-
filter_by_uuid
–Filter rows by a set or sequence of UUIDs.
-
from_file
–Create a loader from a JSON file on disk.
-
from_str
–Create a loader from a JSON string.
-
get_by_label
–Retrieve the first row matching a label as a dictionary.
-
get_by_uuid
–Retrieve a row by UUID as a dictionary.
-
head
–Convenience wrapper for DataFrame.head.
-
join_with
–Join the metadata DataFrame with another DataFrame on the 'uuid' index.
-
list_labels
–Return all non-null labels.
-
list_uuids
–Return a list of UUIDs present in the metadata index.
-
to_df
–Return the underlying DataFrame.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
filter_by_label
¤
Filter rows by a set or sequence of labels.
Parameters:
Returns:
-
DataFrame
–Filtered DataFrame.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
285 286 287 288 289 290 291 292 293 294 295 296 |
|
filter_by_uuid
¤
Filter rows by a set or sequence of UUIDs.
Parameters:
Returns:
-
DataFrame
–Filtered DataFrame.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
272 273 274 275 276 277 278 279 280 281 282 283 |
|
from_file
classmethod
¤
from_file(filepath: str, *, strict: bool = True) -> MetadataJsonLoader
Create a loader from a JSON file on disk.
Parameters:
-
filepath
¤str
) –Path to the JSON file.
-
strict
¤bool
, default:True
) –Validation behavior; when True, enforces required fields and unique UUIDs.
Returns:
-
MetadataJsonLoader
–MetadataJsonLoader instance.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
from_str
classmethod
¤
from_str(json_str: str, *, strict: bool = True) -> MetadataJsonLoader
Create a loader from a JSON string.
Parameters:
-
json_str
¤str
) –Raw JSON content as a string.
-
strict
¤bool
, default:True
) –Validation behavior; when True, enforces required fields and unique UUIDs.
Returns:
-
MetadataJsonLoader
–MetadataJsonLoader instance.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
get_by_label
¤
Retrieve the first row matching a label as a dictionary.
Parameters:
Returns:
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
245 246 247 248 249 250 251 252 253 254 255 256 |
|
get_by_uuid
¤
Retrieve a row by UUID as a dictionary.
Parameters:
Returns:
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
head
¤
Convenience wrapper for DataFrame.head.
Parameters:
Returns:
-
DataFrame
–Top n rows of the metadata DataFrame.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
218 219 220 221 222 223 224 225 226 227 228 |
|
join_with
¤
Join the metadata DataFrame with another DataFrame on the 'uuid' index.
Parameters:
-
other_df
¤DataFrame
) –DataFrame to join with (must be indexed compatibly).
-
how
¤str
, default:'inner'
) –Join strategy (e.g., 'inner', 'left', 'outer').
Returns:
-
DataFrame
–Joined pandas DataFrame.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
258 259 260 261 262 263 264 265 266 267 268 269 |
|
list_labels
¤
Return all non-null labels.
Returns:
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
308 309 310 311 312 313 314 315 |
|
list_uuids
¤
Return a list of UUIDs present in the metadata index.
Returns:
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
299 300 301 302 303 304 305 306 |
|
to_df
¤
Return the underlying DataFrame.
Parameters:
Returns:
-
DataFrame
–pandas DataFrame indexed by 'uuid'.
Source code in src/ts_shape/loader/metadata/metadata_json_loader.py
206 207 208 209 210 211 212 213 214 215 216 |
|