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

Supply context via local variables / context manager #5

Closed
jlowin opened this issue Jun 30, 2018 · 1 comment
Closed

Supply context via local variables / context manager #5

jlowin opened this issue Jun 30, 2018 · 1 comment

Comments

@jlowin
Copy link
Member

jlowin commented Jun 30, 2018

Rather than pass context variables explicitly as kwargs, supply them as variables that are set via context manager

Task Definition (user code)

from prefect.context import as_of_date

class MyTask:
    def run(self):
        """ return True if this task's as-of-date is today """
       if as_of_date.date() == datetime.now().date():
           return True
        else:
            return False

TaskRunner (Prefect code)

# context manager sets the values of variables like as_of_date
with prefect.context.set_context(context):
   my_task.run()
@jlowin
Copy link
Member Author

jlowin commented Jun 30, 2018

➤ Jeremiah Lowin commented:

Done!

@jlowin jlowin closed this as completed Jun 30, 2018
AlessandroLollo referenced this issue in AlessandroLollo/prefect Feb 8, 2022
…600-and-lt-0.931

Update mypy requirement from <0.911,>=0.600 to >=0.600,<0.931
cicdw pushed a commit that referenced this issue Aug 23, 2023
Remove all references to process worker configuration
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

No branches or pull requests

1 participant