<@ULVA73B9P> is it possible to `prefect deploy` m...
# ask-marvin
h
@Marvin is it possible to
prefect deploy
multiple deployments defined in prefect.yaml that share certain tags. Something like prefect deploy --all but with another condition to only apply this for tags of ABC
m
thought for 169.8 seconds
Short answer: not by tags. In Prefect 3.x,
prefect deploy
can: - deploy all deployments in your
prefect.yaml
(
--deploy-all
), and - deploy a subset by name using patterns with
--name/-n
. It does not have a flag to filter which deployments to deploy by tags. The
--tags
option sets/overrides tags on the deployments being created; it does not filter selection. What you can do: - If your deployment names share a common token, use a name pattern:
Copy code
prefect deploy --name "my-flow/ABC-*"
or
Copy code
prefect deploy -n "ABC-*"
The
--name
flag supports patterns; examples in the help include things like
my-deployment-*
and
*-flow-name/deployment-*
. - If you must filter by tags, use a small one-liner (requires yq) to read
prefect.yaml
and deploy only those with tag ABC:
Copy code
yq -r '.deployments[] | select(.tags[]? == "ABC") | .name' prefect.yaml | xargs -I{} prefect deploy -n {}
Or a quick Python script to parse
prefect.yaml
and call
prefect deploy -n ...
for matching names. References: - prefect.yaml guide - prefect deploy CLI reference If you can share how your deployments are named, I can suggest a
--name
pattern that matches your “ABC” set.
h
@Marvin how to deploy all deployments that have a name which starts with
kl_
m
thought for 30.9 seconds
Yes — use a name pattern with
prefect deploy
. If the deployment names in your prefect.yaml start with `kl_`:
Copy code
prefect deploy --name "kl_*"
If you want to match deployment names that start with
kl_
regardless of flow:
Copy code
prefect deploy --name "*/kl_*"
If instead your flow names start with
kl_
and you want all their deployments:
Copy code
prefect deploy --name "kl_*/*"
Notes: - Quote the pattern so your shell doesn’t expand it. - Run from your project root (where
prefect.yaml
lives). Docs: - prefect.yaml guide - prefect deploy CLI reference
h
@Marvin what about running deployments in a similar way? can this be triggered from the CLI? Based on names for example with a pattern
m
thought for 80.6 seconds
Short answer: there isn’t a built-in pattern flag for running multiple deployments.
prefect deployment run
takes a single deployment name (or id) at a time. Workable CLI approaches: - Bash/zsh (runs each deployment whose name ends with /kl_*):
Copy code
prefect deployment ls \
  | awk 'NR>2 && $1 ~ /\/kl_/ { print $1 }' \
  | xargs -n1 -I{} prefect deployment run {}
- PowerShell:
Copy code
prefect deployment ls `
| Select-String -Pattern '/kl_' `
| ForEach-Object {
  $name = ($_ -split '\s+')[0]
  prefect deployment run $name
}
Notes: - The first column of
prefect deployment ls
is the deployment’s full name
<FLOW_NAME>/<DEPLOYMENT_NAME>
. We filter rows where the deployment part starts with
kl_
. - Add
--watch
,
--start-in
,
--start-at
, or
-p key=value
to each
prefect deployment run
if needed, e.g.:
Copy code
... | xargs -n1 -I{} prefect deployment run {} --watch
Docs: - Deployment CLI reference - prefect.yaml guide If you prefer a more robust approach (avoiding parsing
ls
output), I can share a tiny Python snippet that queries deployments via the API and triggers runs for those with names matching
*/kl_*
.