erlab.interactive.imagetool.provenanceΒΆ
Public ImageTool provenance API.
Functions
|
Compose streamlined display provenance from a live source spec. |
|
Compose canonical full provenance from parent and local provenance. |
|
Decode values produced by |
|
Return a direct input expression for simple replay seeds. |
|
Encode non-JSON provenance values into a JSON-safe representation. |
|
Build structured file-backed provenance for runtime reload. |
|
Build a spec that starts from the parent's full current data. |
|
Return |
Return the structured operation represented by a console call, if known. |
|
|
Return chained expression code for structured operations. |
Parse one serialized operation payload. |
|
|
Parse a serialized provenance payload into a validated spec instance. |
|
Build a spec that starts from the parent's restored public data. |
|
Replace the generic |
|
Return |
|
Replay structured file provenance without executing generated Python. |
|
|
|
Execute script provenance from already resolved input arrays. |
|
|
|
Build script provenance from code, structured steps, and named inputs. |
|
Return all live manager dependency references stored in script inputs. |
Return whether script provenance is self-contained enough to execute. |
|
|
Build a spec that starts from the parent's public selection model. |
|
Parse |
Return whether generated replay code refers to the generic |
Classes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Normalized runtime call observed by the ImageTool manager console. |
|
Declarative matcher for direct console-to-operation mappings. |
|
|
|
One user-visible step in a provenance derivation listing. |
|
|
|
Serializable selection of one displayable array from a loaded file object. |
|
Serializable file origin used by saved file-backed provenance. |
|
Serializable call information used to reload file-backed provenance. |
|
|
|
ImageTool selection state stored for manager child refreshes. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Structured transformation stage replayed against one parent data array. |
|
|
|
|
|
|
|
Named input captured by script or multi-tool provenance. |
|
Live manager dependency captured by a script input. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Base class for typed operations stored in |
|
Saved provenance recipe for ImageTool data. |
|
- class erlab.interactive.imagetool.provenance.AffineCoordOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['affine_coord']ΒΆ
- coord_name: strΒΆ
- scale: floatΒΆ
- offset: floatΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.AssignAttrsOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['assign_attrs']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- attrs: ProvenanceMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.AssignCoord1DOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['assign_coord_1d']ΒΆ
- coord_name: ProvenanceHashableΒΆ
- dim: ProvenanceHashableΒΆ
- values: typing.AnyΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.AssignCoordsOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['assign_coords']ΒΆ
- coord_name: strΒΆ
- values: typing.AnyΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.AssignScalarCoordOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['assign_scalar_coord']ΒΆ
- coord_name: ProvenanceHashableΒΆ
- value: typing.AnyΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.AverageOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['average']ΒΆ
- dims: ProvenanceHashableTupleΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.CoarsenOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['coarsen']ΒΆ
- dim: ProvenanceIntMappingΒΆ
- boundary: strΒΆ
- side: strΒΆ
- coord_func: strΒΆ
- reducer: strΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ConsoleCall(*, func=None, dataarray_method=None, accessor_path=(), args=(), kwargs=None, display_code, has_extra_tracked_inputs, receiver_data=None)[source]ΒΆ
Bases:
objectNormalized runtime call observed by the ImageTool manager console.
Console proxies create this descriptor after unwrapping provenance-aware tool handles to raw
xarray.DataArrayarguments. Operation classes inspect the invoked callable, DataArray method/accessor context, and raw arguments to decide whether the call can be represented as structured provenance.- accessor_pathΒΆ
- argsΒΆ
- dataarray_methodΒΆ
- display_codeΒΆ
- funcΒΆ
- has_extra_tracked_inputsΒΆ
- kwargsΒΆ
- receiver_dataΒΆ
- class erlab.interactive.imagetool.provenance.ConsoleOperationPattern(*, target=None, dataarray_method=None, accessor_path=(), fields=(), field_aliases=None, kwargs_field=None, mapping_kwarg=None, defaults=None, ignored_defaults=None)[source]ΒΆ
Bases:
objectDeclarative matcher for direct console-to-operation mappings.
Use this for calls where public arguments map directly onto operation model fields. Store module-function targets as strings so importing this module does not resolve lazy ERLab analysis modules; the matcher compares those strings with the callable that the console actually invoked. More complex calls should implement
ToolProvenanceOperation.from_console_call().- accessor_pathΒΆ
- dataarray_methodΒΆ
- defaultsΒΆ
- field_aliasesΒΆ
- fieldsΒΆ
- ignored_defaultsΒΆ
- kwargs_fieldΒΆ
- mapping_kwargsΒΆ
- targetsΒΆ
- class erlab.interactive.imagetool.provenance.CorrectWithEdgeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['correct_with_edge']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- edge_fit: typing.AnyΒΆ
- shift_coords: boolΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.DerivationEntry(label, code, copyable=False)[source]ΒΆ
Bases:
objectOne user-visible step in a provenance derivation listing.
- class erlab.interactive.imagetool.provenance.DivideByCoordOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['divide_by_coord']ΒΆ
- coord_name: ProvenanceHashableΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.FileDataSelection(**data)[source]ΒΆ
Bases:
BaseModelSerializable selection of one displayable array from a loaded file object.
New provenance stores stable Dataset variable names and DataTree data paths instead of the positional parsed-array index used by older workspaces.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- kind: typing.Literal['dataarray', 'dataset_variable', 'datatree_path', 'parsed_index']ΒΆ
- value: typing.AnyΒΆ
- class erlab.interactive.imagetool.provenance.FileLoadSource(**data)[source]ΒΆ
Bases:
BaseModelSerializable file origin used by saved file-backed provenance.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- path: strΒΆ
- loader_label: strΒΆ
- loader_text: strΒΆ
- kwargs_text: strΒΆ
- replay_call: FileReplayCall | NoneΒΆ
- load_code: str | NoneΒΆ
- class erlab.interactive.imagetool.provenance.FileReplayCall(**data)[source]ΒΆ
Bases:
BaseModelSerializable call information used to reload file-backed provenance.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- kind: typing.Literal['erlab_loader', 'callable']ΒΆ
- target: strΒΆ
- kwargs: dict[str, typing.Any]ΒΆ
- selection: FileDataSelectionΒΆ
- cast_float64: boolΒΆ
- class erlab.interactive.imagetool.provenance.GaussianFilterOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['gaussian_filter']ΒΆ
- sigma: ProvenanceFloatMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ImageToolSelectionSourceBinding(**data)[source]ΒΆ
Bases:
BaseModelImageTool selection state stored for manager child refreshes.
Stores the parent dimension indices selected in an ImageTool plot. When a child refreshes after parent coordinates change,
materialize()rebuildsqseloriseloperations from the current parent data so the child follows the same cursor or bin position instead of old coordinate labels.- schema_version: typing.Literal[1]ΒΆ
- kind: typing.Literal['imagetool_selection']ΒΆ
- selection_mode: typing.Literal['qsel', 'isel']ΒΆ
- selection_indexers: ProvenanceMappingΒΆ
- selection_binned_dims: ProvenanceHashableTupleΒΆ
- crop_sel_indexers: ProvenanceMappingΒΆ
- crop_isel_indexers: ProvenanceMappingΒΆ
- transpose_dims: NullableProvenanceHashableTupleΒΆ
- squeeze: boolΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.InterpolationOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['interpolate']ΒΆ
- dim: ProvenanceHashableΒΆ
- values: typing.AnyΒΆ
- method: typing.Literal['linear', 'nearest']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.IselOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['isel']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- kwargs: ProvenanceMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.LeadingEdgeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['leading_edge']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- fraction: floatΒΆ
- dim: ProvenanceHashableΒΆ
- direction: typing.Literal['positive', 'negative']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.MaskWithPolygonOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['mask_with_polygon']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- vertices: typing.AnyΒΆ
- dims: ProvenanceHashableTupleΒΆ
- invert: boolΒΆ
- drop: boolΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.NormalizeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['normalize']ΒΆ
- dims: ProvenanceHashableTupleΒΆ
- mode: typing.Literal['area', 'minmax', 'min', 'min_area']ΒΆ
- denominator_rtol: floatΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.QSelAggregationOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['qsel_aggregate']ΒΆ
- dims: ProvenanceHashableTupleΒΆ
- func: typing.Literal['mean', 'min', 'max', 'sum']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.QSelOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['qsel']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- kwargs: ProvenanceMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.RenameDimsCoordsOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['rename_dims_coords']ΒΆ
- mapping: ProvenanceHashableMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.RenameOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['rename']ΒΆ
- name: strΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ReplayStage(**data)[source]ΒΆ
Bases:
BaseModelStructured transformation stage replayed against one parent data array.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- source_kind: typing.Literal['full_data', 'public_data', 'selection']ΒΆ
- operations: tuple[pydantic.SerializeAsAny[ToolProvenanceOperation], ...]ΒΆ
- class erlab.interactive.imagetool.provenance.RestoreNonuniformDimsOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['restore_nonuniform_dims']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.RotateOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['rotate']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- angle: floatΒΆ
- axes: ProvenanceHashablePairΒΆ
- center: tuple[float, float]ΒΆ
- reshape: boolΒΆ
- order: intΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ScriptCodeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['script_code']ΒΆ
- label: strΒΆ
- code: str | NoneΒΆ
- copyable: boolΒΆ
- live_applicable: typing.ClassVar[bool] = FalseΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ScriptInput(**data)[source]ΒΆ
Bases:
BaseModelNamed input captured by script or multi-tool provenance.
nameis the immutable replay variable,labelis the historical display label,node_uidandnode_snapshot_tokenidentify the live manager input that was used, andprovenance_specstores the historical replay source used when that live input is unavailable.- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- name: strΒΆ
- label: strΒΆ
- node_uid: str | NoneΒΆ
- node_snapshot_token: str | NoneΒΆ
- provenance_spec: dict[str, typing.Any] | NoneΒΆ
- class erlab.interactive.imagetool.provenance.ScriptInputDependencyRef(name, label, node_uid, node_snapshot_token=None)[source]ΒΆ
Bases:
objectLive manager dependency captured by a script input.
- class erlab.interactive.imagetool.provenance.SelOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['sel']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- kwargs: ProvenanceMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SelectCoordOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['select_coord']ΒΆ
- coord_name: ProvenanceHashableΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SliceAlongPathOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['slice_along_path']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- vertices: ProvenanceFloatSequenceMappingΒΆ
- step_size: floatΒΆ
- dim_name: strΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SortCoordOrderOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['sort_coord_order']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SqueezeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['squeeze']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SwapDimsOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['swap_dims']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- mapping: ProvenanceHashableMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SymmetrizeNfoldOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['symmetrize_nfold']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- fold: intΒΆ
- axes: ProvenanceHashablePairΒΆ
- center: typing.AnyΒΆ
- reshape: boolΒΆ
- order: intΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.SymmetrizeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['symmetrize']ΒΆ
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = (<erlab.interactive.imagetool._provenance_framework.ConsoleOperationPattern object>,)ΒΆ
- dim: ProvenanceHashableΒΆ
- center: floatΒΆ
- subtract: boolΒΆ
- mode: typing.Literal['full', 'valid']ΒΆ
- part: typing.Literal['both', 'below', 'above']ΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ThinOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['thin']ΒΆ
- mode: typing.Literal['global', 'per_dim']ΒΆ
- factor: int | NoneΒΆ
- factors: ProvenanceIntMappingΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class erlab.interactive.imagetool.provenance.ToolProvenanceOperation(**data)[source]ΒΆ
Bases:
BaseModelBase class for typed operations stored in
ToolProvenanceSpec.New operations should keep runtime fields in their decoded Python form, prefer the annotated provenance field aliases in this module for lossless JSON serialization, implement
apply()to replay the transformation, implementexpression_code()to emit the public Python expression for the same transformation, and implementderivation_label()to describe the step in manager UI.Operation instances store the exact arguments used by live refresh, replay graph execution, copied code, and derivation display. If a public console call maps exactly to an operation, expose it with
console_patternsorfrom_console_call(); ambiguous calls should returnNoneso script provenance records the original code instead.- apply(data, *, parent_data)[source]ΒΆ
Apply this operation to the current derived array.
Subclasses that participate in live refresh or executable provenance replay should reimplement this method. The implementation must be deterministic for the operationβs stored model fields and must not mutate
dataorparent_datain place.- Parameters:
- Returns:
xarray.DataArrayβ Array after this operation has been applied.- Return type:
Notes
Operations that only emit generated code should set
live_applicable = Falseand raise from this method.
- console_patterns: typing.ClassVar[tuple[ConsoleOperationPattern, ...]] = ()ΒΆ
- derivation_entry()[source]ΒΆ
Return the user-visible derivation entry for this operation.
Structured transform subclasses should normally reimplement
derivation_label()andexpression_code()instead of overriding this method. Override this method only for operations whose display entry cannot be represented as a label plus parameterized operation code, such as stored free-form script code.- Returns:
DerivationEntryβ Label, replay code, and copyability flag shown in derivation UI and used by legacy derivation-code paths.- Return type:
Notes
The base implementation keeps the legacy
derivedreplay contract while letting concrete operations emit expression code for any input variable.Use
DerivationEntry(..., code=None)instead when the step should remain visible in the derivation list but code generation should stop and returnNone.
- derivation_label()[source]ΒΆ
Return the derivation-list label for this operation.
Subclasses should reimplement this for every structured operation that uses the base
derivation_entry()implementation.
- expression_code(input_name, *, source_name=None)[source]ΒΆ
Return a Python expression applying this operation to an input name.
Subclasses should reimplement this for every structured operation that can be represented as ordinary user-facing Python code. The emitted expression should be complete, public-API-based, and free of assignment to hardcoded temporary names.
- Parameters:
input_name (
str) β Python expression or identifier for the array produced by the previous replay step. Use this exact value as the operation receiver/input instead of assuming a variable name such asderived.source_name (
str|None, default:None) β Python expression or identifier for the original public input array for the enclosing replay sequence. Operations that need parent/source context, such as coordinate-order restoration, should use this name for that context. Operations that only transforminput_namemay ignore it.
- Returns:
strβ Python expression that evaluates to the transformed DataArray.- Return type:
- classmethod from_console_call(call)[source]ΒΆ
Build an operation from a normalized manager-console call.
Subclasses should reimplement this when a console call maps cleanly to the operation but cannot be expressed with declarative
console_patternsalone. ReturnNonefor unsupported, ambiguous, or lossy calls so the original console code remains recorded as script provenance.- Parameters:
call (
ConsoleCall) β Normalized descriptor for the function, method, or accessor call observed by the ImageTool manager console, including unwrapped arguments, keyword arguments, display code, and receiver data when available.- Returns:
ToolProvenanceOperationorNoneβ Operation instance when the call is exactly representable by this operation class; otherwiseNone.- Return type:
ToolProvenanceOperation | None
- live_applicable: typing.ClassVar[bool] = TrueΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- replay_code(input_name, *, output_name=None, source_name=None)[source]ΒΆ
Return replay code for this operation with caller-selected names.
This method usually should not be reimplemented by subclasses. Implement
expression_code()instead so replay graph emission, dialog copy code, and derivation entries all share the same operation expression.- Parameters:
input_name (
str) β Python expression or identifier for the array produced by the previous replay step.output_name (
str|None, default:None) β Variable name to assign the transformed value to. IfNone, return only the expression fromexpression_code().source_name (
str|None, default:None) β Python expression or identifier for the original public input array for the enclosing replay sequence. Passed through toexpression_code().
- Returns:
strβ Either an assignment statement whenoutput_nameis provided, or a bare expression when it isNone.- Return type:
- class erlab.interactive.imagetool.provenance.ToolProvenanceSpec(**data)[source]ΒΆ
Bases:
BaseModelSaved provenance recipe for ImageTool data.
Live child-tool refresh uses single-parent specs from
full_data(),public_data(), orselection(). Durable reload and copied code usefileandscriptspecs, including multi-inputscript_inputsfor console or UI actions that combine several ImageTools. Deserialize saved payloads withparse_tool_provenance_spec().A spec records exact operation arguments for live refresh, runtime replay, copied code, and derivation display. Manager children opened from ImageTool cursor or bin selections should keep
ImageToolSelectionSourceBindingas their refresh state; that binding builds a spec before refresh so edited parent coordinates are used.- append_display_operation(operation)[source]ΒΆ
Append a live display operation without making a final name stale.
- append_operations(*operations)[source]ΒΆ
Append operation instances to the spec.
Runtime code should pass operation instances from this module. Saved mappings should be normalized with
parse_tool_provenance_spec()before calling this method.
- append_replacement_operations(*operations)[source]ΒΆ
Replace a final rename, if present, then append new operation instances.
- append_replay_stage(source)[source]ΒΆ
Append one live-source transformation stage to file provenance.
- display_code(*, parent_data=None)[source]ΒΆ
Return streamlined replay code for UI and clipboard actions.
The display path preserves exact live-source behavior while omitting user-facing no-op and normalization steps from copied provenance code.
- display_entries(*, parent_data=None)[source]ΒΆ
Return streamlined derivation entries for UI and copy-code output.
The display path hides internal ImageTool normalization steps while keeping the recorded replay steps available through
derivation_entries().
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- to_replay_spec()[source]ΒΆ
Return the durable replay form for this spec.
Replay specs are the canonical, composable form used for derivation metadata, copied code, workspace save/load, and manager dependency status. Structured file provenance remains structured so runtime reloads can replay typed operations without
exec. Live ImageTool refresh uses the original single-parent spec viarequire_live_source_spec().
- schema_version: typing.Literal[2]ΒΆ
- kind: typing.Literal['full_data', 'public_data', 'selection', 'script', 'file']ΒΆ
- start_label: str | NoneΒΆ
- seed_code: str | NoneΒΆ
- active_name: str | NoneΒΆ
- operations: tuple[pydantic.SerializeAsAny[ToolProvenanceOperation], ...]ΒΆ
- file_load_source: FileLoadSource | NoneΒΆ
- replay_stages: tuple[ReplayStage, ...]ΒΆ
- script_inputs: tuple[ScriptInput, ...]ΒΆ
- class erlab.interactive.imagetool.provenance.TransposeOperation(**data)[source]ΒΆ
Bases:
ToolProvenanceOperation- op: typing.Literal['transpose']ΒΆ
- dims: NullableProvenanceHashableTupleΒΆ
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': True}ΒΆ
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- erlab.interactive.imagetool.provenance.compose_display_provenance(parent, source_spec, *, parent_data=None)[source]ΒΆ
Compose streamlined display provenance from a live source spec.
- erlab.interactive.imagetool.provenance.compose_full_provenance(parent, local)[source]ΒΆ
Compose canonical full provenance from parent and local provenance.
parentrepresents the replay provenance for the current input data.localrepresents the additional steps performed by the current node. File-backed parents remain structured when composed with live-source specs so runtime reloads can avoid executing generated Python.
- erlab.interactive.imagetool.provenance.decode_provenance_value(value)[source]ΒΆ
Decode values produced by
encode_provenance_value().
- erlab.interactive.imagetool.provenance.direct_replay_input_name(value)[source]ΒΆ
Return a direct input expression for simple replay seeds.
This only applies to non-default single-line seeds such as watched variables. Generic replay aliases like
derived = datacontinue to usederivedso existing non-watched code generation remains stable.
- erlab.interactive.imagetool.provenance.encode_provenance_value(value)[source]ΒΆ
Encode non-JSON provenance values into a JSON-safe representation.
- erlab.interactive.imagetool.provenance.file_load(*, start_label, seed_code, file_load_source, active_name='derived', replay_stages=())[source]ΒΆ
Build structured file-backed provenance for runtime reload.
- erlab.interactive.imagetool.provenance.full_data(*operations)[source]ΒΆ
Build a spec that starts from the parentβs full current data.
- erlab.interactive.imagetool.provenance.mark_promoted_1d_source(data)[source]ΒΆ
Return
datatagged as originating from a promoted 1D source.
- erlab.interactive.imagetool.provenance.operation_from_console_call(call)[source]ΒΆ
Return the structured operation represented by a console call, if known.
- erlab.interactive.imagetool.provenance.operations_expression_code(operations, input_name, *, source_name=None)[source]ΒΆ
Return chained expression code for structured operations.
source_nameis the public/source array name passed to operations that need context beyond the transformed input, such as coordinate-order restoration.
- erlab.interactive.imagetool.provenance.parse_tool_provenance_operation(value)[source]ΒΆ
Parse one serialized operation payload.
This is the deserialize boundary for saved JSON. Runtime call sites should build concrete operation instances directly instead of passing raw mappings around.
- erlab.interactive.imagetool.provenance.parse_tool_provenance_spec(value)[source]ΒΆ
Parse a serialized provenance payload into a validated spec instance.
This is the deserialize boundary for saved tool and workspace metadata. Runtime authoring code should pass
ToolProvenanceSpecinstances directly.
- erlab.interactive.imagetool.provenance.public_data(*operations)[source]ΒΆ
Build a spec that starts from the parentβs restored public data.
- erlab.interactive.imagetool.provenance.rebase_default_replay_input(code, input_name)[source]ΒΆ
Replace the generic
datareplay input in generated code.Manager clipboard actions use this when a concrete source is known, such as a watched variable, a load snippet target, or a user-provided variable name.
- erlab.interactive.imagetool.provenance.rebase_script_input_node_uids(value, uid_map)[source]ΒΆ
Return
valuewith script input node UIDs remapped recursively.
- erlab.interactive.imagetool.provenance.replay_file_provenance(spec, *, cache=None)[source]ΒΆ
Replay structured file provenance without executing generated Python.
- erlab.interactive.imagetool.provenance.replay_script_provenance(spec, inputs)[source]ΒΆ
Execute script provenance from already resolved input arrays.
The caller is responsible for trust and input resolution. This function only validates the provenance shape, compiles it through the replay graph, and returns the replayed
xarray.DataArray.
- erlab.interactive.imagetool.provenance.script(*operations, start_label, seed_code=None, active_name=None, file_load_source=None, script_inputs=())[source]ΒΆ
Build script provenance from code, structured steps, and named inputs.
- erlab.interactive.imagetool.provenance.script_input_dependency_refs(value)[source]ΒΆ
Return all live manager dependency references stored in script inputs.
- erlab.interactive.imagetool.provenance.script_provenance_replayable(spec)[source]ΒΆ
Return whether script provenance is self-contained enough to execute.
This checks the saved code and structured operations. It does not mean live manager inputs are present; callers still need to resolve
script_inputs.
- erlab.interactive.imagetool.provenance.selection(*operations)[source]ΒΆ
Build a spec that starts from the parentβs public selection model.