pycif.plugins.obsoperators.standard — API reference#
Configuration reference: standard plugin
- pycif.plugins.obsoperators.standard.check.check_inputs(inputs, mode)[source]#
Check the consistency of inputs given to the observation operator.
Validates that mode is one of the accepted values and that inputs carries the attributes required by that mode.
- Parameters:
inputs – control or observation vector passed to the operator; must expose at least
xfor'fwd'mode, and bothxanddxfor'tl'mode.mode (str) – requested execution mode — one of
'fwd','tl', or'adj'.
- Returns:
Trueif all checks pass.- Return type:
bool
- Raises:
Exception – if mode is not one of
'fwd','tl', or'adj'.Exception – if mode is
'tl'and inputs does not expose bothxanddx.
- pycif.plugins.obsoperators.standard.flushrun.flushrun(self, workdir, rundir, mode, transform_pipe, full_flush=True)[source]#
Remove intermediate files produced by transforms that are no longer needed.
Iterates over every transform in transform_pipe and calls each transform’s own
flushrunmethod to clean up its output files in rundir. In adjoint mode, when the operator is not running in approximate mode, the forward reference directory of each transform is also flushed — provided it lies inside workdir, to avoid accidentally deleting files outside the managed tree.- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
workdir (str) – root working directory; used to check that
transf.adj_refdiris a safe path to flush.rundir (str) – the run sub-directory whose files should be cleaned.
mode (str) – execution mode — one of
'fwd','tl', or'adj'; controls whetheradj_refdirof each transform is also flushed.transform_pipe – the
Transformobject holding all transforms for this run.full_flush (bool, optional) – forwarded to each transform’s own
flushrun; ifFalseonly a partial cleanup is performed (exact behaviour is transform-specific). Defaults toTrue.
- Raises:
PluginError – caught internally and logged as a warning if a transform’s
flushrunraises it; execution continues with the remaining transforms.
- pycif.plugins.obsoperators.standard.ndarray_wrapper.forward(self, x: ndarray, reload_results=False) ndarray[source]#
- pycif.plugins.obsoperators.standard.ndarray_wrapper.tangent_linear(self, x: ndarray, reload_results=False) ndarray[source]#
- pycif.plugins.obsoperators.standard.ndarray_wrapper.adjoint(self, _x: ndarray, dy: ndarray, reload_results=False) ndarray[source]#
- pycif.plugins.obsoperators.standard.obsoper.obsoper(self, controlvect, obsvect, mode, run_id=0, datei=datetime.datetime(1979, 1, 1, 0, 0), datef=datetime.datetime(2100, 1, 1, 0, 0), workdir='./', reload_results=False, check_transforms=False, ignore_exceptions=False, force_fetch_results=False, **kwargs)[source]#
Run the standard observation operator in forward, tangent-linear or adjoint mode.
Orchestrates the full observation-operator pipeline:
Creates a per-run sub-directory
obsoperator/<mode>_<run_id>/under workdir.If
reload_resultsis set, attempts to recover cached outputs from a previous run before computing from scratch.Dispatches to
obsoper_serial()orobsoper_parallel()depending on whetherself.parallelis configured.Dumps the resulting observation or control vector to disk for later use.
- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
controlvect (ControlVect) – control-vector object. Must carry
x(anddxfor'tl'mode); receivesdxin'adj'mode.obsvect (ObsVect) – observation-vector object. Receives
ysim(anddyfor'tl'mode); providesdyin'adj'mode.mode (str) – execution mode — one of
'fwd','tl', or'adj'.run_id (int | str, optional) – identifier for the current run; used to name the sub-directory. Defaults to
0.datei (datetime.datetime, optional) – start date of the simulation window. Defaults to
datetime.datetime(1979, 1, 1).datef (datetime.datetime, optional) – end date of the simulation window. Defaults to
datetime.datetime(2100, 1, 1).workdir (str, optional) – parent directory in which the run sub-directory is created. Defaults to
"./"reload_results (bool, optional) – if
True, attempt to recover pre-computed outputs from the run sub-directory before running the full pipeline. Defaults toFalse.check_transforms (bool, optional) – if
True, run each transform in both directions and verify the adjoint / TL identity; disables result reloading. Defaults toFalse.ignore_exceptions (bool, optional) – if
True, non-fatal transform errors are logged and swallowed rather than re-raised. Defaults toFalse.force_fetch_results (bool, optional) – if
Trueand cached outputs cannot be found, raiseIOErrorinstead of computing. Defaults toFalse.**kwargs – extra keyword arguments (ignored).
- Returns:
in
'fwd'and'tl'modes — the updated obsvect withysim(anddy) populated.ControlVect: in
'adj'mode — the updated controlvect withdxpopulated.- Return type:
- Raises:
TypeError – if run_id is neither an
intnor astr.IOError – if
force_fetch_resultsisTrueand cached outputs cannot be loaded.
- pycif.plugins.obsoperators.standard.parallel.run_pycif_in_subprocess(python_path, yaml_path)[source]#
Run a pyCIF configuration file in a blocking subprocess.
Launches
python_path -m pycif yaml_path, redirecting stdout tosubprocess_stdout.logand stderr tosubprocess_stderr.login the same directory as yaml_path.- Parameters:
python_path (str) – path to the Python interpreter (e.g.
self.platform.python).yaml_path (str) – absolute path to the pyCIF YAML configuration file to execute.
- Raises:
RuntimeError – if the subprocess exits with a non-zero return code.
- pycif.plugins.obsoperators.standard.parallel.obsoper_parallel(self, controlvect, obsvect, rundir, mode, workdir, check_transforms, ignore_exceptions)[source]#
Run the observation operator in parallel over independent time segments.
Splits the simulation window
[self.datei, self.datef]into segments of lengthself.parallel.segmentswith optional boundary overlapself.parallel.overlap, then runs each segment independently — either as subprocesses (self.parallel.subprocess = True) or as HPC jobs via theplatformplugin.Each segment is configured via a freshly dumped YAML file that restricts the
approx_operatorwindow to its date range, then executed withrun_pycif_in_subprocess()orself.platform.submit_job.After all segments finish, their outputs are reassembled:
'tl'mode —obsvect.ysimandobsvect.dyare set to the element-wise sums over all segment observation vectors.'adj'mode —controlvect.dxis set to the element-wise sum over all segment adjoint sensitivities;controlvect.xandcontrolvect.xbare reset to their pre-run values.
- Parameters:
self (ObsOperator) – the obs-operator plugin instance. Must have
self.parallel(withsegments,overlap,subprocessattributes),self.datei,self.datef,self.ref_fwd_dir, andself.platformset.controlvect (ControlVect) – control-vector object.
obsvect (ObsVect) – observation-vector object.
rundir (str) – the run sub-directory for this operator call.
mode (str) – execution mode —
'tl'or'adj'. (Forward mode is always dispatched to serial execution.)workdir (str) – parent working directory.
check_transforms (bool) – if
True, validate each segment’s transform adjoint / TL identity.ignore_exceptions (bool) – if
True, non-fatal transform errors inside segments are swallowed.
- Raises:
RuntimeError – if a subprocess-based segment exits with a non-zero return code (propagated from
run_pycif_in_subprocess()).
- pycif.plugins.obsoperators.standard.serial.obsoper_serial(self, controlvect, obsvect, rundir, mode, workdir, check_transforms, ignore_exceptions)[source]#
Run the observation operator sequentially over all transforms and time steps.
Handles bookkeeping common to every serial execution:
'fwd'/'tl'— zerosobsvect.ysimandobsvect.dy, then dumps the control vector torundir/controlvect.pickle.'adj'— initialisescontrolvect.dx = 0and enables forward-run chaining for multi-step models.
Dispatches to the Dask execution path (
init_dask()) whenself.use_daskis set, otherwise runs the standard transform loop viado_transforms().After the run, calls
flushrun()to clean up intermediate files whenself.autoflushis set (and the operator is not running in parallel mode).Stores rundir as
self.ref_fwd_dirafter a forward run so that the subsequent adjoint can locate the forward outputs.- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
controlvect (ControlVect) – control-vector object.
obsvect (ObsVect) – observation-vector object.
rundir (str) – the run sub-directory for this operator call.
mode (str) – execution mode — one of
'fwd','tl', or'adj'.workdir (str) – parent working directory; forwarded to
flushrun().check_transforms (bool) – if
True, validate each transform’s adjoint / TL identity.ignore_exceptions (bool) – if
True, non-fatal transform errors are swallowed rather than re-raised.
- pycif.plugins.obsoperators.standard.transforms.batch_computation.batch_computation(self, all_transforms, mapper, dask=False)[source]#
Adapt the transform pipeline for batch computation of Monte-Carlo samples.
Traverses the forward period order in reverse and calls
Transform.mapper2batch()on each forward-direction transform to extend its input/output mapper so that a batch of nsamples perturbations can be computed simultaneously.- Parameters:
self (ObsOperator) – the obs-operator plugin instance. Must have
self.batch_computation.nsamples,self.batch_computation.dir_samples, andself.batch_computation.file_samplesset.all_transforms – the
Transformobject holding all transforms.mapper (dict) – the pipeline mapper dictionary mapping transform IDs to their input/output/precursor/successor metadata; updated in-place.
dask (bool) – whether to use dask for parallel computation.
- pycif.plugins.obsoperators.standard.transforms.do_transforms.input_output_msg(trid_list: List[Tuple[str, str]]) str[source]#
Format a list of tracer IDs as a human-readable multi-line string.
Groups parameters by component and produces output of the form:
- component1: param1, param2 - component2: param1
- Parameters:
trid_list (list[tuple[str, str]]) – list of
(component, parameter)tracer-ID pairs to format.- Returns:
multi-line string, one component per line, suitable for logging.
- Return type:
str
- pycif.plugins.obsoperators.standard.transforms.do_transforms.do_transforms(self, transform_pipe, mapper, controlvect, obsvect, mode, rundir, workdir, do_simu=True, onlyinit=False, check_transforms=False, adj_test_threshold=10, save_debug=False, ignore_exceptions=False, ref_fwd_dir='', dump_metadata_only=False, **kwargs)[source]#
Execute the full ordered transform pipeline for a single operator call.
Iterates over all
(date, transform, direction)entries inself.period_order_fwd(orself.period_order_adjin adjoint mode) and applies each transform in sequence. Key responsibilities:Datastore initialisation — builds a nested
transform_pipe.datastore[transform][date]dictionary on the first call to track intermediate inputs/outputs shared between transforms.Restart support — reads
rundir/finished_transforms.txtto skip transforms already completed in a previous interrupted run whenself.autorestartis enabled.Input/output routing — uses
fetch_inputs_outputs()andaggregate_inout()to gather inputs from precursor datastores, anddeaggregate_inout()to redistribute outputs to successor datastores.Approximate operator — when
self.approx_operatoris set (parallel mode), transforms outside the segment window execute in dry-run (onlyinit) mode only.Memory monitoring — tracks peak memory with
tracemallocwhenself.monitor_memoryis enabled.Memory cleaning — releases unused datastore entries after each transform when
self.clean_memoryis enabled.Autokill / restart — kills the job and resubmits if the elapsed wall-clock time exceeds
self.autokill_time.Adjoint / TL test — when
check_transformsisTrue, saves copies of each transform’s in/outputs and callscheck_adjtltest()at the end of the adjoint pass.
- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
transform_pipe – the
Transformpipeline object populated byinit_transform().mapper (dict) – the pipeline mapper dictionary.
controlvect (ControlVect) – control-vector object.
obsvect (ObsVect) – observation-vector object.
mode (str) – execution mode — one of
'fwd','tl', or'adj'.rundir (str) – the run sub-directory for this operator call.
workdir (str) – parent working directory.
do_simu (bool, optional) – if
False, skip actual transform execution (used internally for dry runs). Defaults toTrue.onlyinit (bool, optional) – if
True, run all transforms in initialisation / dry-run mode only. Defaults toFalse.check_transforms (bool, optional) – if
True, validate each transform’s adjoint / TL identity. Defaults toFalse.adj_test_threshold (float, optional) – relative tolerance used by the adjoint test. Defaults to
10.save_debug (bool, optional) – if
True, dump the inputs and outputs of each transform to rundir for post-run inspection. Defaults toFalse.ignore_exceptions (bool, optional) – if
True, non-fatal errors inside individual transforms are swallowed and execution continues. Defaults toFalse.ref_fwd_dir (str, optional) – path to the reference forward run directory, forwarded to each transform for adjoint input location. Defaults to
"".dump_metadata_only (bool, optional) – passed through to
dump_debug()whensave_debugisTrue. IfTrue, writes lightweight plain-text metadata summaries (dimensions, min/max, NaN presence) instead of full NetCDF/datastore files. Greatly reduces wall-time and disk overhead while still allowing data-flow inspection. Defaults toFalse.**kwargs – additional keyword arguments (ignored).
- pycif.plugins.obsoperators.standard.transforms.dump_read_inout.dump_read_inout(self, all_transforms, backup_comps, mapper)[source]#
Insert dump and load transforms for explicit input/output file I/O.
Scans all transforms for inputs flagged with
force_dumpand outputs flagged withforce_loadout, then inserts extra transforms into the pipeline accordingly:force_dump on an input: inserts a
dump2inputstransform immediately before the flagged transform to write that input to disk so it can be inspected or reused.force_loadout on an output: inserts a
loadfromoutputstransform immediately after the flagged transform to reload that output from disk (useful for transforms whose results must survive across restarts).
Before scanning,
propagate_parameters()is called to ensureforce_loadflags have been propagated through the pipeline.- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
all_transforms – the
Transformobject holding all transforms; modified in-place.backup_comps (dict) – backed-up component definitions forwarded to
add_default().mapper (dict) – the pipeline mapper dictionary; updated in-place to include entries for the newly inserted transforms.
- pycif.plugins.obsoperators.standard.transforms.init_control_transformations.init_control_transformations(self, all_transforms, controlvect, backup_comps, mapper)[source]#
Initialize transforms on the control-vector side.
Reads
controlvect.transform_pipeand inserts each of its transforms before the first element ofself.mainpipein all_transforms, preserving the user-defined order.Also loops over all components/tracers of the
datavectand, for those that specify theunit_conversionargument, automatically inserts a unit_conversion transform.- Parameters:
self (ObsOperator) – the obs-operator plugin instance; uses
self.mainpipeto determine the insertion point.all_transforms – the
Transformobject holding all transforms; modified in-place.controlvect (ControlVect) – control-vector object; its
transform_pipeis read to determine which transforms to insert.backup_comps (dict) – backed-up component definitions forwarded to
add_default().mapper (dict) – the pipeline mapper dictionary; updated in-place.
- pycif.plugins.obsoperators.standard.transforms.init_mainpipe.init_mainpipe(self, all_transforms, backup_comps, mapper)[source]#
Initialize the core of the transform pipeline.
Reads
self.transform_pipe(transforms defined directly on the observation operator in the YAML) and inserts each of its transforms before the first element already present inself.mainpipe. If notransform_pipeis defined andself.ignore_modelisFalse, a defaultrun_modeltransform is added automatically.Warning
If
transform_pipeis specified in the observation operator, only the explicitly listed transforms are used — the CTM model is not added automatically. To run the model on top of custom transforms, includerun_modelexplicitly in the list. For most applications it is preferable to define extra transforms in thecontrolvectorobsvecttransform_pipeinstead.- Parameters:
self (ObsOperator) – the obs-operator plugin instance. On return,
self.mainpipeis updated with the IDs of the newly inserted transforms.all_transforms – the
Transformobject holding all transforms; modified in-place.backup_comps (dict) – backed-up component definitions forwarded to
add_default().mapper (dict) – the pipeline mapper dictionary; updated in-place.
- pycif.plugins.obsoperators.standard.transforms.init_obsvect_transformations.init_obsvect_transformations(self, all_transforms, obsvect, backup_comps, mapper)[source]#
Initialize transforms on the observation-vector side.
Appends a
toobsvecttransform to the pipeline for every observed species (component/tracer pair whereparam.isobsisTrue). Forsatellitescomponents, a satellites transform is inserted immediately before the correspondingtoobsvectstep.Then reads
obsvect.transform_pipeand prepends each of its transforms before all other transforms in all_transforms, preserving the user-defined order.- Parameters:
self (ObsOperator) – the obs-operator plugin instance. On return,
self.mainpipeis populated with the IDs of the newly insertedtoobsvect(andsatellites) transforms.all_transforms – the
Transformobject holding all transforms; modified in-place.obsvect (ObsVect) – observation-vector object; its
transform_pipeanddatavectare read to determine which transforms to insert.backup_comps (dict) – backed-up component definitions forwarded to
add_default().mapper (dict) – the pipeline mapper dictionary; updated in-place.
- pycif.plugins.obsoperators.standard.transforms.period_pipe.period_pipe(self, all_transforms, mapper)[source]#
Arrange all transforms into ordered forward and adjoint execution pipes.
Determines the chronologically correct execution order for every
(transform, sub-simulation date)pair by:Propagating sub-simulation periods from each transform to its precursors and successors via
default_subsimus().Building a dependency graph and walking it in forward order with
fwd_adj_pipe()(mode='forward').Walking the same graph in reverse order (
mode='adjoint').
Each returned pipe is a list of
(date, transform_id, direction)tuples, wheredirectionis either'forward'or'adjoint'and controls whether a transform runs in its normal or dry-run mode.- Parameters:
self (ObsOperator) – the obs-operator plugin instance.
all_transforms – the
Transformobject holding all initialized transforms.mapper (dict) – the pipeline mapper dictionary mapping transform IDs to their sub-simulation, input/output and precursor/successor metadata.
- Returns:
(pipe_fwd, pipe_adj)where each element is a list of(datetime.datetime, str, str)tuples giving the execution order for forward and adjoint runs respectively.- Return type:
tuple[list, list]
- pycif.plugins.obsoperators.standard.transforms.utils.add_default.add_default(self, transforms, yml_dict, position='last', index=0, init=False, mapper={}, transform_type='state', backup_comps={}, ref_transform='', precursor=None, successor=None, transform_id=None, do_pipe_entry=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.add_default.init_pipe_entry(self, all_transforms, backup_comps, mapper, transform)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.add_default.update_successors_precursors(new_id, precursors2add, successor2add, transf_mapper_loc, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.add_default.generate_internal_pipe(new_id, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.aggreg_deaggreg_inout.aggregate_inout(transform, ddi, tmp_inputs, tmp_outputs, transform_mode, transform_onlyinit, mapper, check_transforms=False)[source]#
Aggregate inputs and outputs from precursors and successors respectively.
There can be only one precursor per trid, with the possibility of having several sub-dates. By construction, it is not possible to have several precursors for a given trid to avoid ambiguity. This could become possible in the future, but it would require further complexity in identifying datastores (i.e., including precursor and successor in dictionaries, at the cost of reduced readability).
Outputs can have several successors for a given trid. This implies that adjoint sensitivities must be properly propagated backwards.
- Parameters:
transform (str) – The name of the transform currently being processed
ddi (datetime.datetime) – The period being processed
tmp_inputs (dict) – _description_
tmp_outputs (dict) – _description_
transform_mode (str) – _description_
transform_onlyinit (bool) – _description_
mapper (dict) – _description_
check_transforms (bool, optional) – _description_. Defaults to False.
- Raises:
Exception – _description_
TypeError – _description_
- Returns:
_description_
- Return type:
_type_
- pycif.plugins.obsoperators.standard.transforms.utils.aggreg_deaggreg_inout.deaggregate_inout(transform, transform_mode, transform_onlyinit, ddi, tmp_datastore, mapper, check_transforms=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.check_adjtltest.check_adjtltest(self, period_order, mapper, transform_pipe)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.check_datavect.check_datavect(self, all_transforms, backup_comps, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.clean_memory.clean_memory(self, transform_pipe, mapper, period_order, ddi, transform, direction, mode, only_init)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.connect_pipes.connect_pipes(all_transforms, mapper, transform)[source]#
Connect transforms based on their inputs and outputs
- pycif.plugins.obsoperators.standard.transforms.utils.connect_pipes.prune_dead_branches(all_transforms, mapper, skip_transform)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.default_subsimus.default_subsimus(all_transforms, mapper)[source]#
Initialize sub-simulations for each transform for which sub-simulations are not already defined. By default, the sub-simulations of a given transform are deduced from the shape of the “input_dates” of each component/tracer in the outputs.
- pycif.plugins.obsoperators.standard.transforms.utils.dump_debug.dump_debug(transform, transf_mapper, tmp_datastore, runsubdir, ddi, entry='outputs', transform_onlyinit=False, dump_metadata_only=False)[source]#
Dump inputs or outputs of a transform step for post-run inspection.
For each tracer ID (
trid) intmp_datastore[entry], writes debug files under:<runsubdir>/../transform_debug/<transform>/<ddi>/<component>/<parameter>/
Two modes are supported:
- Full dump (
dump_metadata_only=False) Writes the complete datastore to disk as NetCDF files (
xr.Dataset) or pyCIF datastore files (pd.DataFrame). One file is produced per tracer ID and date. This mode is accurate but slow and disk-intensive.- Metadata-only dump (
dump_metadata_only=True) Writes lightweight plain-text files instead of full data files. Dramatically reduces wall-time overhead and disk usage while still capturing enough information to trace data flow and detect anomalies.
For
xr.Datasetvalues — records the dimension names and sizes, min/max values, and NaN presence for thespecvariable (andincrwhen it exists in the dataset).For
pd.DataFramevalues — records the row count and, for each of themaindata,spec, andincrcolumns that are present, the min/max values and NaN presence.
- Parameters:
transform (str) – name of the transform being debugged.
transf_mapper (dict) – mapper entry for the transform (not directly used here; kept for API consistency).
tmp_datastore (dict) – the datastore for the current transform step, keyed by
"inputs"and"outputs".runsubdir (str) – the per-period run sub-directory. Debug files are written to
<runsubdir>/../transform_debug/….ddi (datetime.datetime) – the current simulation date (used both for directory naming and for per-date filename formatting).
entry (str, optional) – which side of the datastore to dump —
"inputs"or"outputs". Defaults to"outputs".transform_onlyinit (bool, optional) – when
True, the transform ran in dry-run / init-only mode. Currently unused inside this function but kept for API consistency with the call sites indo_transforms(). Defaults toFalse.dump_metadata_only (bool, optional) – when
True, write lightweight metadata text files instead of full NetCDF/datastore files. Defaults toFalse.
- Raises:
TypeError – if a datastore entry is neither an
xr.Datasetnor adictofxr.Dataset/pd.DataFrame.
- Full dump (
- pycif.plugins.obsoperators.standard.transforms.utils.dump_transform_description.dump_transform_description(self, all_transforms, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.fetch_inoutputs.fetch_inputs_outputs(transform, ddi, transform_pipe, tmp_datastore, subsimus, successors, precursors, transf_mapper, mapper, return_links=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.fwd_pipe.fwd_adj_pipe(self, all_transforms, mapper, mode='forward')[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.init_default_transformations.init_default_transformations(self, all_transforms, backup_comps, mapper, transform, do_pipe_entry=False, trid_to_check=None)[source]#
Initialize default transformations based on compatibility of input/output formats of successive transforms.
- pycif.plugins.obsoperators.standard.transforms.utils.init_entry.init_entry(self, all_transforms, backup_comps, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.init_regrid.init_regrid(self, trid, tmp_dict, trid_dict, precursor_id, transform, param, all_transforms, mapper, backup_comps, precursors, return_last=True, do_pipe_entry=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.init_reindex.init_reindex(self, trid, tmp_dict, trid_dict, precursor_id, transform, param, all_transforms, mapper, backup_comps, precursors, do_pipe_entry=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.init_sparse.init_sparse(self, trid, precursor_dict, ref_dict, tr, transform, param, all_transforms, mapper, backup_comps, precursors, do_pipe_entry=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.initiate_default_attributes.initiate_default_attributes(all_transforms, mapper, transform_id)[source]#
Initiate default values.
- pycif.plugins.obsoperators.standard.transforms.utils.precursors_successors.add_precursors_successors(self, all_transforms, transforms_ids, mapper, pipe_links, pipe_subend, transf, simu, mode='adjoint', fetch_precursors=True)[source]#
Find the precursors/successors in backward and forward mode
- Parameters:
self
all_transforms
transforms_ids
mapper
pipe_links
transf
simu
mode
precursors
fetch_precursors
- Returns:
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.propagate_attributes(self, all_transforms, mapper, transform_id, backup_comps=None, next_did_nothing=False, previous_did_nothing=False, only_backwards=False, only_forwards=False, parent_transform=None, parent_trids=None)[source]#
Propagate attributes backward and forward when initializing a new transform.
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.propagate_attribute(self, all_transforms, mapper, attributes, transform_id, only_backwards=False, only_forwards=False, next_did_nothing=False, previous_did_nothing=False, backup_comps=None, parent_transform=None, parent_trids=None, force_propagate=False, deal_boolean=None)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.propagate_backwards(self, all_transforms, mapper, attributes, transform_id, next_did_nothing=False, backup_comps=None, parent_transform=None, parent_trids=None, force_propagate=False, deal_boolean=None)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.propagate_forwards(self, all_transforms, mapper, attributes, transform_id, previous_did_nothing=False, backup_comps=None, parent_transform=None, parent_trids=None, force_propagate=False, deal_boolean=None)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.skip_attributes(list_attributes, list_initialized=None, force_propagate=False, deal_boolean=None)[source]#
Check compatibility of attributes and determines whether to skip
- Parameters:
list_attributes (_type_) – _description_
list_initialized (_type_) – _description_
force_propagate (bool, optional) – _description_. Defaults to False.
- Returns:
List of attributes are not compatible
List of attributes to propagate
True if all Nones
- Return type:
bool, list, bool
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_attributes.compare_attribute(attr1, attr2, deal_boolean=None, return_boolean_value=False)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_dates.propagate_dates(all_transforms, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.propagate_parameters.propagate_parameters(all_transforms, mapper)[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.dask.individual_transform.do_individual_transform(*args, **kwargs)[source]#
Runs a single transform, batching its log output.
Thin wrapper around _do_individual_transform: dask worker threads run many transforms concurrently, and without batching their debug/info calls interleave line-by-line with other threads’ output. See pycif.utils.check.batched_logging.
- pycif.plugins.obsoperators.standard.transforms.utils.dask.individual_transform.input_output_msg(trid_list: List[Tuple[str, str]]) str[source]#
- pycif.plugins.obsoperators.standard.transforms.utils.dask.init_dask.plot_task_graph(tasks, dependencies, rundir)[source]#
Render the resolved transform DAG as an interactive HTML graph.
dask’s own visualize() rasterizes through Graphviz, which becomes unreadable past a few dozen nodes. pyvis (vis.js) instead produces a pannable/zoomable/draggable HTML page with hover tooltips, which stays usable with the hundreds of transform tasks a typical CIF run builds.
networkx and pyvis are optional (
pip install networkx pyvisor thegraphextra): imported lazily here so their absence never breaks a run that doesn’t request plotting.- Parameters:
tasks (dict) – mapping of task name -> delayed object, as built by init_dask’s main loop.
dependencies (dict) – mapping of task name -> list of precursor task names, as built by init_dask before the main loop.
rundir (str) – directory to write
dask_graph.htmlinto.