Skip to content

Conversation

@vineetbansal
Copy link

@vineetbansal vineetbansal commented Jan 5, 2026

Summary

When a creating dynamic flow, it is currently the Job's responsibility to create a Flow and return Response with a replace:

@job
def add_distributed(list_a):
    jobs = [add(val, 1) for val in list_a]
    flow = Flow(jobs)
    return Response(replace=flow)

This works fine, but we feel that a cleaner way might be if the following worked directly:

@job
def add_distributed(list_a):
    jobs = [add(val, 1) for val in list_a]
    return jobs

i.e. if a Job returns an iterable of Job objects (or a single Job object), it is interpreted as a replacement, and the actual mechanics of replacement (Response/replace) are handled internally in jobflow.

This enhancement is related to making jobflow closer to a drop-in replacement of a workflow engine (along with parsl, prefect etc) for the quacc platform.

This tweak allows this enhancement, while preserving old behavior.

Additional dependencies introduced (if any)

None

TODO (if any)

None

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request
title.

Before a pull request can be merged, the following items must be checked:

  • Code is in the standard Python style.
    The easiest way to handle this is to run the following in the correct sequence on
    your local machine. Start with running black on your new code. This will
    automatically reformat your code to PEP8 conventions and removes most issues. Then run
    pycodestyle, followed by flake8.
  • Docstrings have been added in theNumpy docstring format.
    Run pydocstyle on your code.
  • Type annotations are highly encouraged. Run mypy to
    type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply
pip install pre-commit and then pre-commit install and a check will be run
prior to allowing commits.

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