openghg_inversions.rhime.builders#
Public whole-model build contracts and validation for RHIME customizations.
- class openghg_inversions.rhime.builders.RhimeModelBuildResult(model: ~pymc.model.core.Model, variable_roles: ~collections.abc.Mapping[str, str], supported_output_formats: tuple[~typing.Literal['none', 'inv_out', 'basic', 'paris', 'legacy'], ...] = ('none',), metadata: ~collections.abc.Mapping[str, ~typing.Any] = <factory>)#
Bases:
objectConcrete model and serializable metadata returned by a model builder.
Custom builders default to supporting sampling-only runs (
output_format="none"). A builder must explicitly declare additional formats after ensuring that its role manifest and trace satisfy those postprocessing contracts.- Parameters:
model – Concrete PyMC model for
RhimeSampler.variable_roles – Semantic role to concrete input/model variable name. Roles such as
concentration,model_error,flux_scale, andbaselinelet sampling and outputs avoid name inference. Components that do not exist, such as model error in a fixed-error model, should be omitted.supported_output_formats – Output formats the builder declares safe.
"none"always means sampling without RHIME postprocessing.metadata – Additional JSON-serializable builder/provenance metadata.
- supported_output_formats: tuple[Literal['none', 'inv_out', 'basic', 'paris', 'legacy'], ...] = ('none',)#
- class openghg_inversions.rhime.builders.RhimeModelBuilder(*args, **kwargs)#
Bases:
ProtocolAdvanced callable contract for a complete user-owned model factory.
- class openghg_inversions.rhime.builders.RhimeModelBuilderContext(prepared_inputs: RhimePreparedInputs, run_spec: RhimeRunSpec, multisector: bool)#
Bases:
objectAdvanced compatibility input supplied only to a complete model builder.
Ordinary in-tree recipes and components use explicit named scientific inputs. This context remains solely for user-owned complete models invoked through
run_rhime_from_prepared_inputs; those builders own validation and materialization of any lazy arrays they consume.- Parameters:
prepared_inputs – Validated canonical inputs, retained basis functions, and preparation metadata.
run_spec – Model, output, and run settings for this execution. The callable is deliberately kept outside this serializable spec.
multisector – Whether the validated prepared layout and model spec are sector resolved.
- prepared_inputs: RhimePreparedInputs#
- run_spec: RhimeRunSpec#
- openghg_inversions.rhime.builders.callable_metadata(builder: Callable[[...], Any]) dict[str, str]#
Return stable, serializable direct-Python callable identity metadata.
- Parameters:
builder – Callable whose import module and qualified name identify the runtime customization.
- Returns:
JSON-serializable module and qualified-name fields.
- openghg_inversions.rhime.builders.validate_model_build_result(result: RhimeModelBuildResult, *, context: RhimeModelBuilderContext) None#
Validate a custom build result before sampling or postprocessing.
- Parameters:
result – Complete model build result to validate.
context – Prepared inputs and run settings for the active model build.
- Raises:
ValueError – If the requested output is unsupported or a declared variable role refers to an absent variable.