Hi All, is anyone using Module storage option?
# ask-community
m
Hi All, is anyone using Module storage option?
k
Hi @Milly gupta! What question do you have about model storage?
I read you other thread asking for a working example. I provided one here
m
Thanks @Kevin Kho. I am looking for working examples as documentation doesn't explain much
Copy code
So I have created test_module.py from prefect import task, Flow
from prefect.storage import Module
@task
def say_hello():
    print("hello world")
flow = Flow("hello-flow")
flow.storage = Module("test_module")
flow.storage.add_flow(flow)
flow.add_task(say_hello)
and a separate script to register
Copy code
from test_module import flow
flow.run_config = LocalRun(labels=["mg-test"])
flow.register(project_name="CDP")
So this work but wondering if it's the right way
f
biggest problem I ran into was that the module storage needs the code to be installed as a package in the environment.
k
I believe this will work but just a couple of comments. First is that while this is right, we recommend the functional API.
with Flow("") as flow:
and then putting the tasks underneath. Second is that you can just have
flow.register
at the end of the file, but I think for ModuleStorage, it normally makes sense to have Flows inside a folder and register those flows all at once with the command line like in the previous linked thread. I believe this will all work though.
Thank you for the reminder @Florian Kühnlenz!
@Marvin open “Docs around ModuleStorage Need More Details on Usage”
m
yeah thanks @Florian Kühnlenz. That's the intention to use packages eventually
@Kevin Kho Yeah we use functional API, this is just a test example to understand module storage