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

[BUG] FlyteKit's ImageSpec results in unexpected behavior with incorrect "packages" argument type. #5632

Closed
2 tasks done
granthamtaylor opened this issue Aug 5, 2024 · 2 comments · Fixed by flyteorg/flytekit#2655
Assignees
Labels
bug Something isn't working

Comments

@granthamtaylor
Copy link

Describe the bug

If one were to pass a string to the packages argument of ImageSpec, they will get a similar error to the following (I accidentally passed in "requirements.txt" :

🐳 Build not found, submitting a new build...
👍 Build submitted!
⏳ Waiting for build to finish at: https://serverless.union.ai/org/granthamtaylor/projects/system/domains/development/executions/f3f84fb50f9a04442815
╭─ Error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ❌ Build failed in 0:01:31 at https://serverless.union.ai/org/granthamtaylor/projects/system/domains/development/executions/f3f84fb50f9a04442815 with error:            │
│                                                                                                                                                                                │
│ [2/2] currentAttempt done. Last Error: USER::                                                                                                                                  │
│ [main] terminated with exit code (1). Reason [Error]. Message:                                                                                                                 │
│ b6a7140 done                                                                                                                                                                   │
│ #3 CACHED                                                                                                                                                                      │
│                                                                                                                                                                                │
│ #4 [internal] load image spec                                                                                                                                                  │
│ #4 CACHED                                                                                                                                                                      │
│                                                                                                                                                                                │
│ #5 resolve image config for docker-image://cr.union.ai/union/python-base:3.11                                                                                                  │
│ #5 DONE 0.1s                                                                                                                                                                   │
│                                                                                                                                                                                │
│ #6 resolve image config for docker-image://cr.union.ai/union/python-build:3.11                                                                                                 │
│ #6 DONE 0.1s                                                                                                                                                                   │
│                                                                                                                                                                                │
│ #7 docker-image://cr.union.ai/union/python-base:3.11                                                                                                                           │
│ #7 resolve cr.union.ai/union/python-base:3.11 0.0s done                                                                                                                        │
│ #7 DONE 0.1s                                                                                                                                                                   │
│                                                                                                                                                                                │
│ #8 docker-image://cr.union.ai/union/python-build:3.11                                                                                                                          │
│ #8 resolve cr.union.ai/union/python-build:3.11 0.1s done                                                                                                                       │
│ #8 CACHED                                                                                                                                                                      │
│                                                                                                                                                                                │
│ #9 pip install --cache-dir /var/cache/pip r e q u i r e m e n t s . t x t union==0.1.62                                                                                        │
│ #9 0.396 ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.                                                                               │
│ #9 0.403                                                                                                                                                                       │
│ #9 0.403 [notice] A new release of pip is available: 24.0 -> 24.2                                                                                                              │
│ #9 0.403 [notice] To update, run: pip install --upgrade pip                                                                                                                    │
│ #9 ERROR: process "pip install --cache-dir /var/cache/pip r e q u i r e m e n t s . t x t union==0.1.62" did not complete successfully: exit code: 1                           │
│ ------                                                                                                                                                                         │
│  > pip install --cache-dir /var/cache/pip r e q u i r e m e n t s . t x t union==0.1.62:                                                                                       │
│ 0.396 ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.                                                                                  │
│ 0.403                                                                                                                                                                          │
│ 0.403 [notice] A new release of pip is available: 24.0 -> 24.2                                                                                                                 │
│ 0.403 [notice] To update, run: pip install --upgrade pip                                                                                                                       │
│ ------                                                                                                                                                                         │
│ error: failed to solve: process "pip install --cache-dir /var/cache/pip r e q u i r e m e n t s . t x t union==0.1.62" did not complete successfully: exit code: 1             │
│ {"message":"buildctl local command failed: exit status 1","severity":"ERROR","timestamp":"2024-08-05T16:15:35Z"}                                                               │
│ {"message":"Failed to build image: buildctl command failed: exit status 1","severity":"ERROR","timestamp":"2024-08-05T16:15:35Z"}                                              │
│ {"message":"Image Build error: failed to build image: buildctl command failed: exit status 1","severity":"WARNING","timestamp":"2024-08-05T16:15:36Z"}                         │
│ Error: failed to build image: buildctl command failed: exit status 1                                                                                                           │
│ {"message":"failed to build image: buildctl command failed: exit status 1","severity":"CRITICAL","timestamp":"2024-08-05T16:15:36Z"}                                           │
│ .                                                                                                                                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
        

Expected behavior

There appears to be no type assertion on the packages argument, such that ImageSpec will literally "iterate" over all of the values of the input.

This results in unexpected behavior, but could be improved with couple of simple type assertions:

  • isinstance(packages, list)
  • all(isinstance(package, str) for package in packages)

Should these assertions fail, then I would expect a more human-friendly error message, such as an invalid input type.

Additional context to reproduce

import flytekit as fk

image = fk.ImageSpec(builder="unionai", packages="requirements")

@fk.task(container_image=image)
def my_task(my_value: str) -> None:
print(my_value)

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@granthamtaylor granthamtaylor added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Aug 5, 2024
Copy link

welcome bot commented Aug 5, 2024

Thank you for opening your first issue here! 🛠

Copy link

runllm bot commented Aug 5, 2024

The issue you're encountering is due to the packages argument in ImageSpec not enforcing type checks, leading to unexpected behavior when a string is passed instead of a list of strings. According to the ImageSpec documentation, the packages parameter should be a list of strings, not a single string.

To avoid this issue, ensure that packages is always a list of strings. Here's an example of how to correctly use the ImageSpec:

import flytekit as fk

image = fk.ImageSpec(builder="unionai", packages=["requirements.txt"])

@fk.task(container_image=image)
def my_task(my_value: str) -> None:
    print(my_value)

Would you like more details on how to handle this or any other aspect of ImageSpec?

Sources:


This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not.

Mention @RunLLM to ask follow-up questions. See runllm.com for more!

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
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants