Hey everyone I am wondering is there a way to keep...
# ask-community
r
Hey everyone I am wondering is there a way to keep versioning in prefect limited to when actual changes are made in the code not every-time a flow is registered? an example is I have a flow factory and anytime I add a new flow I just register the flow factory this creates a new versions for all my flows but none of the code has changed.
I looked into some sort of Idempotency key but what is in the docs at least from reading it is not what I am looking for.
k
What does adding a new Flow mean here? Do you just register it under a different name?
Copy code
with Flow(..) as flow:
  ...

flow.register("A")
flow.register("B")
r
Good question essentially yes but I have a loop that reads through a directory of configs that creates a flow for each config.yml file. So Instead having to write new code I just add a new config file that utilizes the base code and creates a unique flow for each configuration
k
What did you try with the idempotency key?
r
Nothing yet was curious if I am going towards the right path. I can try it out and follow up later if it worked out for me
k
Ah ok so if you do
prefect register someflow.py
from the CLI, it checks for changes and if there are none, it will not register. It does this check here. So basically it creates an idempotency key which is a serialized version of the Flow. If the flow changes, this hash will change. Otherwise the hash will remain the same and the flow won’t register. I would try adding this as your idempotency key.
🙌 1
r
Ah thank you Kevin I appreciate the help!
k
of course. note that if you edit a task but don’t change the structure of the DAG, the hash will remain the same
You can test this behavior by using the CLI. In this case, users need to use the
--force
flag which registers without the idempotency key to force the registration