ump_workflow
package ump-workflow
UMP workflow bundles: save a fitted analyst workflow as a hashed folder of data and source, and rerun it on new data of the same necessary shape (score by default, a labelled refit or the Tier D summary otherwise).
Never pickles. Depends only on ump-spec, finprint, numpy and pandas.
Read the ump-workflow guide first for the main entry points.
Modules
Section titled “Modules”| Module | What it holds |
|---|---|
ump_workflow.answers | Answers from per-draw values: point, interval and the estimand, with horizons recomputed from the data. |
ump_workflow.bundle | The bundle format (ump.workflow_bundle/0.1): a folder of data and source, never pickles. |
ump_workflow.cli | ump-workflow: inspect, check, run and serve a bundle from the terminal. |
ump_workflow.env | The environment pin: which versions a bundle was saved with, and how the running ones compare. |
ump_workflow.errors | The codes this runtime raises or notes. All are registered in ump_spec’s error_codes.yaml (source packages/ump-workflow); ump-spec’s tests/test_registry_additions.py scans this package for drift. |
ump_workflow.loader | Open a bundle in the load order S4 fixes, then run it on new data (S2: score by default). |
ump_workflow.profile | The pandas side of ump_spec.rules.check_input: build the FrameProfile it reads, infer a contract from a training frame, and apply an InputReport to a frame (moved here from babelfin’s _contract.py so the runtime checks contracts without babelfin). |
ump_workflow.save | save_workflow: fit the analyst’s module on training data and write a bundle. |
ump_workflow.serve | Serve one workflow bundle as an app speaking UMP’s engine adapter contract (feature workflow-bundles, T7, S6). |
ump_workflow.share | Share a bundle through ump-core (S6): pure helpers, no network code. |
ump_workflow.state | Fitted state as JSON plus plain numeric arrays, and the save-time round trip (S7). |
Re-exports
Section titled “Re-exports”Documented on the page of the module that defines them.
| Name | Kind | Summary |
|---|---|---|
BUNDLE_FORMAT | constant | |
CODES | constant | |
ApprovalTrust | class | What an approval vouches for: hashes (code and prep-step sha256) or an empty set with a reason code (WORKFLOW_SHARE_NOT_APPROVED, WORKFLOW_SELF_APPROVED, WORKFLOW_SHARE_MISMATCH) and detail. |
BundleData | class | A verified bundle, parsed. Nothing here has run the bundle’s code. |
EnvReport | class | drift: one row per differing package (package, pinned, running, level); notes in the input-note shape; score_ok false on any major drift. |
OpenBundle | class | A verified bundle. .module exists only once the code is trusted. |
RunResult | class | route: where the rerun went (score, refit, not_available); source: where the answers came from (score, refit or summary); answers: {name: {value, lo, hi, level, draws_summary, estimand, proposed}}; rows: rows used after the contract’s exclusions; history_end: the last period of the input that was run (the bundle’s training end when the answers are the summary’s). |
WorkflowError | class | A refusal with a registered code. str() is the code and the plain-words message. |
build_summary | function | A Tier D model_manifest doc of the fit-time answers that have a summary_ref. |
bundle_files | function | {relpath: bytes} of every file in a verified bundle, workflow.json and SHA256SUMS included. Each file is read again and checked against the hashes the bundle was verified with (a file changed since the read is BUNDLE_TAMPERED). |
bundle_manifest_refs | function | The payload_refs map of a shared bundle: workflow_bundle (sha256: of workflow.json, the bundle’s id) and file:<relpath> = sha256:<hex> for every file. |
clean_frame | function | A new frame with the excluded rows removed (rows at a new category level, matched by level hash, and rows with no time or category value), drop_columns dropped and the coerce casts applied. The input is not changed. Missing values in variables are left for the caller’s stated policy. |
compare_env | function | Compare a bundle’s pin with the running versions (running overrides the lookup, for a known set). |
contract_from_frame | function | Infer a contract from a training frame: every non-time, non-target, non-category column is a required variable with the frame’s dtype (missing: forbid unless it already has nulls). categories maps a column to its policy (a list means fixed); when None, string columns are fixed categories. Fixed categories get their level set (hash and count). freq is inferred from the time column when not given. |
env_pin | function | Versions to pin for a bundle whose code is source. |
is_principal_id | function | True for a principal id such as user:maya.chen (the rule save_workflow enforces on author); a bare name or an email is not one. |
level_hash | function | sha256 (hex) of one level’s canonical JSON string. |
level_set | function | sha256 (hex) of the canonical JSON of the sorted unique non-null values as strings, their count, and the sorted sha256 of each level. Never the values. |
load_module | function | Execute source as a fresh module called name (registered in sys.modules while it runs, as dataclasses and pickle-free introspection need). No file is imported and no bytecode is written. |
manifest_doc | function | The draft Tier A model_manifest doc of a shared bundle: name, client, engine ump-workflow, family, estimands, summaries and dependence from summary.json, input_contract from contract.json, payload_refs from bundle_manifest_refs and the share note. |
materialize | function | Rebuild a bundle folder at dest (which must not exist) from {relpath: bytes} and verify it through read_bundle; with refs (a payload_refs map) the rebuilt bundle must also match them exactly. A wrong or missing blob refuses (BUNDLE_TAMPERED) and an unsafe path (absolute, .., a backslash) is BUNDLE_INVALID; on any refusal nothing is left behind. |
module_imports | function | Sorted third-party top-level package names source imports anywhere (relative and stdlib excluded). |
open_bundle | function | Verify and parse a bundle (no code runs). trust_code=True trusts its module for this object only; trust_steps=True trusts its prep recipe’s named-step code (.step_code) for this object only. trusted_hashes (sha256 hex, as share.trusted_hashes_from_approval returns) trusts the module and each named step whose hash it names, for this object only: never written to the machine’s trust store. |
profile_frame | function | What check_input reads about df: no row values, only dtypes, counts and hashes. |
read_bundle | function | Verify every file’s hash, then parse (data only: no code runs). Only SHA256SUMS and workflow.json are read before the file lists are compared, so an unlisted file is refused unread. |
round_trip | function | Save model as it would be written, rebuild it with from_state and compare answer(model) with answer(rebuilt) (allclose, rtol 1e-9, atol 0). Returns the plain (meta, arrays) to write. |
save_workflow | function | Fit, check and write a workflow bundle at path; returns the bundle folder. |
summary_answers | function | Answers read from the Tier D summary, and the questions it holds no number for. Each answer carries its own question’s estimand (fit_estimand, else its template), never the summary’s per-metric one. |
to_arrays | function | Each value through numpy.asarray; refuses object or structured dtypes and names that are not plain. |
training_stats | function | workflow.json’s training block: rows and time range of the raw input data, history_end (the last period, which a score must follow on from) and the min and max of every numeric contract variable on the prepped frame (channel_ranges, read by the out-of-support check). |
trusted_hashes_from_approval | function | The code and prep-step hashes a core envelope vouches for, checked against bundle. Trust is given only when the envelope is a model_manifest of engine ump-workflow in state validated (its head version is the validated one), approved_by is present and is none of the owner, the submitter and the bundle’s author, and the doc’s payload_refs and recorded code_sha256 / step_sha256 match the bundle exactly. Otherwise an empty set with a reason code. |
write_bundle | function | Write a bundle folder at path (which must not exist). Everything is written to a temporary sibling and renamed into place, so a refusal leaves nothing behind. workflow holds name, version, seed, params, training and optionally author, created_at, tier, dependence, notes; the rest is filled here. code is the module’s bytes as the caller ran them (read once); without it code_path is read here. code_path always gives the file name. |
Constants
Section titled “Constants”| Name | Type | Value | Description |
|---|---|---|---|
__version__ | '0.1.0' |