Adapt to dags' runtime-type-checker-friendly wrappers#99
Merged
Conversation
Three sites read `__annotations__` directly on functions that may be dags wrappers (`rename_arguments` results, including those produced by `get_one_function_without_tree_logic`): - `fail_if._fail_if_root_nodes_must_be_arrays_but_are_scalars` - `automatically_added_functions._convertibles` - `tt.vectorization._create_vectorized_annotations` `dags.get_annotations` reads the user-described view regardless of where dags keeps it — directly on `__annotations__` (current dags release) or on `__signature__` once dags wrappers advertise the `*args, **kwargs` forwarder shape on `__annotations__`. Routing these reads through it keeps ttsim working across that dags change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
b300fd2 to
9d9009a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
2af5ae9 to
54bbbbc
Compare
Routes the three `__annotations__` reads (`fail_if`, `automatically_added_functions._convertibles`, `tt.vectorization._create_vectorized_annotations`) through `dags.get_annotations`, which returns the user-described view regardless of whether dags keeps it on `__annotations__` (pre-0.6) or `__signature__` (0.6+).
54bbbbc to
dc20d5d
Compare
MImmesberger
approved these changes
May 24, 2026
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.
Coordinated change
Part of a three-repo change adopting runtime type checking in dags-based projects:
Merge order: ttsim#99 (anytime) · dags#82 → release 0.6 · pylcm#357 (after 0.6).
Summary
dags#82 moves
with_signature/rename_argumentswrappers to advertise the*args, **kwargsforwarder shape on__annotations__(the user-described view stays on__signature__). Three sites in ttsim read__annotations__directly off functions that may be such wrappers; this PR routes those reads throughdags.get_annotations, which reads the user view regardless of where dags keeps it.This is a pure compatibility change — ttsim does not adopt runtime type checking here.
fail_if._fail_if_root_nodes_must_be_arrays_but_are_scalarsfunc.function(anAggByGroupFunction/ColumnFunction, whose.functionisrename_arguments-wrapped)automatically_added_functions._convertiblese.function.__annotations__["return"]ofParamFunctions post-remove_tree_logictt.vectorization._create_vectorized_annotationsinspect.get_annotations(func)wherefuncis aParamFunction/PolicyFunction's wrapped.function(
rename_argumentsresults here include those produced bydags.tree.get_one_function_without_tree_logic, whichremove_tree_logicroutes through.)Why
dags.get_annotationsreads the user-described view regardless of where dags keeps it:__annotations__directly (no behaviour change for ttsim);__signature__via the existing args/kwargs-mismatch path.So this PR is back-compatible with the current dags release and forward-compatible with dags#82 — it can land independently, ahead of the dags release.
Future work
ttsim's policy functions are DAG nodes in exactly the way pylcm's regime functions are. The natural next step — separate from this compatibility fix — is a scoped beartype claw analogous to pylcm#357: runtime-check the leaf node functions, where the types actually live, since the dags-composed callable is
(*args, **kwargs)and a static checker can say nothing about a composition determined by data. The known precondition is the one pylcm handled: where Python scalars and JAX arrays mix, tighten internal helpers to canonical JAX types and name the Python→JAX boundary explicitly (cast at the boundary) rather than widening annotations.Verification
pixi run -e py314 pytest→ 969 passed, 7 skipped, 2 xfailedpixi run -e type-checking ty→ cleanprek run --all-files→ cleanTested against the current released dags (no forwarder-shape change yet), confirming the back-compatible half. The forward-compatible half is exercised by dags#82's own suite.
🤖 Generated with Claude Code