Lavanya
06/26/2023, 7:32 PMprefect cloud login --key "$PREFECT_TOKEN" --workspace "$PREFECT_WORKSPACE"
echo "Done configuring Prefect CLI." Prefect Cloud ENABLED...
Successfully parsed PREFECT_TOKEN (not displayed)
Configuring Prefect2 CLI... I get the following httpx connection timeout error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/asyncio.py", line 114, in
connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.8/site-packages/anyio/_core/_sockets.py", line 192, in connect_tcp
gai_res = await getaddrinfo(
File "/usr/local/lib/python3.8/site-packages/anyio/_core/_sockets.py", line 511, in getaddrinfo
gai_res = await get_asynclib().getaddrinfo(
File "/usr/local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 1690, in
getaddrinfo
result = await get_running_loop().getaddrinfo(
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
return await self.run_in_executor(
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/asyncio.py", line 121, in
connect_tcp
stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover File "/usr/local/lib/python3.8/site-packages/anyio/_core/_tasks.py", line 119, in exit
raise TimeoutError
TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 353, in
handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 261, in handle_async_request
raise exc
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 92, in
handle_async_request
raise exc
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 69, in
handle_async_request
stream = await self._connect(request)
File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 117, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/auto.py", line 31, in connect_tcp
return await self._backend.connect_tcp(
File "/usr/local/lib/python3.8/site-packages/httpcore/backends/asyncio.py", line 121, in
connect_tcp
stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover File "/usr/local/lib/python3.8/contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.8/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 260,
in coroutine_wrapper
return call()
File "/usr/local/lib/python3.8/site-packages/prefect/_internal/concurrency/calls.py", line 245, in call
return self.result()
File "/usr/local/lib/python3.8/site-packages/prefect/_internal/concurrency/calls.py", line 173, in result
return self.future.result(timeout=timeout)
File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 437, in result
return self.__get_result()
File "/usr/local/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/usr/local/lib/python3.8/site-packages/prefect/_internal/concurrency/calls.py", line 218, in _run_async
result = await coro
File "/usr/local/lib/python3.8/site-packages/prefect/cli/cloud.py", line 391, in login
workspaces = await client.read_workspaces()
File "/usr/local/lib/python3.8/site-packages/prefect/client/cloud.py", line 72, in read_workspaces
return pydantic.parse_obj_as(List[Workspace], await self.get("/me/workspaces"))
File "/usr/local/lib/python3.8/site-packages/prefect/client/cloud.py", line 92, in get
res = await self._client.get(route, **kwargs)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1757, in get
return await self.request(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1617, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 353, in
handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.8/contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.8/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectTimeout
An exception occurred.
Failed to register flows
At C\WorkProject\dbt CustomerInsights LifeSciences\deploy\deploy dockerfile dev.ps161
char:27
+ if (-not $?) {throw "Failed to register flows"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Failed to register flows:String) [], Run
timeException
+ FullyQualifiedErrorId : Failed to register flows
[3:51 PM] However, if I run the same command in the same powershell terminal with the actual token and workspace, it is connecting to prefect cloud without any issues. prefect cloud login --key "$PREFECT_TOKEN" --workspace "$PREFECT_WORKSPACE"
[3:52 PM] Can you please help me with this connection timeout issue? Using Python 3.8, Prefect 2.0 cloud
[3:53 PM] I do run this in my venv.
[2:58 PM] Can you please suggest some fixes for this httpx connection timeout error?Nate
06/26/2023, 7:44 PMLavanya
06/26/2023, 9:33 PMChristopher Boyd
06/27/2023, 12:25 AM[Environment]::SetEnvironmentVariable("PREFECT_API_KEY", "<>", "User")
Lavanya
06/27/2023, 9:35 PMNate
06/27/2023, 11:09 PMyou can just set / export the API key and API url without an actual login to the same effectas chris mentioned, I think you probably don't need to run a script to do a login at all. you just need to set 2 environment variables: • PREFECT_API_KEY • PREFECT_API_URL any subsequent prefect operations will find and use these credentials to communicate with whatever workspace is indicated by the API URL you set
Christopher Boyd
06/28/2023, 2:01 PMexport PREFECT_API_KEY=<value>
and same for API_URL