PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
16.06k stars 1.57k forks source link

Applying a deployment to Prefect Cloud with 2.7.4-2.7.6 leads to a 422 Error #8102

Closed discdiver closed 1 year ago

discdiver commented 1 year ago

First check

Bug summary

Applying a deployment to Prefect Cloud with 2.7.6 leads to a 422 Error.

This error appears to only affect 2.7.4-2.7.6.- edited.

If this error is affecting you, you can upgrade to 2.7.7 with pip install prefect -U

Reproduction

from prefect import flow

@flow
def hi():
    print("hi")

prefect deployment build flows.py:hi -n sev-six -a

Error

(sev-six) jeffhale prefect/demos $ prefect deployment build flows.py:hi -n sev-six -a
Found flow 'hi'
Default '.prefectignore' file written to /Users/jeffhale/Desktop/prefect/demos/.prefectignore
Deployment YAML created at '/Users/jeffhale/Desktop/prefect/demos/hi-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/sev-six/lib/python3.11/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/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/sev-six/lib/python3.11/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/sev-six/lib/python3.11/site-packages/anyio/_core/_eventloop.py", line 70, in run
    return asynclib.run(func, *args, **backend_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 292, in run
    return native_run(wrapper(), debug=debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
    return await func(*args)
           ^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/prefect/cli/deployment.py", line 966, in build
    deployment_id = await deployment.apply()
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/prefect/deployments.py", line 631, in apply
    deployment_id = await client.create_deployment(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/prefect/client/orion.py", line 1277, in create_deployment
    response = await self._client.post(
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/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/sev-six/lib/python3.11/site-packages/prefect/client/base.py", line 251, in send
    response.raise_for_status()
  File "/Users/jeffhale/miniforge3/envs/sev-six/lib/python3.11/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

### Versions

```Text
Happens with 2.7.6 when try to apply to Prefect Cloud

Does not happen with 2.7.3, 2.7.0.

(sev-six) jeffhale prefect/demos $ prefect version
Version:             2.7.6
API version:         0.8.4
Python version:      3.11.0
Git commit:          528c8300
Built:               Wed, Jan 4, 2023 5:27 PM
OS/Arch:             darwin/arm64
Profile:             jeffmshale
Server type:         cloud

(sev-six) jeffhale prefect/



### Additional context

_No response_
cwhatley commented 1 year ago

I had the same with a deployment using 2.7.4 today and upgraded to 2.7.7 to get it to work.

trahloff commented 1 year ago

Can confirm, this also impacts our setup

amitlissack commented 1 year ago

Also affecting our setup using prefect==2.7.5

peytonrunyan commented 1 year ago

Addressed by https://github.com/PrefectHQ/prefect/pull/8107 and a separate cloud release.