https://prefect.io logo
#prefect-community
Title
# prefect-community
r

R

06/15/2022, 7:00 PM
Hello! I am trying Prefect2.0 for a simple flow from a docker container. I am getting an error and am stuck trying to resolve it - MissingContextError (“No settings context found”) Is there an explicit initial config required? Can I run flows from within a container? Any help would be really appreciated! Thanks!
z

Zanie

06/15/2022, 7:08 PM
This context should be initialized when prefect is imported.
Can you share a minimal example?
r

R

06/15/2022, 7:22 PM
I’m trying to create a flow on a request-response based system
A flow function is triggered by a client request
k

Kevin Kho

06/15/2022, 7:32 PM
Hey @R, do you have code you can share so we can get a better idea of what you’re trying to do?
r

R

06/15/2022, 8:44 PM
Unfortunately I cannot share it. Could you please help me understand if I can manually initialise this context inside my Python code?
k

Kevin Kho

06/15/2022, 8:49 PM
This works:
Copy code
from prefect import flow, task
from prefect.context import get_run_context

@flow
def test():
    ctx = get_run_context()
    print(ctx.flow_run.expected_start_time)

test()
z

Zanie

06/15/2022, 9:06 PM
Is the flow function being called from a different thread than the thread or async context than where prefect is imported?
Can you share the full traceback?
r

R

06/15/2022, 9:08 PM
I tried importing inside the function where the flow is called
That didn’t work either
z

Zanie

06/15/2022, 10:18 PM
You could use
with prefect.context.use_profile("default"): …
You’ll need to give us more information for us to help further
r

R

06/16/2022, 2:28 PM
This worked, thank you so much!
Also, could you please suggest if it’s possible to use the Dashboard (UI) if I trigger a flow from a docker container using prefect 2.0?
k

Kevin Kho

06/16/2022, 2:30 PM
You need to point the API to the Orion API, and as long as it can connect, it should work
r

R

06/16/2022, 2:31 PM
Could you please share an example for this?
k

Kevin Kho

06/16/2022, 2:33 PM
It should be something like this. Specifially the API_URL for inside the Docker image.
r

R

06/17/2022, 9:13 PM
Hey @Kevin Kho , thanks for sharing this. But I am not using any cloud provider. Can I run the UI on local host?
I am running a flow inside docker compose setup
k

Kevin Kho

06/17/2022, 10:27 PM
Yes you can on localhost. That is the default.
r

R

06/17/2022, 10:30 PM
Is there a manual I can refer to for starting Orion from a docker-compose container and accessing UI from local host?
k

Kevin Kho

06/17/2022, 10:32 PM
this is community contributed. maybe you can check it?
r

R

06/17/2022, 10:34 PM
Thanks! Is there any possibility of official tutorials on this soon?
k

Kevin Kho

06/17/2022, 10:36 PM
I think that is being taken and adopted with permission from the repo owner, so it’s in progress
r

R

06/17/2022, 10:37 PM
Great, thank you so much
11 Views