Hi, I'm very new to Prefect and trying to get some...
# prefect-community
s
Hi, I'm very new to Prefect and trying to get some examples up and running. i've managed to successfully run my workflow locally by just executing the python scripts containing my flow using flow.run(). I've also managed to set up server running on my machine and have registered my flow using flow.register(). When I try to execute in my local UI it gives me a 'module not found error' understandably as my flow is dependent on other classes and I have created. I can successfully get a simple example that doesn't reference other modules running so have ruled that out. I've found other threads here advising that my
Flow
needs a
storage
keyword and that storage needs to create a
Docker
instance with a
dockerfile
keyword. I have tried this on a very basic example passing a dockerfile and I keep getting the same error
500 Server Error: Internal Server Error ("Cannot locate specified Dockerfile: .\tmp64wpj0sv\Dockerfile")
after I execute flow.register() Simple example was taken from tutorial and my dockerfile is located in the same location (note i'm pretty certain it can find the file as I get a different error message if the file can't actually be located)
import prefect
from prefect import task, Flow
from prefect.environments.storage import Docker
@task
def hello_task():
    
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("Hello, Cloud!")
flow = Flow("hello-flow", tasks=[hello_task])
flow.storage = Docker(dockerfile = 'Dockerfile')
flow.register(project_name="hello-flow")
Dockerfile content:
FROM ubuntu:18.04
Any assistance on how I should actually be specifying my dockerfile to add the required modules to my actual workflow is appreciated Thanks
n
Hi @Sanjay Patel and welcome to Prefect! 👋 You should be able to remove
dockerfile = 'Dockerfile'
from your code and this should build in a tmp directory locally.
s
Thanks @nicholas. that particular example now executes and registers flow and creates a docker image for me. however I'm unsure how to determine whether the Dockerfile in that same location is actually being used. It doesn't appear so when I check the history of docker image. While this particular example works OK, my more complicated workflow still fails the healthcheck (it could very well be an issue with my Dockerfile but do want to ensure the Dockerfile I've created is being used before I dig into that). Thanks!
@Laura Lorenz (she/her) and @nicholas - thanks so much for your help today on the call. I managed to get this working. I removed all relative imports that weren't actually being used from the file. There must have been one that was causing concern (i'll work that out later). For reference is there is anyone else running into the same problems, Laura and Nicholas advised that failing the health check when trying to
register()
the flow using a Docker container was one issue (giving the module not found error) and the other issue was if it successfully registers, but fails with a 'module not found' error when running through the UI / CLI then it's a different issue with environments