haf
03/09/2021, 8:21 PMParameter to a value in a def?Jenny
03/09/2021, 8:42 PMhaf
03/09/2021, 8:42 PMhaf
03/09/2021, 8:42 PMhaf
03/09/2021, 8:42 PMx in that case, but not what.haf
03/09/2021, 8:43 PMdef function?haf
03/09/2021, 8:44 PMPrefectSecrets as values in a dict; why are simple values resolved but not nested?haf
03/09/2021, 8:45 PMSecret instances were not.Jenny
03/09/2021, 8:52 PMhaf
03/09/2021, 8:53 PMstr instance?haf
03/09/2021, 8:54 PMTask instances to constructors, but only to run methods?Jenny
03/09/2021, 9:17 PMJim Crist-Harif
03/09/2021, 9:18 PMWhat translates / resolves the value you pass into thefunction?def
I'm just trying to understand the magic that translates a Task instance into e.g. aWhen you build a prefectinstance?str
Flow, you're describing a graph of tasks that you'd like to execute. The flow is composed of Task objects as nodes, with the edges expressing how task results pass through the workflow. When that flow is executed, prefect's internals walk that graph and pass results from task to task as described (this all happens in the `FlowRunner`/`TaskRunner` objects).Jim Crist-Harif
03/09/2021, 9:22 PMAnd why, for example, you should never passThat only matters if you're not usinginstances to constructors, but only toTaskmethods?run
@task based tasks (but instead using Task subclasses). If you're using class-based tasks, you need to break your Task initialization into two phases:
⢠Static (non-task) arguments in the Task constructor. These are stored as attributes on the Task object itself.
⢠Dynamic (task) arguments must be encoded as part of the flow graph. Usually this is done by calling task.set_upstream or task.set_dependencies , or calling the task directly like a function (task(**dynamic_parameters_here)).
As I said above, this distinction only matters when using class-based tasks, if you're using @task to define tasks you won't have this issue.Jim Crist-Harif
03/09/2021, 9:24 PMOn a higher level; how can I passas values in a dict; why are simple values resolved but not nested?PrefectSecrets
Or maybe they are resolved? I just assumed they were not, sinceIt's hard for me to tell what you're asking here, but I think you're asking about the difference betweeninstances were not.Secret
prefect.client.Secret and prefect.tasks.secrets.PrefectSecret? The former is a client object, and shouldn't be treated as a task (you should have very few reasons to use this directly). PrefectSecret is what you usually want, and you should treat it as a Task. It can be passed as a parameter to other tasks.haf
03/09/2021, 9:51 PMclone = clone_repository(github_access_token, dbt_repository) but despite the definition: def clone_repository(token: str, repo: str): the passed variables have types PrefectSecret and Parameter respectively. These are not strings; so how come I can pretend they are inside clone_repository?Jim Crist-Harif
03/09/2021, 9:52 PMclone_repository have a @task decorator?haf
03/09/2021, 9:54 PMhaf
03/09/2021, 9:54 PMJim Crist-Harif
03/09/2021, 9:56 PMwith Flow(...) block as describing code that will run later, but not now. Later when you call flow.run (or kick off a flow run from prefect cloud/server), the tasks you've defined are executed with the arguments as described.haf
03/09/2021, 10:41 PM