Artifact classification¶
These helpers build cheap, JSON-compatible classification metadata for records. They describe artifact shape and reader hints without opening scientific data payloads.
- ogcat.classification.classify_artifact(locator, *, original_path=None, original_filename=None, suffixes=None)[source]¶
Infer normalized, cheap artifact classification metadata.
The classifier uses locator text, path suffixes, and local path shape. It does not open NetCDF, HDF5, Zarr, or other scientific data payloads. For local zip files it may read the central directory to identify a single member’s suffix without extracting file content.
- Parameters:
locator (
ArtifactLocator) – Stored artifact locator.original_path (
str|Path|None) – Optional original source path or URI.original_filename (
str|None) – Optional original source filename.suffixes (
Sequence[str] |None) – Optional suffix list to preserve in the classification.
- Return type:
- Returns:
JSON-compatible metadata for
derived_metadata["classification"].
- ogcat.classification.collection_classification_metadata(*, collection_pattern='*', member_format=None, member_suffixes=None, reader_hint=None)[source]¶
Build explicit classification metadata for a logical collection.
Collection classification is opt-in policy. It records the caller’s cheap description of directory members without scanning, opening, or validating member files.
- Parameters:
collection_pattern (
str) – Relative glob/pattern that describes intended collection members.member_format (
str|None) – Optional format label for collection members.member_suffixes (
Sequence[str] |None) – Optional suffixes expected for collection members. When omitted, suffixes are inferred fromcollection_pattern.reader_hint (
str|None) – Optional human-readable hint for downstream readers.
- Return type:
- Returns:
Metadata suitable for
derived_metadata["classification"].- Raises:
ValueError – If collection metadata contains unsafe or empty values.