feat(model): Expose chunks_task_count_override on the v1 iterator - #344
Open
leongdl wants to merge 5 commits into
Open
feat(model): Expose chunks_task_count_override on the v1 iterator#344leongdl wants to merge 5 commits into
leongdl wants to merge 5 commits into
Conversation
Signed-off-by: David Leong <leongdl@amazon.com>
Signed-off-by: David Leong <leongdl@amazon.com>
Signed-off-by: David Leong <leongdl@amazon.com>
…case Signed-off-by: David Leong <leongdl@amazon.com>
Signed-off-by: David Leong <leongdl@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
chunks_task_count_overridetoStepParameterSpaceIterator.__new__on the Rust-backed v1 iterator, wired toopenjd-model's existingStepParameterSpaceIterator::new_with_chunk_override.Why
A statically chunked space could not be walked at any granularity but the template's own. The only override the binding exposed is the
chunks_default_task_countsetter, which accepts adaptive spaces only:The capability already existed everywhere else:
openjd-rs(openjd-model)new_with_chunk_override(space, Some(n))— used internally bycreate_jobfor task counting and byopenjd-cli'sstep_total_tasksopenjd.model)chunks_task_count_overrideconstructor kwargSo this is a missing wrapper rather than a missing feature, and it closes a v0/v1 parity gap.
The consumer case is storing one task per chunk value. Given
1-20chunked five at a time, iteration yields1-5,6-10,11-15,16-20, but a caller that needs individual tasks wants1-1,2-2, …. On the pure-Python path that ischunks_task_count_override=1; on v1 there was no equivalent, so callers had to refuse such templates.Behaviour
Mirrors the pure-Python reference: the override replaces
defaultTaskCountand turns adaptive chunking off, and is ignored when the space has no chunked parameter.Two details worth a reviewer's attention.
__getitem__carries the override. It builds a fresh iterator, so without threading the override through, random access would report the template's chunks while iteration reported the overridden ones. Covered by a test usingNONCONTIGUOUS, since a contiguous chunked space is always sequential and declinesget(see below).chunks_task_count_override=0raisesValueError.openjd-modelapplies.max(1)to the override, so 0 would silently mean 1, and thechunks_default_task_countsetter already rejects 0. This is a deliberate, small divergence from the pure-Python reference, which does not validate the argument. Happy to drop the check if you would rather match the reference exactly.Two pre-existing gaps found along the way
Neither is caused by this change — both reproduce without the new argument — so they are recorded as
strict=Truexfails intest/openjd/model_v1/test_known_gaps.pyrather than fixed in passing. Happy to split either into its own PR.chunks_parameter_nameandchunks_default_task_countare both derived from adaptive detection (chunks_param_nameandadaptive_chunk_sizeare built fromadaptive_infoinstep_param_space.rs), so both returnNonefor a statically chunked space. v0 returns"Frame"and5. Neither value is unknowable — both are in the template.needs_sequential = adaptive || has_contiguous_chunks(space), andget()returnsNonewheneversequential, soit[0]raisesIndexError. v0 answers1-5for the same space.len()works, so the count is known; onlygetdeclines.Testing
hatch run test— 5528 passed, 24 skipped, 5 xfailedhatch run lint,hatch run typing— cleancargo fmt --check,cargo build --all-targets,cargo clippy --all-targets -- -D warnings,cargo test— cleanNew tests in
test/openjd/model_v1/test_step_param_space_iter.py::TestChunksTaskCountOverridebuild the space throughdecode_job_template+create_job, so they exercise the path a consumer actually hits. They cover: the un-overridden baseline,override=1yielding individual tasks, an intermediate size regrouping the space,len()reflecting the override, indexing agreeing with iteration, adaptive being turned off (andlen()becoming answerable as a result), the override being ignored for an unchunked space,0being rejected, the setter still refusing static spaces, and containment round-tripping.specs/python-model-interface.mdandsrc/openjd/_openjd_rs.pyiare updated. The stub was hand-edited:scripts/generate_stubs.shneeds the patchedpyo3-stub-gen, which does not compile in my environment (8 errors inpyo3-stub-genitself). Worth regenerating on a machine with the patched tool to confirm it matches.