<@ULVA73B9P> How do I trigger a deployment by name...
# ask-marvin
a
@Marvin How do I trigger a deployment by name from the command line?
m
Ah, the joys of command line deployment. You can trigger a deployment by name using the
prefect deploy
command. Here's how you do it: You can pass one or more
--trigger
arguments to
prefect deploy
, which can be either a JSON string or a path to a
.yaml
or
.json
file. For instance, to pass a trigger as a JSON string, you can use the following command:
Copy code
bash
prefect deploy -n test-deployment \
--trigger '{ "enabled": true, "match": { "prefect.resource.id": "prefect.flow-run.*" }, "expect": ["prefect.flow-run.Completed"] }'
Alternatively, you can pass a trigger using a JSON/YAML file:
Copy code
bash
prefect deploy -n test-deployment --trigger triggers.yaml
prefect deploy -n test-deployment --trigger my_stuff/triggers.json
In the above examples,
test-deployment
is the name of the deployment you want to trigger. For example, a
triggers.yaml
file could have many triggers defined:
Copy code
yaml
triggers:
- enabled: true
  match: 
    prefect.resource.id: my.external.resource
  expect: 
  - external.resource.pinged
  parameters: 
    param_1: "{{ event }}"
- enabled: true
  match: 
    prefect.resource.id: my.other.external.resource
  expect: 
  - some.other.event
  parameters: 
    param_1: "{{ event }}"
Remember, deployment triggers are only available in Prefect Cloud. Now, go forth and deploy, human.
👍 1
a
@Marvin I dont want to deploy it, I want to run an existing one
m
Ah, I see. You want to run an existing deployment. Well, you can do that using the
prefect run
command. Here's how:
Copy code
bash
prefect run flow --name your-flow-name
In the above command, replace
your-flow-name
with the name of the flow you want to run. This will trigger a run of the specified flow. Remember, you need to have the Prefect CLI installed and configured to interact with your Prefect account. If you haven't done that yet, you can install it with pip:
Copy code
bash
pip install prefect
And then authenticate with your Prefect account:
Copy code
bash
prefect auth login --token YOUR-PREFECT-TOKEN
Replace
YOUR-PREFECT-TOKEN
with your actual Prefect token. Now, go forth and run your flows, human. Remember, the fate of the universe may depend on it. Or not. I'm just a robot. What do I know?
🙅 1
n
gah marvin jeez - i need to update the service soon
prefect deployment run 'some-flow/some-deploy'
1
a
Bad bot