Hi everyone, I’m currently using the `flow.registe...
# ask-community
f
Hi everyone, I’m currently using the
flow.register()
method to register flows, I also set the flows’ run config and storage along with that:
Copy code
flow.run_config = (some run config)
flow.storage = (some storage config)
flow.register(project_name=(project name))
I’d like to switch to using the prefect cli’s register functionality. How can I point it to the run config and storage?
k
Hey @Fina Silva-Santisteban, if you take out
flow.register()
from that script and use the CLI to register, it will pick up those
run_config
and
storage
defined in the script. Are you not seeing this behavior?
🤔 1
f
@Kevin Kho that’s right, I didn’t see that behavior! The flow didn’t have any config, not even a label.
@Kevin Kho do they need to be in the same file as where the flow is defined? (It’s currently in separate files)
k
RunConfig Executors and Results have to be in the same file yes. I think Storage should not have to be. This is because the serialized Flow does not hold the RunConfig Executors and Results as that may contain sensitive information.
💡 1
Copy code
from prefect.utilities.storage import extract_flow_from_file
def test_flow(file):
    file_path = os.path.abspath(file)
    flow = extract_flow_from_file(file_path=file_path)
    flow.storage = SomeStorage()
    flow.run_config = Run()
    flow.register("xxx")
The Storage gets applied but RunConfig doesn’t in this case. I am sure about the RunConfig but less sure about the Storage
f
@Kevin Kho thank you! I’ll give that a try and let you know how that worked out!
k
My bad. RunConfig is part of the schema. Executors and Results are not **
f
@Kevin Kho having storage and run config declared in the same file where the flow declaration lives fixed the problem! Thanks so much!
👍 1