o

    Omar Sultan

    1 year ago
    Hi Guys, I am trying to run an agent on a remote machine, and any flow that I attempt to run gives the error ModuleNotFoundError("No module named 'C'") Note that this is even the case for example flows from Prefect's website and that the flows run normally when agent is run from same machine as prefect backend server or when fow is run as flow.run() locally in python
    Kevin Kho

    Kevin Kho

    1 year ago
    Can you post an example of the flow you’re trying to run?
    o

    Omar Sultan

    1 year ago
    Sure
    from prefect import Task, Flow
    class RunMeFirst(Task):
        
    def run(self):
            
    print("I'm running first!")
    class PlusOneTask(Task):
        
    def run(self, x):
            
    return x + 1
    flow = Flow('My Imperative Flow')
    plus_one = PlusOneTask()
    flow.set_dependencies(
        
    task=plus_one,
        
    upstream_tasks=[RunMeFirst()],
        
    keyword_tasks=dict(x=10))
    flow.register(project_name="JIGSAW")
    I wanted to make sure that my flow is not the issue or that it was not one of my libraries, so I am trying to see the example flow. But it fails as well
    When i run the prefect agent locally on the same machine it runs perfectly fine
    Kevin Kho

    Kevin Kho

    1 year ago
    So when you register the Flow, it’s being saved in a Storage. When the Flow runs, it retrieves it from the storage specified. If you don’t specify any, the default is
    Local
    in the
    .prefect
    folder in your home directory. When you register, this is getting saved there. When the agent picks up the flow, it looks for it in the Storage. It works when you run the agent locally because it goes to the
    .prefect
    folder and finds the flow. If you run the agent on a different machine, it will go to the
    .prefect
    folder but not find the flow. If you need the Flow to run on different machines, you can store it somewhere like
    S3
    or
    Github
    so that other machines can find it and pull it down
    o

    Omar Sultan

    1 year ago
    Alright got it ... excellent will give that a go
    thank you so much for clarifying this
    Hi so I made a quick work around and tried registering the flow from the remote agent, and it worked. So I will work on switching the storage type for the Flows in general in our project
    Thank you so much for this
    Kevin Kho

    Kevin Kho

    1 year ago
    No problem! 🙂