https://prefect.io logo
Title
g

Giacomo Chiarella

04/21/2023, 1:23 PM
Hi everyone! I have a flow which I want to deploy multiple times with different parameters. The only problem is that I want some parameters to be not modifiable when a user does a custom run. How can I achieve this?
1
f

flapili

04/21/2023, 1:26 PM
not sure it's possible
you could retreive their parameters from a database instead
hard to give more advise without knowledge of the usecase & minimal code of example
😅
g

Giacomo Chiarella

04/21/2023, 1:28 PM
it could be also a python dictionary, the only problem is
how to identify the deployment which triggered the flow?
If I know if I could implement the logic and even avoid to present these parameters in the ui
f

flapili

04/21/2023, 1:29 PM
never tried by you could use the context
g

Giacomo Chiarella

04/21/2023, 1:29 PM
yeah, I will look at it
f

flapili

04/21/2023, 1:39 PM
from prefect import flow
from prefect.context import get_run_context


@flow
def main():
    ctx = get_run_context()
    print(ctx.flow_run.deployment_id)
🙌 1
it should do the tricks
g

Giacomo Chiarella

04/21/2023, 1:42 PM
get_run_logger().info(get_client().read_deployment(FlowRunContext.get().flow_run.deployment_id).name)
I found it! Thanks!
f

flapili

04/21/2023, 1:43 PM
else pernaps you can store some args as infra args ?
(I never used infra args so idk)
g

Giacomo Chiarella

04/21/2023, 1:44 PM
they are not sensitive, they can be also in the code. Anyway, there are also variables in Prefect which can be used to store parameters that every deployment can read
f

flapili

04/21/2023, 1:45 PM
it could be a solution, or not 😅
only you know the needs and constraints :
g

Giacomo Chiarella

04/21/2023, 1:46 PM
ahah yeah 😉