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

Error due to missing uuid import in client.find_automation #16822

Closed
ogenstad opened this issue Jan 23, 2025 · 1 comment · Fixed by #16824
Closed

Error due to missing uuid import in client.find_automation #16822

ogenstad opened this issue Jan 23, 2025 · 1 comment · Fixed by #16824
Labels
bug Something isn't working

Comments

@ogenstad
Copy link

ogenstad commented Jan 23, 2025

Bug summary

When calling await client.find_automation(id_or_name="dd9465f4-2f1a-494e-b219-c05790b19f0a") there's an exception due to a missing import:

  File "/Users/patrick/.virtualenvs/infrahub/lib/python3.12/site-packages/prefect/client/orchestration/_automations/client.py", line 208, in find_automation
    id = UUID(id_or_name)
         ^^^^
NameError: name 'UUID' is not defined

The bug was introduced in #16579. When finding automations we try to create a UUID from the provided string here:

https://github.com/PrefectHQ/prefect/blob/3.1.13/src/prefect/client/orchestration/_automations/client.py#L51

However the uuid library isn't imported aside from within the TYPE_CHECKING section: https://github.com/PrefectHQ/prefect/blob/3.1.13/src/prefect/client/orchestration/_automations/client.py#L11

As a note the create_automation works differently:
https://github.com/PrefectHQ/prefect/blob/3.1.13/src/prefect/client/orchestration/_automations/client.py#L24C9-L26

Version info

❯ prefect version
Version:             3.1.13
API version:         0.8.4
Python version:      3.12.8
Git commit:          16e85ce3
Built:               Fri, Jan 17, 2025 8:46 AM
OS/Arch:             darwin/arm64
Profile:             ephemeral
Server type:         server
Pydantic version:    2.9.2

Additional context

As the imports are cached and I'm sure that the uuid package gets imported elsewhere regardless it feels like these inline imports just adds confusion.

@aaazzam
Copy link
Collaborator

aaazzam commented Jan 23, 2025

PR to fix is up.

As the imports are cached and I'm sure that the uuid package gets imported elsewhere regardless it feels like these inline imports just adds confusion.

Yeah I can see that. We've chosen to keep some imports out of the type_checking guard (custom exception types, etc), and I get the argument that UUID is probably ubiquitous enough to be considered standard fare.

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

Successfully merging a pull request may close this issue.

2 participants