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

Adds experimental support for uv.lock in ImageSpec #2929

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

thomasjpfan
Copy link
Member

@thomasjpfan thomasjpfan commented Nov 14, 2024

Why are the changes needed?

uv and uv.lock is becoming a commonly used tool for managing python environments. This PR adds experimental support for uv.lock into ImageSpec.

What changes were proposed in this pull request?

This PR enables requirements="uv.lock" support in ImageSpec. Using uv.lock shows a warning stating that uv.lock support is experimental since uv sync is experimental, so our integration may change.

How was this patch tested?

mkdir uv-check
cd uv-check
uv init
uv add flytekit numpy

# activate python environment with this PR
pyflyte run --remote main.py my_task

where main.py is:

from flytekit import task, ImageSpec

image_spec = ImageSpec(
    name="uv-wow",
    requirements="uv.lock",
    registry="localhost:30000",
    env={"abc": "xyz125"},
)


@task(container_image=image_spec)
def my_task() -> int:
    import numpy as np

    return np.asarray([1, 2, 3]).sum().item()

@thomasjpfan thomasjpfan changed the title Adds experimental support for uv.lock Adds experimental support for uv.lock in ImageSpec Nov 14, 2024
eapolinario
eapolinario previously approved these changes Nov 18, 2024
Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had a better way to signal that uv lock files could be used in imagespec that didn't involve overloading the requirements parameter. Can't think of anything better though, so let's get this out.


requirements = []
if image_spec.packages is not None:
msg = "uv.lock is not compatible with packages, please include all your dependencies in uv.lock"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this mention that support for uv.lock files and packages is mutually exclusive instead?

Signed-off-by: Thomas J. Fan <[email protected]>
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.36%. Comparing base (8feb3b8) to head (c630885).
Report is 8 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2929       +/-   ##
===========================================
- Coverage   94.25%   79.36%   -14.90%     
===========================================
  Files          18      199      +181     
  Lines        1358    20910    +19552     
  Branches        0     2691     +2691     
===========================================
+ Hits         1280    16595    +15315     
- Misses         78     3574     +3496     
- Partials        0      741      +741     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants