Hi All, I am looking for how to run a flow using t...
# prefect-community
Hi All, I am looking for how to run a flow using the prefect
Where is the documentation for this?
Hi @Richard Hughes - how do you want to run the flow? You could use the
mutation in the Interactive API - the docs are right there in the Interactive API page of the UI. If you want to do something different, please let us know.
I want to do this from a console
@Jenny how do put my parameters into this call? example:
prefect run cloud --version_group_id "PROD.System.SQLFileExecution" --project "PROD" --paramters SQLFileName="F:\\Shares\\System\\Script.sql"
I found this: https://docs.prefect.io/api/latest/cli/run.html
prefect run cloud --version_group_id "PROD.System.SQLFileExecution" --project "PROD" --parameters-string {"SQLFileName": "F:\\Shares\\System\\Script.sql"}
does this work for
Not quite sure I understand the question. Do you mean can -ps be used instead of --parameters-string? You can also use -h or --help to get a list of those commands.
@Jenny, I am still having trouble passing the json parameters into the
prefect run cloud
. I've tried both
I am using powershell console in my case, I am not sure if this is causing the issue. Example:
Copy code
@{SQLFileName="F:\Shares\Snowflake\System\AccessControl.sql"} | ConvertTo-Json -compress > .\parameters.json
Get-Content .\parameters.json
prefect auth login -t $env:prefect_token
prefect run cloud --name "System.SQLFileExecution" --project "PROD" --parameters-file parameters.json
Copy code
Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\prefect.exe\__main__.py", line 7, in <module>
  File "c:\python37\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\python37\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\python37\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python37\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python37\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python37\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python37\lib\site-packages\prefect\cli\run.py", line 217, in cloud
  File "c:\python37\lib\site-packages\prefect\cli\run.py", line 369, in _run_flow
    file_params = json.load(params_file)
  File "c:\python37\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "c:\python37\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "c:\python37\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "c:\python37\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Ah - I'm not an expert on the way the CLI handles JSON but for graphql mutations the JSON can be a little tricky and I suspect it may be the same here. You might need to add "\ as in the graphql docs here: https://docs.prefect.io/orchestration/concepts/flow_runs.html#graphql But let me double check that for you.
@Jenny let me escape those double quotes and try again, fingers crossed
I just tried it myself and it went through. So for example {"c":3} would need to be "{\"c\":3}". We'll need to update that in the help section of the CLI as I see it suggests parameters without that escape.
Can you let me know if it works for you too?
Here is the winning combo:
prefect run cloud --name "System.SQLFileExecution" --project "PROD" --parameters-string '{\"SQLFileName\":\"F:\\Shares\\System\\Script.sql\"}'
, now my fingers are crossed again this will run in azure devops w/ remote powershell cmdlet
Great! Thank you.
I've added an issue for this here. Feel free to add any extra info if you feel it's useful.
👍 1
success! thanks for you help on this on
👍 1