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

Circular Import in prefect.utilities.schema_tools #16434

Open
JMMarchant opened this issue Dec 18, 2024 · 2 comments
Open

Circular Import in prefect.utilities.schema_tools #16434

JMMarchant opened this issue Dec 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@JMMarchant
Copy link

JMMarchant commented Dec 18, 2024

Bug summary

Attempting to import from prefect.utilities.schema_tools raises an ImportError due to circular imports.

Steps

  • Run python -c "import prefect.utilities.schema_tools"
  • Raises:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/utilities/schema_tools/__init__.py", line 1, in <module>
    from .hydration import HydrationContext, HydrationError, hydrate
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/utilities/schema_tools/hydration.py", line 11, in <module>
    from prefect.server.utilities.user_templates import (
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/__init__.py", line 1, in <module>
    from . import models, orchestration, schemas, services
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/models/__init__.py", line 1, in <module>
    from . import (
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/models/agents.py", line 14, in <module>
    import prefect.server.schemas as schemas
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/schemas/__init__.py", line 1, in <module>
    from . import (
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/schemas/sorting.py", line 9, in <module>
    from prefect.server.database import orm_models
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/database/orm_models.py", line 34, in <module>
    from prefect.server.events.actions import ServerActionTypes
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/server/events/actions.py", line 83, in <module>
    from prefect.utilities.schema_tools.hydration import (
ImportError: cannot import name 'HydrationContext' from partially initialized module 'prefect.utilities.schema_tools.hydration' (most likely due to a circular import) (/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/utilities/schema_tools/hydration.py)

Version info

Version:             3.1.7
API version:         0.8.4
Python version:      3.10.16
Git commit:          c05ffa6d
Built:               Mon, Dec 16, 2024 10:06 AM
OS/Arch:             darwin/x86_64
Profile:             ephemeral
Server type:         ephemeral
Pydantic version:    2.10.3
Server:
  Database:          sqlite
  SQLite version:    3.43.2

Additional context

No response

@JMMarchant JMMarchant added the bug Something isn't working label Dec 18, 2024
@JMMarchant
Copy link
Author

Can also confirm this is present in 3.1.9.dev1

@JMMarchant
Copy link
Author

Additionally, a similar circular import from import prefect.infrastructure.provisioners:

> python -c "import prefect.infrastructure.provisioners"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/infrastructure/provisioners/__init__.py", line 4, in <module>
    from .cloud_run import CloudRunPushProvisioner
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/infrastructure/provisioners/cloud_run.py", line 19, in <module>
    from prefect.cli._prompts import prompt, prompt_select_from_table
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/cli/__init__.py", line 27, in <module>
    import prefect.cli.work_pool
  File "/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/cli/work_pool.py", line 24, in <module>
    from prefect.infrastructure.provisioners import (
ImportError: cannot import name '_provisioners' from partially initialized module 'prefect.infrastructure.provisioners' (most likely due to a circular import) (/Users/jamesmarchant/.pyenv/versions/pf_pi/lib/python3.10/site-packages/prefect/infrastructure/provisioners/__init__.py)

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