Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Task execution graph #26

Closed
nat-n opened this issue Apr 27, 2021 · 3 comments
Closed

Proposal: Task execution graph #26

nat-n opened this issue Apr 27, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request Seeking feedback

Comments

@nat-n
Copy link
Owner

nat-n commented Apr 27, 2021

Another model for task composition (in addition to sequence tasks) would be to support declaring dependencies between tasks, such that invoking a task with dependencies would first run all its dependencies (and their dependencies and so on).

Thus an execution DAG of tasks could easily be defined as in the following

Config proposal A

[tool.poe.tasks]
test = "pytest src"
version.script = "scripts:get_current_version"

  [tool.poe.tasks.build]
  cmd = "docker build -f Dockerfile -t my_app:$VERSION ."
  deps = { "" = ["test -v"], VERSION = "version" }

Config proposal B

[tool.poe.tasks]
test = "pytest src"
version.script = "scripts:get_current_version"

  [tool.poe.tasks.build]
  cmd = "docker build -f Dockerfile -t my_app:$VERSION ."
  deps = ["test -v"]
  uses = { VERSION = "version" }

Note that in this example scenario the dependency on the test task demonstrates that dep tasks could be passed arguments (or even env vars).

This example also demonstrates the output of one task being captured and made available to the dependant task as an env var hence addressing #21. Since this required silencing (capturing) the output of the dependency, this could allow for multiple tasks to be run in parallel if their dependencies are all satisfied at the same time and neither of them will write to the console (related #24).

This could be particularly powerful if combined with #12 , getting us closer to the power of make.

I've started prototyping this already, but comments are more than welcome.

@nat-n nat-n added enhancement New feature or request Seeking feedback labels Apr 27, 2021
@nat-n nat-n self-assigned this Apr 27, 2021
nat-n added a commit that referenced this issue Apr 28, 2021
Included:
- Add deps task option for declaring dependencies on other tasks
- Add uses task option for declaring a task dependency where the
  output of the upstream task should be captured and made available
  as an environment variable.
- Add TaskExecutionGraph for planning execution of tasks with
  dependencies
- modify PoeExecutor to support stdout capture
- Add capture_stdout task option to redirect task output to a file.

Still to do:
- Feature tests for new features
nat-n added a commit that referenced this issue Apr 28, 2021
Included:
- Add deps task option for declaring dependencies on other tasks
- Add uses task option for declaring a task dependency where the
  output of the upstream task should be captured and made available
  as an environment variable.
- Add TaskExecutionGraph for planning execution of tasks with
  dependencies
- modify PoeExecutor to support stdout capture
- Add capture_stdout task option to redirect task output to a file.

Still to do:
- Feature tests for new features
nat-n added a commit that referenced this issue Apr 28, 2021
Included:
- Add deps task option for declaring dependencies on other tasks
- Add uses task option for declaring a task dependency where the
  output of the upstream task should be captured and made available
  as an environment variable.
- Add TaskExecutionGraph for planning execution of tasks with
  dependencies
- modify PoeExecutor to support stdout capture
- Add capture_stdout task option to redirect task output to a file.

Still to do:
- Feature tests for new features
- Document new features
@nat-n
Copy link
Owner Author

nat-n commented Apr 28, 2021

@kikohs I prototyped a solution and made a beta release: https://pypi.org/project/poethepoet/0.11.0b2/ (also includes experimental implementation of named arguments).

It hasn't been extensively tested, but I'm keen to get feedback on how well it works for your use case, and whether you encounter any issues.

@kikohs
Copy link

kikohs commented May 11, 2021

Hi Nat, I didn't forget your message. Just a swarmed at the moment. Thanks for implementing this, I'll let you know.

@nat-n
Copy link
Owner Author

nat-n commented Nov 14, 2021

Experimental (but reasonably complete) task execution graph released in v0.11.0.

@nat-n nat-n closed this as completed Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Seeking feedback
Projects
None yet
Development

No branches or pull requests

2 participants