https://prefect.io logo
#prefect-community
Title
# prefect-community
j

Jessica Smith

06/09/2022, 9:10 PM
Can a templated task run name access attributes of objects? Like task_run_name="{my_object.name}"
k

Kevin Kho

06/09/2022, 9:12 PM
I think if my_object is an input into the task. If not like that, you can surely do a function call like this
j

Jessica Smith

06/09/2022, 9:38 PM
Right, duh, I literally just read that. Thanks!
So that is giving me an error
TypeError: Object of type function is not JSON serializable
It's when trying to execute create_flow_run:
Copy code
File "c:\sourcecontrol\Prefect\venv\lib\site-packages\prefect\client\client.py", line 1192, in create_flow_run
    res = self.graphql(create_mutation, variables=dict(input=inputs))
  File "c:\sourcecontrol\Prefect\venv\lib\site-packages\prefect\client\client.py", line 447, in graphql
    params=dict(query=parse_graphql(query), variables=json.dumps(variables)),
thoughts?
k

Kevin Kho

06/09/2022, 9:56 PM
This looks like you are trying to have a function as a parameter or an object? So
create_flow_run
goes through an API so everything passed needs to be JSONSerializable to be passed through the API. You can’t have Python classes or callables
It’s an API request
j

Jessica Smith

06/09/2022, 10:00 PM
I think I figured it out, didn't change something after switching to a function
k

Kevin Kho

06/09/2022, 10:00 PM
Ah ok. Good to hear!
3 Views