Accept positional/string context shorthand for Flow.model(context_type=)#237
Merged
timkpaine merged 1 commit intoJun 9, 2026
Conversation
Class-based CallableModel execution already accepts positional/string context shorthand via ContextBase's ordered `zip(model_fields, v)` mapping (as used by Hydra `+context=[...]`). Generated @Flow.model instances expose the open FlowContext bag as their runtime context type, which has no declared fields to zip against, so positional shorthand was silently dropped. When a generated model declares a `context_type`, `compute()` now validates non-mapping shorthand (list/tuple/str) through that declared type first, then forwards the named values into the FlowContext bag. Mapping and named-kwarg inputs keep their existing paths. Scope: this covers the `compute()` entry point only. The direct-call form (`model([...])`) is intentionally not supported, since `Flow.call` validates against FlowContext before the generated body runs; supporting it would require reverting the bag-of-types design. Adds `_declared_context_type_for_model` and focused tests for list/tuple/string shorthand, parity with named inputs, and that bag-only models are unaffected. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
d168556 to
fae1c15
Compare
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## nk/auto_deps_auto_callable_model #237 +/- ##
====================================================================
+ Coverage 93.01% 93.02% +0.01%
====================================================================
Files 160 161 +1
Lines 17835 17868 +33
Branches 1153 1155 +2
====================================================================
+ Hits 16589 16622 +33
Misses 1020 1020
Partials 226 226 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Class-based CallableModel execution already accepts positional/string context shorthand via ContextBase's ordered
zip(model_fields, v)mapping (as used by Hydra+context=[...]). Generated @Flow.model instances expose the open FlowContext bag as their runtime context type, which has no declared fields to zip against, so positional shorthand was silently dropped.When a generated model declares a
context_type,compute()now validates non-mapping shorthand (list/tuple/str) through that declared type first, then forwards the named values into the FlowContext bag. Mapping and named-kwarg inputs keep their existing paths.Scope: this covers the
compute()entry point only. The direct-call form (model([...])) is intentionally not supported, sinceFlow.callvalidates against FlowContext before the generated body runs; supporting it would require reverting the bag-of-types design.Adds
_declared_context_type_for_modeland focused tests for list/tuple/string shorthand, parity with named inputs, and that bag-only models are unaffected.