ofplang validate
A validator for Object-flow Programming Language v0 — a YAML-based dataflow workflow IR with linear Object tracking. The language is defined in the ofplang/spec repository.
The validator checks that a document is well-formed portable v0: structure and types, the feature model, linear Object tracking, structured nodes, contracts, and scheduling policies. It reports findings as stable error codes rather than free text, so results are easy to consume in tests and tooling.
Install
pip install ofplang-validate
Requires Python 3.10+. The only runtime dependency is PyYAML. For development, install editable with the test extra from a clone:
pip install -e ".[test]"
Command line
ofp-validate <file>... # or: python -m ofplang.validate <file>...
ofp-validate --mode extension-tolerant doc.yaml
ofp-validate --format json doc.yaml
Options: --mode {strict,extension-tolerant}, --format {text,json},
-q/--quiet, --no-color.
Exit codes: 0 all valid, 1 validation errors found, 2 usage/input error.
$ ofp-validate workflow.yaml
workflow.yaml:7:15: error unknown_type processes.main.inputs.x.type unknown type in 'Foo'
1 error in 1 of 1 file
Diagnostics carry a file:line:col source position (an imported fragment's own
file when the problem is inside an $import); --format json includes
file/line/col fields.
This tool is also intended to be exposed as the validate subcommand of the
umbrella ofp CLI (a separate repository in the ofplang organization).
Library
from ofplang.validate import validate
result = validate("workflow.yaml", mode="strict")
if not result.ok:
for d in result.diagnostics:
print(d.code, d.path, d.message)
validate(source, *, mode="strict") returns a ValidationResult with .ok and
.diagnostics (each a Diagnostic(code, message, path, file, line, col)). The
validator collects all independent findings rather than stopping at the first;
only a YAML parse or $import resolution failure is terminal.
source is a path or an already-loaded document (a mapping), so a caller that
builds one in memory — a generator, a notebook, a tool that rewrote a document
before running it — can validate exactly what it holds:
result = validate(document) # the same checks, the same codes
An in-memory document must already be import-expanded (there is no base directory
to resolve a relative $import against — call expand() on the file first), and it
cannot contain a value v0 has no spelling for, such as a datetime; either raises
ValueError. Its diagnostics carry no file:line:col, only path, and no
duplicate_key can arise for it: a mapping holds one value per key.
Expanded document
$import (spec §3) is structural inclusion resolved before any other checks,
so the document that gets validated is the fully expanded one. To obtain that
expanded document — e.g. to hand a downstream tool the exact form it should
schedule or run, instead of re-reading the unexpanded file — use:
from ofplang.validate import validate, expand
# structural expansion only (no validation); raises YamlError on import failure
doc = expand("workflow.yaml")
# validate and get the expanded document in one pass
result = validate("workflow.yaml", mode="extension-tolerant", expand=True)
if result.ok:
run_it(result.document) # exactly what was validated
expand(source, *, base_dir=None) returns the plain-Python document
yaml.safe_load would yield for the resolved tree (fidelity is exact, including
non-string scalar tags). base_dir overrides where the root's relative imports
resolve. validate(..., expand=True) sets ValidationResult.document to that
same value whenever load + $import resolution succeeds (otherwise None).
The package lives under the ofplang PEP 420 namespace (ofplang.validate),
shared across the organization's tools.
Scope
Covers graph-time validation of portable v0. Runtime failures, and run/data-phase
preflight checks, are out of scope (spec §6.2, §25). Two modes are supported:
strict (portable v0) and extension-tolerant (accepts x- extension keys).
Tests
The behavior is pinned by a spec-derived conformance suite that matches on error codes (see tests/conformance/README.md).
pytest # run everything
OFPLANG_STRICT_TESTS=1 pytest # full contract, no pending escapes
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ofplang_validate-0.1.5.tar.gz.
File metadata
- Download URL: ofplang_validate-0.1.5.tar.gz
- Upload date:
- Size: 150.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aadc932f21469a1b0cfb341e331f21a0f6e3f4cfe56308e1c8dd9dcaffb7d6f
|
|
| MD5 |
6abfae36c7395d6e3e39172a2e78d854
|
|
| BLAKE2b-256 |
f195d4c95fed374918584c51e90aa05f941b871680d9a68e8f4c86981721e496
|
Provenance
The following attestation bundles were made for ofplang_validate-0.1.5.tar.gz:
Publisher:
publish.yml on ofplang/validate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ofplang_validate-0.1.5.tar.gz -
Subject digest:
2aadc932f21469a1b0cfb341e331f21a0f6e3f4cfe56308e1c8dd9dcaffb7d6f - Sigstore transparency entry: 2518003097
- Sigstore integration time:
-
Permalink:
ofplang/validate@1287734c3c06b9153a1c13e380897a1fec2bd4b1 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/ofplang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1287734c3c06b9153a1c13e380897a1fec2bd4b1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ofplang_validate-0.1.5-py3-none-any.whl.
File metadata
- Download URL: ofplang_validate-0.1.5-py3-none-any.whl
- Upload date:
- Size: 97.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
665d4b4966383524828b8302a9671fdbdab764ef4cdface28f6e458b07e84737
|
|
| MD5 |
f39100db04880e3e9f5883b89fe36dbd
|
|
| BLAKE2b-256 |
d0a2b8c7515a1475d09aa626ab8a9e2fe02451576d8dd060036e72190b4e3215
|
Provenance
The following attestation bundles were made for ofplang_validate-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on ofplang/validate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ofplang_validate-0.1.5-py3-none-any.whl -
Subject digest:
665d4b4966383524828b8302a9671fdbdab764ef4cdface28f6e458b07e84737 - Sigstore transparency entry: 2518003237
- Sigstore integration time:
-
Permalink:
ofplang/validate@1287734c3c06b9153a1c13e380897a1fec2bd4b1 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/ofplang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1287734c3c06b9153a1c13e380897a1fec2bd4b1 -
Trigger Event:
push
-
Statement type: