Skip to content

Commit f1fc113

Browse files
authored
Merge branch 'mainline' into fix/template-scope-let-path-format
2 parents 0787cb2 + 3057874 commit f1fc113

12 files changed

Lines changed: 352 additions & 187 deletions

‎CHANGELOG.md‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
## Unreleased
1+
## 0.11.8 (2026-09-03)
22

3-
### BREAKING CHANGES
4-
* Step-level `let` bindings are evaluated once in template scope and are no longer merged into the step's script, so the `Job`
5-
returned by `create_job` no longer carries their values. A caller that runs a job whose steps declare a template-scope `let`
6-
referenced from the step's script must switch to `create_job_with_symbol_tables` and forward the step's `step_symbol_tables`
7-
entry to the session; otherwise the action fails at run time with `Undefined variable`. Callers that only inspect the `Job`
8-
at creation time — `StepDependencyGraph`, `StepParameterSpaceIterator`, `hostRequirements` — are unaffected.
3+
4+
### Features
5+
* A chunked step parameter space can now be walked at a granularity you choose, instead of only at the chunk size the template declared. Pass `chunks_task_count_override` when constructing `StepParameterSpaceIterator`; it overrides the `defaultTaskCount` of a `CHUNK[INT]` parameter and turns adaptive chunking off. Pass `1` to iterate individual tasks. It is ignored when the space has no chunked parameter, though a non-positive value is still rejected. (#344)
96

107
### Bug Fixes
11-
* Evaluate step-level let bindings in template scope
12-
* Stop merging step-level let into the script
8+
* A float range element keeps the number of decimal places it was written with, so `2.50` in a range list renders as `2.50` rather than `2.5`. Redundant leading zeros are still dropped, and a signed zero renders as the author wrote it. This is the scale-preserving behavior required by Template Schemas §7.5. (#345)
9+
* A `let` binding name longer than 512 characters is now rejected instead of accepted, per Template Schemas §3.6.1. The error names the offending binding with a 32-character prefix and its true length, so it is diagnosable when a template declares many bindings. (#348)
1310

1411

1512
## 0.11.7 (2026-09-01)

‎Cargo.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎THIRD-PARTY-LICENSES.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,9 +2534,9 @@ limitations under the License.
25342534
** itoa; version 1.0.18 -- https://crates.io/crates/itoa
25352535
** libc; version 0.2.189 -- https://crates.io/crates/libc
25362536
** manyhow-macros; version 0.11.4 -- https://crates.io/crates/manyhow-macros
2537-
** openjd-expr; version 0.5.0 -- https://crates.io/crates/openjd-expr
2538-
** openjd-model; version 0.5.4 -- https://crates.io/crates/openjd-model
2539-
** openjd-sessions; version 0.5.4 -- https://crates.io/crates/openjd-sessions
2537+
** openjd-expr; version 0.6.0 -- https://crates.io/crates/openjd-expr
2538+
** openjd-model; version 0.6.0 -- https://crates.io/crates/openjd-model
2539+
** openjd-sessions; version 0.5.5 -- https://crates.io/crates/openjd-sessions
25402540
** pin-project-lite; version 0.2.17 -- https://crates.io/crates/pin-project-lite
25412541
** portable-atomic; version 1.15.0 -- https://crates.io/crates/portable-atomic
25422542
** proc-macro2; version 1.0.107 -- https://crates.io/crates/proc-macro2

‎rust-bindings/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ name = "_openjd_rs"
1212
crate-type = ["cdylib", "rlib"]
1313

1414
[dependencies]
15-
openjd-expr = "0.5.0"
16-
openjd-model = "0.5.4"
17-
openjd-sessions = "0.5.4"
15+
openjd-expr = "0.6.0"
16+
openjd-model = "0.6.0"
17+
openjd-sessions = "0.5.5"
1818
tokio = { version = "1", features = ["rt-multi-thread"] }
1919
uuid = { version = "1", features = ["v4"] }
2020
serde_json = "1"

‎rust-bindings/src/model/job.rs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,15 +899,25 @@ fn task_param_def_from_dict(
899899
// List of values — coerce each to the variant's element type.
900900
let mut items: Vec<serde_json::Value> = Vec::with_capacity(list.len());
901901
for v in list.iter() {
902-
let s: String = match v.extract::<String>() {
903-
Ok(s) => s,
904-
Err(_) => v.str()?.extract()?,
902+
// Whether the element arrived as a Python `str` decides which member of
903+
// the template's own `<float> | <floatstring>` union it is, and a
904+
// `<floatstring>` has to keep the spelling it was written with (§7.5).
905+
// `Float64` reads a JSON string as that spelling and a JSON number as a
906+
// bare value, so the distinction has to survive to here -- `v.str()`
907+
// collapses it.
908+
let (s, is_text): (String, bool) = match v.extract::<String>() {
909+
Ok(s) => (s, true),
910+
Err(_) => (v.str()?.extract()?, false),
905911
};
906912
items.push(match variant {
907913
"int" | "chunkInt" => match s.parse::<i64>() {
908914
Ok(n) => serde_json::Value::Number(n.into()),
909915
Err(_) => serde_json::Value::String(s),
910916
},
917+
// The text carries as-is. `Float64`'s deserializer parses it, and
918+
// rejects an unparseable one there rather than here -- which is also
919+
// what happened when this re-emitted a number.
920+
"float" if is_text => serde_json::Value::String(s),
911921
"float" => match s.parse::<f64>() {
912922
Ok(n) => serde_json::Number::from_f64(n)
913923
.map(serde_json::Value::Number)

‎rust-bindings/src/model/step_param_space.rs‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,26 @@ impl PyStepParameterSpaceIterator {
214214
}
215215

216216
fn __getitem__(&self, py: Python<'_>, index: isize) -> PyResult<Py<PyDict>> {
217+
// Random access uses a fresh iterator — don't disturb the
218+
// persistent iter's cursor or its adaptive Arc. It must carry the
219+
// same chunk override, or indexing would report chunks that
220+
// iteration never yields.
221+
let iter =
222+
StepParameterSpaceIterator::new_with_chunk_override(&self.space, self.chunk_override)
223+
.map_err(model_err_to_py)?;
224+
// Rejected here rather than left to `get`, because the negative-index
225+
// arithmetic below resolves against `self.len` — the count `__len__`
226+
// refuses to report for an adaptive space. Without this, `it[-1]` declines
227+
// only incidentally, and would start answering against that hidden count
228+
// if `get` were ever extended to adaptive spaces the way 0.6.0 extended it
229+
// to contiguous ones. The message is the pure-Python reference's; the type
230+
// stays `IndexError`, which is a `LookupError` as v0 raises, so `except`
231+
// clauses for either keep working.
232+
if iter.chunks_adaptive() {
233+
return Err(pyo3::exceptions::PyIndexError::new_err(
234+
"Items cannot be retrieved by index because the parameter space uses adaptive chunking.",
235+
));
236+
}
217237
let idx = if index < 0 {
218238
let adjusted = self.len as isize + index;
219239
if adjusted < 0 {
@@ -225,13 +245,6 @@ impl PyStepParameterSpaceIterator {
225245
} else {
226246
index as usize
227247
};
228-
// Random access uses a fresh iterator — don't disturb the
229-
// persistent iter's cursor or its adaptive Arc. It must carry the
230-
// same chunk override, or indexing would report chunks that
231-
// iteration never yields.
232-
let iter =
233-
StepParameterSpaceIterator::new_with_chunk_override(&self.space, self.chunk_override)
234-
.map_err(model_err_to_py)?;
235248
match iter.get(idx) {
236249
Some(params) => task_param_set_to_py(py, &params),
237250
None => Err(pyo3::exceptions::PyIndexError::new_err(

‎rust-bindings/src/model/task_parameter.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,12 @@ pub(crate) fn task_parameter_to_py<'py>(
548548
}
549549
.into_bound_py_any(py)
550550
}
551+
// `Float64` carries the spelling a `<floatstring>` range element was
552+
// written with (§7.5). It reaches a command line through
553+
// `TaskParameterValue`, which renders it verbatim; this getter is the
554+
// numeric introspection view, so take the value and drop the spelling.
551555
TaskParameter::Float { range } => PyFloatTaskParameter {
552-
range: range.clone(),
556+
range: range.iter().map(|f| f.value()).collect(),
553557
}
554558
.into_bound_py_any(py),
555559
TaskParameter::String { range } => PyStringTaskParameter {

‎scripts/check_third_party_licenses.sh‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,15 @@ awk -v re="^[*][*] ($workspace_pattern); version " '
150150

151151
# ── Combine ───────────────────────────────────────────────────────────
152152

153+
# Piped through `sed` on the way in, so the EOL strip needs neither a second temp
154+
# file nor `sed -i`, which wants a backup suffix on BSD sed and refuses one on GNU.
153155
{
154156
echo ""
155157
echo ""
156158
cat "$python_section"
157159
echo ""
158160
cat "$rust_section"
159-
} > "$generated"
160-
161-
# Ensure consistent EOL.
162-
sed -i 's/\r//' "$generated"
161+
} | sed 's/\r//' > "$generated"
163162

164163
if [[ "$mode" == "update" ]]; then
165164
cp "$generated" "$OUTPUT_FILE"

‎specs/python-model-interface.md‎

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,24 @@ does. (The underlying Rust struct has `chunks: Option<ResolvedChunks>`
718718
on the `Int` variant for shape reasons, but no resolver path ever
719719
populates it; the binding mirrors the runtime *behaviour*.)
720720

721+
`FloatTaskParameter.range` is numeric, so it does not show the decimal
722+
places a `<floatstring>` range element was written with. A range element
723+
`'2.50'` reports `2.5` here and renders `2.50` as the task parameter
724+
value, which is the form that reaches a command line (Template Schemas
725+
§7.5). Two `FloatTaskParameter`s that compare equal by `range` can
726+
therefore render different task values. Read
727+
`StepParameterSpaceIterator` for the rendered form.
728+
729+
Constructing a space directly follows the same rule as the template: a
730+
range element given as a `str` is a `<floatstring>` and keeps its
731+
spelling, and one given as a `float` is a `<float>` and renders as the
732+
number. `StepParameterSpace(taskParameterDefinitions={"F": {"type":
733+
"FLOAT", "range": ["1.50"]}})` renders `1.50`, and `range=[1.5]` renders
734+
`1.5`. Stripping a redundant leading zero is a `create_job`
735+
normalization rather than part of reading a resolved value, so `'02.50'`
736+
given directly to the constructor keeps its zero where the same element
737+
in a template does not.
738+
721739
### `ChunkIntTaskParameter`
722740

723741
Available only when the `TASK_CHUNKING` extension is enabled.
@@ -1176,20 +1194,30 @@ least 1, so 0 would otherwise silently mean 1, and the
11761194
`chunks_default_task_count` setter already rejects it. The pure-Python
11771195
reference does not validate this argument.
11781196

1179-
Two current-implementation limitations, both divergences from the v0
1180-
reference rather than intended behaviour. Each has a `strict` xfail in
1181-
`test/openjd/model_v1/test_known_gaps.py`, so clearing either will fail
1182-
CI until this text is updated with it.
1183-
1184-
- Indexing observes the override only for a space that supports random
1185-
access. A `CONTIGUOUS` chunked space requires sequential iteration, so
1186-
`it[i]` raises `IndexError` for any index — with or without the
1187-
override — even though `len(it)` reports a count. See
1188-
`test_a_contiguous_chunked_space_supports_indexing`.
1189-
- `chunks_parameter_name` and `chunks_default_task_count` both return
1190-
`None` once the space is non-adaptive, which supplying the override
1191-
makes it. v0 reports the parameter name and the override value. See
1192-
`test_chunk_metadata_is_reported_for_a_non_adaptive_space`.
1197+
Indexing observes the override. `openjd-model` 0.6.0 gave a `CONTIGUOUS`
1198+
chunked space random access, so `it[i]` answers there as it does for a
1199+
`NONCONTIGUOUS` one, and reports the overridden granularity rather than
1200+
the template's.
1201+
1202+
One current-implementation limitation remains. An *adaptive* space has no
1203+
knowable count until it is walked, so `len(it)` raises `ValueError` and
1204+
`it[i]` is refused for every index, negative included. Iteration still
1205+
yields, which is what distinguishes an unknown count from an empty space.
1206+
Supplying the override makes the space static and lifts both.
1207+
1208+
That refusal is enforced rather than incidental: `__getitem__` rejects an
1209+
adaptive space before it resolves a negative index, because the
1210+
arithmetic for a negative index would otherwise run against the length
1211+
`__len__` declines to report.
1212+
1213+
One divergence from the v0 reference here, in the exception *type*. v0
1214+
raises a bare `LookupError` for an adaptive `it[i]`; v1 raises
1215+
`IndexError`, which is a `LookupError` subclass, so a caller catching
1216+
either type is served by both implementations. The messages agree.
1217+
Because `IndexError` also means "past the end" in v1, the two conditions
1218+
are told apart by the message rather than the type — the adaptive refusal
1219+
says `Items cannot be retrieved by index because the parameter space uses
1220+
adaptive chunking.` where a real overrun says `index out of range`.
11931221

11941222
### `StepDependencyGraph`
11951223

‎test/openjd/model_v1/test_known_gaps.py‎

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
from __future__ import annotations
2121

22-
from typing import Any
23-
2422
# ── Top-level package no longer leaks typing imports ──
2523
#
2624
# An earlier draft of ``openjd.model._v1`` imported ``Any``,
@@ -43,121 +41,3 @@ def test_no_internal_imports_leak_at_top_level(name: str) -> None:
4341
import openjd.model._v1 as v1
4442

4543
assert not hasattr(v1, name), f"{name} leaks as a public attribute on openjd.model._v1"
46-
47-
48-
# ── Chunked parameter spaces: two divergences from the v0 reference ──
49-
#
50-
# Found while adding `chunks_task_count_override` to
51-
# `StepParameterSpaceIterator`. Neither is caused by that argument — both
52-
# reproduce without it — so they are recorded here rather than fixed in
53-
# passing.
54-
55-
56-
def _chunked_step(constraint: str) -> Any:
57-
from openjd.model._v1 import create_job, decode_job_template
58-
59-
template = {
60-
"specificationVersion": "jobtemplate-2023-09",
61-
"name": "T",
62-
"extensions": ["TASK_CHUNKING"],
63-
"steps": [
64-
{
65-
"name": "S",
66-
"parameterSpace": {
67-
"taskParameterDefinitions": [
68-
{
69-
"name": "Frame",
70-
"type": "CHUNK[INT]",
71-
"range": "1-10",
72-
"chunks": {"defaultTaskCount": 5, "rangeConstraint": constraint},
73-
}
74-
]
75-
},
76-
"script": {
77-
"actions": {"onRun": {"command": "echo", "args": ["{{Task.Param.Frame}}"]}}
78-
},
79-
}
80-
],
81-
}
82-
job_template = decode_job_template(template=template, supported_extensions=["TASK_CHUNKING"])
83-
return create_job(job_template=job_template, job_parameter_values={}).steps[0]
84-
85-
86-
@pytest.mark.xfail(
87-
reason="v1 derives chunks_parameter_name and chunks_default_task_count from adaptive "
88-
"detection, so both are None for any non-adaptive chunked space. v0 reports them for "
89-
"any chunked space. See openjd-model step_param_space.rs: chunks_param_name and "
90-
"adaptive_chunk_size are both built from adaptive_info.",
91-
strict=True,
92-
)
93-
@pytest.mark.parametrize(
94-
"chunks,override,expected_count",
95-
[
96-
# Statically chunked: no override involved, v0 reports the template's size.
97-
({"defaultTaskCount": 5, "rangeConstraint": "CONTIGUOUS"}, None, 5),
98-
# Statically chunked, re-chunked by the override.
99-
({"defaultTaskCount": 5, "rangeConstraint": "CONTIGUOUS"}, 1, 1),
100-
# Adaptive, turned static by the override. v0 reports the override as the size.
101-
(
102-
{"defaultTaskCount": 5, "targetRuntimeSeconds": 60, "rangeConstraint": "CONTIGUOUS"},
103-
1,
104-
1,
105-
),
106-
],
107-
ids=["static", "static-overridden", "adaptive-overridden"],
108-
)
109-
def test_chunk_metadata_is_reported_for_a_non_adaptive_space(
110-
chunks: dict, override: int | None, expected_count: int
111-
) -> None:
112-
"""v0 returns ``"Frame"`` and the chunk size for each of these. v1 returns ``None``.
113-
114-
Neither value is unknowable — both are in the template, or are the override the caller
115-
just passed — so a consumer inspecting a non-adaptive chunked space through v1 cannot
116-
learn which parameter chunks, or at what size. One root cause, three ways to reach it:
117-
anything that leaves the space non-adaptive drops both getters.
118-
"""
119-
from openjd.model._v1 import create_job, decode_job_template
120-
from openjd.model._v1.job import StepParameterSpaceIterator
121-
122-
template = {
123-
"specificationVersion": "jobtemplate-2023-09",
124-
"name": "T",
125-
"extensions": ["TASK_CHUNKING"],
126-
"steps": [
127-
{
128-
"name": "S",
129-
"parameterSpace": {
130-
"taskParameterDefinitions": [
131-
{"name": "Frame", "type": "CHUNK[INT]", "range": "1-10", "chunks": chunks}
132-
]
133-
},
134-
"script": {
135-
"actions": {"onRun": {"command": "echo", "args": ["{{Task.Param.Frame}}"]}}
136-
},
137-
}
138-
],
139-
}
140-
job_template = decode_job_template(template=template, supported_extensions=["TASK_CHUNKING"])
141-
step = create_job(job_template=job_template, job_parameter_values={}).steps[0]
142-
143-
it = StepParameterSpaceIterator(step=step, chunks_task_count_override=override)
144-
assert it.chunks_adaptive is False
145-
assert it.chunks_parameter_name == "Frame"
146-
assert it.chunks_default_task_count == expected_count
147-
148-
149-
@pytest.mark.xfail(
150-
reason="v1 refuses random access whenever the space needs sequential iteration, and "
151-
"contiguous chunking always does. v0 supports indexing the same space.",
152-
strict=True,
153-
)
154-
def test_a_contiguous_chunked_space_supports_indexing() -> None:
155-
"""v0 answers ``it[0]`` with ``1-5``. v1 raises ``IndexError``.
156-
157-
``len()`` works on this space, so the count is known; only ``get`` declines.
158-
"""
159-
from openjd.model._v1.job import StepParameterSpaceIterator
160-
161-
it = StepParameterSpaceIterator(step=_chunked_step("CONTIGUOUS"))
162-
assert len(it) == 2
163-
assert it[0]["Frame"].value == "1-5"

0 commit comments

Comments
 (0)