Fix loop export reference inference and Jinja template resolution for loop contexts#349
Open
zhongkaifu wants to merge 1 commit intomainfrom
Open
Fix loop export reference inference and Jinja template resolution for loop contexts#349zhongkaifu wants to merge 1 commit intomainfrom
zhongkaifu wants to merge 1 commit intomainfrom
Conversation
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.
Motivation
exportssegment and validation rejected inferred paths.loop/loop_ctxreferences as non-array sources during model validation.{{ ... }}reference paths against the binding context early, causinglength/countand built-in function usages to return incorrect values.Description
BindingContexttolerant of both wrapped (result_of.<loop>.exports.<key>) and flattened (result_of.<loop>.<key>) loop result shapes by skipping theexportssegment when the runtime result is flattened and by improving the inference path logic inresolve_binding/_get_from_context.BindingContexttemplate handling so a bare Jinja template{{ ... }}that looks like a simple reference toloop/loop_ctx/result_ofis resolved viactx.get_valuebefore generic Jinja evaluation, and fall back to the context value when a JinjaUndefinedis produced.sourceschema checks for paths that areloopor start withloop./loop_ctx.inWorkflow.validate_loop_body_subgraphsto avoid false positives for loop-local references.Testing
pytest -q tests/test_reference_templates.py::test_reference_allows_builtin_function_invocation tests/test_reference_templates.py::test_eval_params_renders_interpolated_templates tests/test_loop_binding_inference.py::test_missing_exports_segment_is_inferred tests/test_loop_state_isolation.py::test_nested_loop_results_do_not_leak_across_outer_iterations tests/test_reference_templates.py::test_binding_context_resolves_length_field tests/test_reference_templates.py::test_binding_context_resolves_count_fieldand all tests passed.Codex Task