Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK - Run deployment fails unless flow imported #16109

Open
Chris-Perkins opened this issue Nov 25, 2024 · 0 comments
Open

SDK - Run deployment fails unless flow imported #16109

Chris-Perkins opened this issue Nov 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Chris-Perkins
Copy link

Chris-Perkins commented Nov 25, 2024

Bug summary

Prefect fails to execute run_deployment if flow is not imported. The following pydantic error is raised:
State is not fully defined; you should define all referenced types, then call State.model_rebuild()

This code fails:

from prefect.deployments import run_deployment

run_deployment(name="<Deployment Name>", timeout=0)

But this code succeeds:

from prefect.deployments import run_deployment
from prefect import flow # NEW!

run_deployment(name="<Deployment Name>", timeout=0)

Version info

Version:             3.1.4
API version:         0.8.4
Python version:      3.11.4
Git commit:          78ee41cb
Built:               Wed, Nov 20, 2024 7:37 PM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         cloud
Pydantic version:    2.10.1

Additional context

  File "/Users/nepperkins/Desktop/arnold/jobs/file.py", line 249, in <module>
    run_deployment(name=f"<My Deployment>", timeout=0)
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 399, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 243, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/3.11.4/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 225, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 389, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/client/utilities.py", line 103, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/deployments/flow_runs.py", line 164, in run_deployment
    state=Scheduled(scheduled_time=scheduled_time),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/prefect/states.py", line 609, in Scheduled
    return cls(type=StateType.SCHEDULED, state_details=state_details, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/pydantic/main.py", line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nepperkins/.pyenv/versions/arnold/lib/python3.11/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__
    raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `State` is not fully defined; you should define all referenced types, then call `State.model_rebuild()`.

For further information visit https://errors.pydantic.dev/2.10/u/class-not-fully-defined
@Chris-Perkins Chris-Perkins added the bug Something isn't working label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant