Postproduction architecture

The postproduction system is built on a YAML-driven workflow engine (pycwb.post_production.workflow) that chains actions as a directed acyclic graph (DAG). Actions are Python functions registered with the action_spec() decorator (pycwb.post_production.action_spec), declaring their inputs, outputs, and arguments.

Key modules:

Module

Purpose

pycwb.modules.postprocess.far

FAR vs. ranking statistic computation

pycwb.modules.postprocess.train_xgboost

XGBoost classifier training

pycwb.modules.postprocess.evaluate

Model scoring, FAR evaluation, efficiency

pycwb.modules.postprocess.selection

Trigger/job selection and train/FAR splitting

pycwb.modules.postprocess.matching

Trigger-to-injection matching

pycwb.modules.postprocess.zero_lag

Zero-lag significance analysis

pycwb.modules.postprocess.report_builder

Multi-tab HTML report generation

pycwb.modules.postprocess.ranked_events

Shared Pandas ranking and projected Parquet row recovery

For a user-facing workflow, see Post-Production Workflow Guide. Exact action interfaces are in Post-Production Action Reference and persistence rules are in Catalog format and provenance.

Shared event ranking and catalog reads

Report listings, background loudest-trigger tables and event follow-up selection reuse postprocess.ranked_events. The shared layer handles ranking, physical row offsets and selected payload recovery. Each consumer retains its scientific eligibility rules, provenance validation and output format.

ranked_rows uses Pandas top-N partitioning before sorting the small candidate set. Its explicit tie policies preserve existing behavior:

  • first retains first-occurrence ties in streamed loudest-trigger tables.

  • legacy uses the report’s fast partition path for unique finite winners, falling back to its historical full sort when ties or special values require it.

  • identity retains the best occurrence of each supplied identity and breaks score ties lexically. A validation callback sees the complete input before ranking discards any rows.

iter_parquet_batches supplies physical row offsets alongside projected Arrow batches. read_parquet_rows loads requested columns from winning row groups, returning the requested order and repeated positions. Its optional compatibility mode converts complete original batches before selecting rows when nullable or nested values affect Pandas dtypes. take_rows provides the same row recovery primitive for the follow-up selector’s provenance-aware scan.

Parquet and CSV follow-up selection both rank bounded batches through the shared Pandas identity policy. For Parquet, the selector projects the columns needed for ranking, cuts and validation, retains the running winners, and recovers their full payloads after selection. Source content hashes, physical provenance checks and original payload conversion remain part of the action. There is no separate selection backend or database connection. The selector still accepts and validates the deprecated duckdb_memory_limit argument for compatibility with existing YAML, but the value has no effect on selection.

The report retains its full ranking vector for FAR calculations and streams figure coordinates. No additional YAML options are needed for this shared layer.

Action resume contracts

action_spec preserves the callable’s signature and adds default-on resume for file-producing actions. Ordinary outputs declarations supply the default essential output inventory. resume_outputs can instead be a list of parameter names or a callable receiving resolved arguments, including defaults, and returning file paths relative to work_dir. Include every required product, including companions with derived filenames. Return an empty list or use resume_outputs=False when output completeness cannot be checked.

Named parameters, declared inputs/outputs, and options listed in resume_args form the configuration fingerprint. resume_args is needed for meaningful options consumed through **kwargs; unrelated accumulated workflow context is excluded. Declared inputs and named file parameters are fingerprinted by file identity. resume_inputs overrides the declared input inventory for structured inputs or implicit dependencies such as external job manifests; named file parameters remain tracked. Optional missing files are recorded as missing so their later appearance also invalidates reuse.

The completion record is JSON data, published atomically after success. Results must consist of built-in scalars, dictionaries, lists and tuples; tuple and dictionary-key types survive restoration. An unsupported return value disables reuse for the entire result, without changing normal action behavior. Before rerunning, the old record is invalidated. Changed inputs during execution also prevent recording success. Existing action arguments and returned keys remain unchanged. See Post-Production Workflow Guide for switch precedence and examples.