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

Make it easier to use commands with uv #2897

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

thomasjpfan
Copy link
Member

Tracking issue

Related to flyteorg/flyte#5597

Why are the changes needed?

It's hard to use uv in commands. With this PR, using uv targets the install python environment and it's simple to use. For example, we can now write:

image_spec = ImageSpec(
    name="myimage",
    registry="localhost:30000",
    packages=["numpy"],
    commands=["uv pip install scikit-learn"],
)

What changes were proposed in this pull request?

With this PR the run_commands automatically mounts the

How was this patch tested?

I ran the following workflow:

from flytekit import task, workflow, ImageSpec

image_spec = ImageSpec(
    name="myimage",
    registry="localhost:30000",
    packages=["scikit-learn"],
    pip_extra_index_url=[
        "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
    ],
    env={"UV_PRERELEASE": "allow"},
)


@task(container_image=image_spec)
def sklearn_version() -> str:
    import sklearn

    return sklearn.__version__


@workflow
def main() -> str:
    return sklearn_version()

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Copy link
Member

@pingsutw pingsutw left a comment

Choose a reason for hiding this comment

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

looks great, but some tests are failing

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
@thomasjpfan
Copy link
Member Author

@pingsutw Fixed it in https://github.com/flyteorg/flytekit/pull/2897/files/a4aa19755933d8998fb0797507c52fb74760a462..206c3f9618d70a98d57935c8517532b6f63f03db by updating the test to a regex.

@thomasjpfan thomasjpfan merged commit 9ded460 into flyteorg:master Nov 5, 2024
100 of 102 checks passed
kumare3 pushed a commit that referenced this pull request Nov 8, 2024
* Make it easier to use commands with uv

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Move RUN_COMMANDS up

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add verbose for showing apps

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Update RUN check assertion

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

---------

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
katrogan pushed a commit that referenced this pull request Nov 15, 2024
* Make it easier to use commands with uv

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Move RUN_COMMANDS up

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Add verbose for showing apps

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

* Update RUN check assertion

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>

---------

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Signed-off-by: Katrina Rogan <katroganGH@gmail.com>
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