Skip to content

Collect dependencies for dynamic replacements - #886

Closed
Andrew-S-Rosen wants to merge 1 commit into
materialsproject:mainfrom
Andrew-S-Rosen:agent/collect-dynamic-replacement-dependencies
Closed

Collect dependencies for dynamic replacements#886
Andrew-S-Rosen wants to merge 1 commit into
materialsproject:mainfrom
Andrew-S-Rosen:agent/collect-dynamic-replacement-dependencies

Conversation

@Andrew-S-Rosen

Copy link
Copy Markdown
Member

What changed

  • Collect jobs and flows created while a job function is executing.
  • Resolve dynamically created Job and Flow inputs to their output references.
  • Expand Response(replace=...) with only the captured transitive dependencies required by the returned replacement.
  • Add a regression test covering successful local execution and confirming that an unrelated dynamically created job is excluded.

Why

A dynamically created replacement job could reference another job created in the same function while omitting that dependency from Response(replace=...). The replacement then failed because its output reference could not be resolved. Jobflow now tracks the dynamic construction context and builds the necessary dependency closure before preparing the replacement flow.

User impact

This pattern now runs successfully without manually constructing a Flow:

@job
def make_dynamic_workflow():
    first = add(1, 2)
    final = multiply(first, 3)
    return Response(replace=final)

Validation

  • python -m pytest tests/core/test_job.py tests/core/test_flow_decorator.py -q — 38 passed, 1 xfailed
  • python -m ruff check --ignore PLR0917 src/jobflow/core/job.py tests/core/test_job.py — passed
  • git diff --check — passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant