Hello! I am trying Prefect2.0 for a simple flow fr...
# prefect-community
r
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
This context should be initialized when prefect is imported.
Can you share a minimal example?
r
I’m trying to create a flow on a request-response based system
A flow function is triggered by a client request
k
Hey @R, do you have code you can share so we can get a better idea of what you’re trying to do?
r
Unfortunately I cannot share it. Could you please help me understand if I can manually initialise this context inside my Python code?
k
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
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
I tried importing inside the function where the flow is called
That didn’t work either
z
You could use
with prefect.context.use_profile("default"): …
You’ll need to give us more information for us to help further
r
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
You need to point the API to the Orion API, and as long as it can connect, it should work
r
Could you please share an example for this?
k
It should be something like this. Specifially the API_URL for inside the Docker image.
r
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
Yes you can on localhost. That is the default.
r
Is there a manual I can refer to for starting Orion from a docker-compose container and accessing UI from local host?
k
this is community contributed. maybe you can check it?
r
Thanks! Is there any possibility of official tutorials on this soon?
k
I think that is being taken and adopted with permission from the repo owner, so it’s in progress
r
Great, thank you so much