support passing parameters as lists of dictionaries in Python? I am currently getting the following error when I try to do that:
Copy code
prefect.exceptions.ClientError: 400 Client Error: Bad Request for url: <https://api.prefect.io/>
This is likely caused by a poorly formatted GraphQL query or mutation but the response could not be parsed for more details
I tried performing the same operation via the interactive graphql api and I needed to escape the
{
and
"
to get the query to work. Looking at the source it seems as though this doesn’t happen and might be the cause of my problem.
Eddie Atkinson
09/09/2021, 6:55 AM
I’ve changed my approach to avoid this problem, but would be interested to hear whether that’s the case
k
Kevin Kho
09/09/2021, 2:07 PM
Hey @Eddie Atkinson, I believe this should work. If you got it to work in the interactive API, there should be a way to get it to work with Python (syntax might just differ a bit). I’ll give this a shot later
e
Eddie Atkinson
09/10/2021, 12:31 AM
Cheers Kevin!
k
Kevin Kho
09/10/2021, 12:35 AM
Oh sorry, support was kinda busy. If you don’t hear from me tom, feel free to ping
Kevin Kho
09/10/2021, 9:17 PM
This worked for me:
Copy code
from prefect import task, Flow, Parameter
import prefect
@task
def abc(x):
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(x)
return x
with Flow(name="betfair_flow") as flow:
x = Parameter("x")
abc(x)
flow.register("dsdc")
from prefect.tasks.prefect import StartFlowRun
import json
test = [{'id': 123, 'data': 'qwerty', 'indices': [1,10]}, {'id': 345, 'data': 'mnbvc', 'indices': [2,11]}]
StartFlowRun(project_name="dsdc", flow_name="betfair_flow").run(parameters={"x": json.dumps(test)})
e
Eddie Atkinson
09/13/2021, 4:36 AM
Interesting, I must have done something weird. Thanks Kevin!
k
Karolína Bzdušek
09/14/2021, 1:47 PM
Hi! @Kevin Kho - and if one want to pass json as parameter but run via CLI?
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.