Skip to content

Pass run instance to task#924

Closed
shalvah wants to merge 5 commits intoShopify:mainfrom
shalvah:expose-run-to-task
Closed

Pass run instance to task#924
shalvah wants to merge 5 commits intoShopify:mainfrom
shalvah:expose-run-to-task

Conversation

@shalvah
Copy link
Copy Markdown
Contributor

@shalvah shalvah commented Dec 3, 2023

This PR adds a .run property to the task object, allowing the task to access information about the current run.

Some example use cases for this:

  • Richer logs: automatically tagging logs emitted from the task with the run ID
  • Richer error context: adding the run ID as a tag for better grouping/filtering
  • Enriching the run metadata from within the task
  • Persisting task information (for instance, marking an item as "failed" without crashing and interrupting the whole task)

It shouldn't be a breaking change, but I've wrapped it in a guard that first checks if the method exists.

Also, arguments are assigned afterwards, so if the task defines an attribute named run, it isn't overriden.

@olivier-thatch
Copy link
Copy Markdown

Any chance this could be reopened and considered for merging? We could certainly use this feature :)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants