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

Shivam Bhatia

07/05/2022, 5:42 AM
Hi, I am trying to self host prefect 2.0 on a gcp cloud engine vm. I have installed prefect on the vm and set PREFECT_API_URL as "http//<external ip>4200/api" I tried to connect to the prefect instance from my local machine by setting the PREFECT_API_URL on my machine and running this code:
Copy code
$ # start python REPL with native await functionality
$ python -m asyncio
>>> from prefect.client import get_client
>>> async with get_client() as client:
...     response = await client.hello()
...     print(response.json())
šŸ‘‹
and I got this error:
Copy code
Traceback (most recent call last):
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "<console>", line 1, in <module>
  File "/home/shivam/.local/lib/python3.9/site-packages/prefect/client.py", line 111, in get_client
    ctx = prefect.context.get_settings_context()
  File "/home/shivam/.local/lib/python3.9/site-packages/prefect/context.py", line 272, in get_settings_context
    raise MissingContextError("No settings context found.")
prefect.exceptions.MissingContextError: No settings context found.
Am I missing something in the setup?
āœ… 1
m

Mathijs Carlu

07/05/2022, 7:24 AM
Did you set PREFECT_API_URL by executing
prefect config set PREFECT_API_URL="http://<external-ip>:4200/api"
?
šŸ’Æ 1
s

Shivam Bhatia

07/05/2022, 7:27 AM
Yes, on my local machine
m

Mathijs Carlu

07/05/2022, 7:28 AM
what is the output of
prefect config view
?
s

Shivam Bhatia

07/05/2022, 7:31 AM
Copy code
PREFECT_PROFILE='default'
PREFECT_API_URL='http://<external-ip>:4200/api' (from profile)
m

Mathijs Carlu

07/05/2022, 7:47 AM
Was able to recreate the issue on Windows. I think there might still be some bugs on Windows, as there was initially no support. Instead of
get_client()
, you could use
OrionClient('http://<external-ip>:4200/api')
. This seems to work on my machine
a

Anna Geller

07/05/2022, 11:02 AM
I don't know how to help here - can you perhaps try Cloud 2.0 first before self-hosting? this guide will help you get started https://discourse.prefect.io/t/how-to-get-started-with-prefect-cloud-2-0/539
m

Mathijs Carlu

07/05/2022, 11:16 AM
@Anna Geller the problem seems to be that the settings_context cannot be found when running
python -m asyncio
from the terminal. I was able to recreate on both windows and linux
a

Anna Geller

07/05/2022, 11:20 AM
if you believe there is a bug here, please open a GitHub issue here https://github.com/PrefectHQ/prefect/issues/new/choose and choose 2.0
4 Views