petitRADTRANS.sbi.artifacts#

Artifact metadata and registry interfaces for SBI assets.

This module defines the metadata and interfaces for saving and loading the datasets, trained posterior models, and validation reports produced by the SBI workflow. The metadata is used to ensure that the current SBI Task and the generated dataset are compatible.

Classes#

ArtifactRole

Artifact categories produced by the SBI workflow.

ArtifactMetadata

Traceability metadata shared by all persisted SBI artifacts.

ArtifactRegistry

Resolve and persist versioned SBI artifacts.

RegisteredArtifact

Stored registry entry for one persisted artifact.

FileArtifactRegistry

Simple JSON-backed registry for local SBI artifacts.

Functions#

save_predictive_spectrum(→ pathlib.Path)

Write a posterior-predictive spectrum (wavelength, observed, uncertainty,

_jsonable(→ Any)

write_json(→ None)

read_json(→ dict[str, Any])

compute_run_config_hash(→ str)

build_run_label(→ str)

latest_run_pointer_path(→ pathlib.Path)

resolve_run_manifest(→ dict[str, Any])

resolve_posterior_dir(→ pathlib.Path)

resolve_latest_posterior_run(→ tuple[pathlib.Path, ...)

resolve_latest_completed_run(→ tuple[pathlib.Path, ...)

count_predictive_case_checkpoints(→ int)

write_run_manifest(→ None)

update_latest_run_pointer(→ None)

Module Contents#

class petitRADTRANS.sbi.artifacts.ArtifactRole#

Bases: str, enum.Enum

Artifact categories produced by the SBI workflow.

SIMULATION_DATASET = 'simulation_dataset'#
POSTERIOR_MODEL = 'posterior_model'#
BENCHMARK_REPORT = 'benchmark_report'#
CALIBRATION_REPORT = 'calibration_report'#
class petitRADTRANS.sbi.artifacts.ArtifactMetadata#

Traceability metadata shared by all persisted SBI artifacts.

This is used to ensure that the current SBI Task and the generated dataset are compatible.

role: ArtifactRole#
task_name: str#
version: str#
estimator_family: str | None = None#
task_version: str | None = None#
task_fingerprint: str | None = None#
preprocessing_version: str | None = None#
forward_model_family: str | None = None#
petitradtrans_version: str | None = None#
retrieval_config_digest: str | None = None#
opacity_digest: str | None = None#
observation_schema: Mapping[str, Any]#
preprocessing_metadata: Mapping[str, Any]#
metadata: Mapping[str, Any]#
to_payload() dict[str, Any]#
classmethod from_payload(payload: Mapping[str, Any]) ArtifactMetadata#
classmethod from_task(task: petitRADTRANS.sbi.task.SBITask, role: ArtifactRole, version: str, estimator_family: str | None = None, metadata: Mapping[str, Any] | None = None, preprocessing_metadata: Mapping[str, Any] | None = None, retrieval_config_digest: str | None = None, opacity_digest: str | None = None) ArtifactMetadata#

Build artifact metadata from an SBI task family.

class petitRADTRANS.sbi.artifacts.ArtifactRegistry#

Bases: abc.ABC

Resolve and persist versioned SBI artifacts.

abstractmethod register(metadata: ArtifactMetadata, location: str) None#

Register an artifact location under the supplied metadata.

abstractmethod resolve(role: ArtifactRole, task_name: str, version: str | None = None) str#

Resolve an artifact path or URI for the requested task and role.

class petitRADTRANS.sbi.artifacts.RegisteredArtifact#

Stored registry entry for one persisted artifact.

metadata: ArtifactMetadata#
location: str#
to_payload() dict[str, Any]#
classmethod from_payload(payload: Mapping[str, Any]) RegisteredArtifact#
class petitRADTRANS.sbi.artifacts.FileArtifactRegistry(root_directory: str)#

Bases: ArtifactRegistry

Simple JSON-backed registry for local SBI artifacts.

root_directory#
index_path#
_load_entries() list[RegisteredArtifact]#
_write_entries(entries: list[RegisteredArtifact]) None#
register(metadata: ArtifactMetadata, location: str) None#

Register an artifact location under the supplied metadata.

resolve(role: ArtifactRole, task_name: str, version: str | None = None) str#

Resolve an artifact path or URI for the requested task and role.

petitRADTRANS.sbi.artifacts.save_predictive_spectrum(output_path: pathlib.Path, retrieval_config: Any, predictive_report: Any) pathlib.Path#

Write a posterior-predictive spectrum (wavelength, observed, uncertainty, predictive mean and interval) as a plain-text table.

The dataset is taken from the predictive report itself, so the saver is generic across observations.

petitRADTRANS.sbi.artifacts._jsonable(value: Any) Any#
petitRADTRANS.sbi.artifacts.write_json(path: pathlib.Path, payload: dict[str, Any]) None#
petitRADTRANS.sbi.artifacts.read_json(path: pathlib.Path) dict[str, Any]#
petitRADTRANS.sbi.artifacts.compute_run_config_hash(run_config: dict[str, Any]) str#
petitRADTRANS.sbi.artifacts.build_run_label(run_config: dict[str, Any]) str#
petitRADTRANS.sbi.artifacts.latest_run_pointer_path(output_root: pathlib.Path) pathlib.Path#
petitRADTRANS.sbi.artifacts.resolve_run_manifest(run_root: pathlib.Path) dict[str, Any]#
petitRADTRANS.sbi.artifacts.resolve_posterior_dir(run_root: pathlib.Path, manifest: dict[str, Any]) pathlib.Path#
petitRADTRANS.sbi.artifacts.resolve_latest_posterior_run(output_root: pathlib.Path) tuple[pathlib.Path, dict[str, Any]]#
petitRADTRANS.sbi.artifacts.resolve_latest_completed_run(output_root: pathlib.Path) tuple[pathlib.Path, dict[str, Any]]#
petitRADTRANS.sbi.artifacts.count_predictive_case_checkpoints(checkpoint_directory: pathlib.Path) int#
petitRADTRANS.sbi.artifacts.write_run_manifest(run_root: pathlib.Path, run_label: str, run_config: dict[str, Any], task: Any, dataset_uri: str, posterior_dir: pathlib.Path, summary_path: pathlib.Path | None, status: str) None#
petitRADTRANS.sbi.artifacts.update_latest_run_pointer(output_root: pathlib.Path, run_root: pathlib.Path, run_label: str) None#