https://prefect.io logo
Title
y

YD

01/07/2023, 8:57 PM
Having issues deploying on Prefect 2.0
$ prefect version
Version:             2.7.7
API version:         0.8.4
Python version:      3.8.10
Git commit:          e8ca30b8
Built:               Fri, Jan 6, 2023 4:25 PM
OS/Arch:             linux/aarch64
Profile:             default
Server type:         cloud
Error:
$ prefect deployment apply run_collect_stocks_data-deployment.yaml
Successfully loaded 'yquark_deployment'
Traceback (most recent call last):
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/home/youval/.local/lib/python3.8/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/home/youval/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/youval/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/cli/deployment.py", line 594, in apply
    deployment_id = await deployment.apply()
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/deployments.py", line 633, in apply
    deployment_id = await client.create_deployment(
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/client/orion.py", line 1313, in create_deployment
    response = await <http://self._client.post|self._client.post>(
  File "/home/youval/.local/lib/python3.8/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
  File "/home/youval/.local/lib/python3.8/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/home/youval/.local/lib/python3.8/site-packages/prefect/client/base.py", line 251, in send
    response.raise_for_status()
  File "/home/youval/.local/lib/python3.8/site-packages/httpx/_models.py", line 745, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url '<https://api.prefect.cloud/api/accounts>
in the UI [Work Queues] Status is Healthy and
$ jobs
[1]+  Running                 nohup prefect agent start -q 'aws2' > ~/tmp/prefect_agent.log &  (wd: ~)
n

Nate

01/07/2023, 11:57 PM
Hi @YD - I would guess something unexpected is in the deployment definition, did you alter the
run_collect_stocks_data-deployment.yaml
file directly or are you just applying what the build command produced?
y

YD

01/08/2023, 1:00 AM
yes..
prefect deployment build ../weekly_data_collection_only.py:run_collect_stocks_data -q aws2 --tag AWS --name yquark_deployment --skip-upload
prefect deployment apply run_collect_stocks_data-deployment.yaml
I’ll try to delete and recreate the YAML file
I deleted the YAML and run again both commands, but got the same error
n

Nate

01/08/2023, 1:08 AM
hmm - okay. I’m currently on mobile but will try to help you resolve when I’m back at my machine
👍 1
a

Andrew Huang

01/08/2023, 1:09 AM
I don’t think the name should have underscore; can you try
yquark-deployment
y

YD

01/08/2023, 1:13 AM
$ rm run_collect_stocks_data-deployment.yaml
$ prefect deployment build ../weekly_data_collection_only.py:run_collect_stocks_data -q aws2 --tag AWS --name yquark_deployment --skip-upload
Found flow 'Weekly data collection only'
Deployment YAML created at '.../run_collect_stocks_data-deployment.yaml'.

$ prefect deployment apply run_collect_stocks_data-deployment.yaml
Successfully loaded 'yquark_deployment'
Traceback (most recent call last):
  File "/home/youval/.local/lib/python3.8/site-
...  
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url '<https://api.prefect.cloud/api/accounts>
a

Andrew Huang

01/08/2023, 1:14 AM
--name yquark_deployment
to clarify, can you replace the underscore with hyphen?
y

YD

01/08/2023, 1:23 AM
I’ll replace with
"yquark-deployment"
and try again
$ rm run_collect_stocks_data-deployment.yaml
$ prefect deployment build ../weekly_data_collection_only.py:run_collect_stocks_data -q aws2 --tag AWS --name "yquark-deployment" --skip-upload

Found flow 'Weekly data collection only'
Deployment YAML created at '.../run_collect_stocks_data-deployment.yaml'.

$ prefect deployment apply run_collect_stocks_data-deployment.yaml
Successfully loaded 'yquark-deployment'
Traceback (most recent call last):
  File "~/.local/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "~/.local/lib/python3.8/site-packages/prefect/utilities/asyncutils.py"
I also tried replacing to
--name yquark
but this did not help either
I went to an older version
$ pip3 install -U prefect==2.7.6
and run the same commands and it worked fine so I think the issue is with the 2.7.7 version
mind you… I still have to edit the YAML
edpoint
path for the deployment to run
j

Jeff Hale

01/08/2023, 2:30 AM
I am able to reproduce on 2.7.7 with Prefect Cloud
(zoom) jeffhale demos/docker $ prefect deployment build flows/flows.py:do -n dockt -ib docker-container/doit  -a
Found flow 'do'
Deployment YAML created at 
'/Users/jeffhale/Desktop/prefect/demos/docker/do-deployment.yaml'.
Deployment storage None does not have upload capabilities; no files 
uploaded.  Pass --skip-upload to suppress this warning.
Traceback (most recent call last):
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/utilities/asyncutils.py", line 230, in coroutine_wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/utilities/asyncutils.py", line 181, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/cli/deployment.py", line 966, in build
    deployment_id = await deployment.apply()
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/deployments.py", line 633, in apply
    deployment_id = await client.create_deployment(
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/client/orion.py", line 1313, in create_deployment
    response = await <http://self._client.post|self._client.post>(
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/httpx/_client.py", line 1533, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/prefect/client/base.py", line 251, in send
    response.raise_for_status()
  File "/Users/jeffhale/miniforge3/envs/zoom/lib/python3.9/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '422 Unprocessable Entity' for url '<https://api.prefect.cloud/api/accounts/cbad165a-7057-416a-bb31-a0aab3f1d0cf/workspaces/a575bdc0-4dcc-4ad4-b286-3639c7077307/deployments/>'
For more information check: <https://httpstatuses.com/422>
(zoom) jeffhale demos/docker $ prefect version
Version:             2.7.7
API version:         0.8.4
Python version:      3.9.15
Git commit:          e8ca30b8
Built:               Fri, Jan 6, 2023 4:25 PM
OS/Arch:             darwin/arm64
Profile:             jeffmshale
Server type:         cloud
I had just authenticated through the CLI -> UI. Also tried creating API key in UI and saving to profile.
n

Nate

01/08/2023, 4:34 AM
Thanks for raising @YD - we've rolled out a fix to Prefect Cloud, you should be able to deploy using 2.7.7 now let us know if the problem persists!
🙌 2
👍 1