Commit 45df3b3
committed
feat!: Rust-backed openjd.model._v1, openjd.expr, openjd.sessions._v1 via PyO3
Introduces a Rust-backed implementation of the OpenJD data model,
expression language, and session runtime types, distributed alongside
the existing pure-Python reference. Built as a single PyO3 extension
module — `openjd._openjd_rs` — that wraps three Rust crates from the
`openjd-rs` workspace (`openjd-expr`, `openjd-model`, `openjd-sessions`)
and is consumed via three Python import roots:
* `openjd.expr` — Rust-only. No pure-Python predecessor.
* `openjd.model._v1` — Rust-backed v1, parallel to the existing
Pydantic-based `openjd.model` (a.k.a. `openjd.model.v0`).
* `openjd.sessions._v1` — Rust-backed v1, with the Python wrapper
module living in the sibling `openjd-sessions-for-python` repository.
The Python distribution still ships under the single PyPI package name
`openjd-model`; no consumer of the v0 API is forced to migrate. v1 is
opt-in via the explicit `_v1` import path.
```
rust-bindings/ (PyO3 crate, name=openjd-python, lib=_openjd_rs)
├── src/lib.rs #[pymodule] _openjd_rs registration
├── src/expr/ ──→ openjd.expr wraps openjd-rs::openjd-expr
├── src/model/ ──→ openjd.model._v1 wraps openjd-rs::openjd-model
├── src/sessions/ ──→ openjd.sessions._v1 (re-exported from
│ openjd-sessions-for-python,
│ wraps openjd-rs::openjd-sessions)
└── src/bin/stub_gen.rs pyo3-stub-gen entry point
```
* The crate is named `openjd-python`; the cdylib is `_openjd_rs`.
* Every `#[pyclass]` has a `Py`-prefixed Rust identifier (e.g. `PyJob`)
and is registered under its public Python name via
`#[pyo3(name = "...")]`.
* Exception classes raised through `create_exception!` are registered
via a `register_renamed_exception` helper so `__name__` /
`__module__` / `__qualname__` resolve to canonical user-facing
values across pickle, repr, and tracebacks.
* Build infrastructure: an in-tree PEP 517 backend (`_build_backend.py`),
a `maturin develop` wrapper that injects a VCS-derived version
(`scripts/maturin_build.py`), and a `pyo3-stub-gen` driver
(`scripts/generate_stubs.sh`) that emits `src/openjd/_openjd_rs.pyi`.
* Python: 3.9+ via `abi3-py39` (set in `rust-bindings/Cargo.toml` and
enforced by `pyproject.toml` `requires-python`).
23 public symbols re-exported from `src/openjd/expr/__init__.py`:
* Entry points — `evaluate_expression`, `parse_expression`,
`escape_format_string`.
* Value/type system — `ExprType`, `TypeCode`, `ExprValue`, `RangeExpr`,
`IntRange`, `FormatString`, `SymbolTable`, `ParsedExpression`,
`EvalResult`.
* Profile types — `ExprProfile`, `ExprRevision`, `ExprExtension`,
`HostContext`. The previous `FunctionLibrary` /
`FunctionSignature` / `get_default_library` surface was replaced
by these profile types; the full migration story is documented in
`specs/python-expr-interface.md`.
* Path types — `PathFormat`, `PathMappingRule`.
* Errors — `ExpressionError`, `ExpressionTypeError`, `RangeExprError`,
`FormatStringValidationError`.
* Constants — `DEFAULT_MEMORY_LIMIT`, `DEFAULT_OPERATION_LIMIT`.
`ParsedExpression.evaluate(...)` returns an `ExprValue` (the lighter
form, no metric tracking); `ParsedExpression.evaluate_with_metrics(...)`
returns an `EvalResult` value-class bundling `value` / `peak_memory` /
`operation_count`, mirroring the upstream Rust `EvalResult` struct.
Top-level entry points: `decode_job_template{,_str}`,
`decode_environment_template{,_str}`, `decode_template`, `create_job`,
`preprocess_job_parameters`, `merge_job_parameter_definitions`,
`evaluate_let_bindings`. Output and type pyclasses are organised under
three submodules:
* `.template` — template-time pyclasses returned by `decode_*_template`:
`JobTemplate`, `EnvironmentTemplate`, `StepTemplate`, the typed
`Job*ParameterDefinition` / `*TaskParameterDefinition` /
`*UserInterface` variants, and the template-time structural types
(`TemplateAction`, `TemplateEmbeddedFile`, `TemplateHostRequirements`,
…) plus their unprefixed short-alias re-exports.
* `.job` — job-time pyclasses returned by `create_job`: `Job`, `Step`,
`StepScript`, `StepActions`, `Action`, `Environment`,
`EmbeddedFile`, `JobParameter`, `HostRequirements`,
`AmountRequirement`, `AttributeRequirement`, `StepParameterSpace`,
`StepParameterSpaceIterator`, `StepDependencyGraph`, and the typed
task-parameter pyclasses.
* `.types` — cross-cutting types: `JobParameterType`,
`TaskParameterType`, `DocumentType`, `ModelProfile`,
`ModelExtension`, `SpecificationRevision`, `CallerLimits`,
`ValidationContext`.
* `.errors` — `DecodeValidationError`, `ModelValidationError`,
`UnsupportedSchema`.
Binding source lives in this repository under
`rust-bindings/src/sessions/`, but the user-facing wrapper module
ships from a parallel branch in the
`openjd-sessions-for-python` repository. The two repos must change
together when the binding API changes.
* `specs/python-expr-interface.md`,
`specs/python-model-interface.md`,
`specs/python-sessions-interface.md` are the contract for each
binding component — the equivalent of `public-api.md` in
`openjd-rs`.
* `test/openjd/expr/` and `test/openjd/model_v1/` carry component
test suites covering parse/evaluate, pickle, equality / hashability,
parity probes against the v0 reference, fuzz tests, and end-to-end
decode/create paths. Total: 5121 passing tests, 24 platform-skipped
(Windows-only), 0 xfailed, coverage 94.30%.
* `skills/eval-bindings/SKILL.md` defines the report-driven
evaluation workflow used to identify and resolve binding/reference
parity gaps.
* `reports/` holds quality-evaluation reports for each component; the
current state of each report has every numbered recommendation
resolved.
`rust-bindings/Cargo.toml` consumes the three Rust workspace crates
from crates.io at pinned versions (`openjd-expr = "0.1.1"`,
`openjd-model = "0.2.0"`, `openjd-sessions = "0.2.2"`). A
commented-out `[patch.crates-io]` block at the bottom of that file
documents how to redirect to a sibling `~/openjd-rs` checkout when
iterating across both repos. CI does not require a sibling clone.
* `cargo build --all-targets` clean
* `cargo clippy --all-targets -- -D warnings` clean (hard gate in CI)
* `cargo test --doc` clean
* `hatch run lint` clean (ruff + black + mypy on every supported
Python version)
* `hatch run test` 5121 passed, 24 skipped (Windows-only), 0 xfailed,
coverage 94.30% — the project-wide 94% coverage gate is enforced
by the test runner.
* The `.github/workflows/rust_quality.yml` workflow runs
build / clippy / test / doctest on `{ubuntu, windows, macos}`.
BREAKING CHANGE: This commit introduces a new `_v1` API surface
behind explicit `openjd.model._v1` / `openjd.sessions._v1` imports
and a brand-new `openjd.expr` import root. The existing v0
(`openjd.model` / `openjd.model.v0`, Pydantic-backed) public API is
untouched and remains the default. v1 itself contains many breaking
changes relative to v0 — `JobParameter.type` returns the
`JobParameterType` enum rather than a string, `Action.timeout`
returns `Optional[FormatString]` rather than `Optional[str]`,
`PathFormat` and `JobParameterType` no longer carry a `str` mixin,
and the function-library surface has been replaced by `ExprProfile`
/ `HostContext`, among others. Each divergence is documented in the
relevant `specs/python-*-interface.md` file. The `openjd.sessions._v1`
surface is published from the sibling
`openjd-sessions-for-python` repository.
Signed-off-by: Mark <399551+mwiebe@users.noreply.github.com>1 parent 94129dc commit 45df3b3
186 files changed
Lines changed: 42864 additions & 213 deletions
File tree
- .github
- scripts
- workflows
- reports
- rust-bindings
- src
- bin
- expr
- model
- sessions
- scripts
- skills/eval-bindings
- specs
- src/openjd
- expr
- model
- _format_strings
- _v1
- v2023_09
- v0
- v2023_09
- test/openjd
- expr
- model_v0
- _internal
- benchmark
- format_strings
- v2023_09
- model_v1
- _internal
- benchmark
- format_strings
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | | - | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
12 | 21 | | |
| |||
0 commit comments