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

Add more variables to context #1405

Merged
merged 8 commits into from
Aug 27, 2019
Merged

Add more variables to context #1405

merged 8 commits into from
Aug 27, 2019

Conversation

jlowin
Copy link
Member

@jlowin jlowin commented Aug 25, 2019

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including docs/outline.toml for API reference docs (if appropriate)

Note that your PR will not be reviewed unless all three boxes are checked.

What does this PR change?

This PR pulls the non-breaking changes out of #1403:

  • Adds task_slug, task, and flow to context
  • Adds flow_id and flow_run_id to context when running in Cloud
  • Updates context documentation

Why is this PR important?

@codecov
Copy link

codecov bot commented Aug 25, 2019

Codecov Report

Merging #1405 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting a discussion on tasks / flows in context and whether we should pursue that at this moment. Serialization costs + the fact that context is thread.local make me hesitant, without a strong known use case.

@@ -154,7 +154,7 @@ def initialize_run( # type: ignore
for param, value in parameters.items():
context_params[param] = value

context.update(flow_name=self.flow.name)
context.update(flow=self.flow, flow_name=self.flow.name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only piece of the PR that makes me hesitate -> Flow objects could be quite large, and adding this to context guarantees that all Dask communication has to ship the Flow along with every task run submission. Without a strong argument for its inclusion, I vote to not include it for now until we better understand the implications.

It is definitely possible that Flows are already serialized since we submit a FlowRunner method to Dask, but this feels like something we shouldn't do off-the-cuff without thinking through it.

@@ -166,7 +166,11 @@ def initialize_run( # type: ignore
context.update(loop_context)

context.update(
task_run_count=run_count, task_name=self.task.name, task_tags=self.task.tags
task=self.task,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related discussion: #889

We definitely know tasks are serialized by Dask already, but including "heavy" objects in context without a known use case still makes me nervous - context is a thread.local object too, so I honestly don't know if that introduces any complications for Tasks which use multithreading or not. It feels like something I'd rather learn during experimentation than from a user though.

@@ -155,6 +155,8 @@ def initialize_run( # type: ignore
updated_context = context or {}
updated_context.update(flow_run_info.context or {})
updated_context.update(
flow_id=flow_run_info.id,
flow_run_id=flow_run_info.id,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note: in the context of running w/ Cloud this is already added on to all deployments. (e.g. of use: https://github.com/PrefectHQ/prefect/blob/master/src/prefect/cli/execute.py#L39)

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlowin jlowin merged commit fea0298 into master Aug 27, 2019
@jlowin jlowin deleted the context-improvements branch August 27, 2019 04:09
@cicdw cicdw mentioned this pull request Aug 30, 2019
zanieb pushed a commit that referenced this pull request Mar 17, 2022
…-ui/esbuild-0.14.27

Bump esbuild from 0.14.25 to 0.14.27 in /orion-ui
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.

3 participants