We've been migrating a flow from v1 to v2 and that's all working out fine. However, in v1 we would invoke a flow from Python using code a little like this -
Copy code
from prefect.client.client import Client
c = Client(api_token='xxxxxxxxxx')
params = {'param1': 'Foo', 'param2': 'Bar'}
c.create_flow_run(
version_group_id='xxxx-xxxxxx-xxxxxx-xxxxx',
run_name='my_run_name',
parameters = params)
But I can't see a good example of how to do the same with v2! I think I'm missing something fundamental! Thanks
Ahh. thanks. This is probably the logical leap I needed!
Theo Platt
04/20/2023, 9:26 PM
@Zanie Do you have a fuller example? I'm still a little lost as how to authenticate etc
z
Zanie
04/20/2023, 9:41 PM
You can login with
prefect cloud login
— the variables needed for authentication in other contexts can then be viewed with
prefect config view
(the API URL and API KEY are the relevant ones).
You don’t need to provide a client manually to
run_deployment
it’ll read settings from the environment.
Zanie
04/20/2023, 9:42 PM
Then you’d just give a name i.e. if you’d run
prefect deployment run hello/test
you’d do
run_deployment(name="hello/test")
t
Theo Platt
04/20/2023, 9:43 PM
Oh right - so if I have the API URL and API KEY as environment variables in my (in this case) AWS lambda function, the run_deployment will pick up on those?
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.