Gio
06/08/2024, 2:52 PMMY_SECRET_KEY
is rendering as a string - {{ prefect.secret('MY_SECRET_KEY') }}
. Is it possible to get the rendered prefect secret in a deployment?
deployment = Deployment.build_from_flow(
flow=my_flow,
name="my-flow-deployment",
infrastructure=docker_infrastructure,
work_pool_name="my-docker-pool",
job_variables={
"env": {
"MY_SECRET_KEY": "{{ prefect.secret('MY_SECRET_KEY') }}"
}
}
)
benorbital
06/08/2024, 4:28 PM{{...}}
syntax is just for yaml deployments?
As you are deploying from python code, you probably don't want thembenorbital
06/08/2024, 4:31 PMGio
06/08/2024, 6:30 PMNate
06/08/2024, 11:08 PMbuild_from_flow
is old syntax for use with agents and infra blocks (deprecated). you'll want to use some_flow.deploy()
as outlined here
you can create the work pool either:
• in the UI
• by simply running prefect worker start --type docker --pool some-new-pool
and we'll create a default work pool of that typeGio
06/08/2024, 11:13 PM.deploy()
I was copying that the the ask-mavin channel.
For the work pool, I'm wondering if there is a way to use prefect Secrets in the work pool, so I'm not hardcoding them. Is this possible?Nate
06/08/2024, 11:29 PMfrom prefect import flow
flow.from_source(
source="<https://gist.github.com/1672b241f7ae3e3a3ff970a07dfcf82d.git>",
entrypoint="job_vars.py:my_flow",
).deploy( # type: ignore
name="test",
work_pool_name="local",
job_variables=dict(env=dict(some_secret="{{ prefect.blocks.secret.very-secret }}")),
)
Nate
06/08/2024, 11:29 PMNate
06/08/2024, 11:30 PMvery-secret
assigned to value
Gio
06/08/2024, 11:34 PMNate
06/08/2024, 11:37 PMwould it work to use this same syntax in the work pool Environment Variables?hm im not sure i know what you mean, but all
job_variables
for a given work pool are jinja template-able from block / variables like this. the above overrides the env
job variable for this deployment specifically, but you can alter the whole template in the advanced tab of the work pool to apply defaults to all deployments using this work pool
docs on thisGio
06/08/2024, 11:45 PMBring 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.
Powered by