Skip to content

[core] [3/N] Use uv as package manager#48611

Merged
pcmoritz merged 10 commits intoray-project:masterfrom
dentiny:hjiang/uv-installation
Nov 8, 2024
Merged

[core] [3/N] Use uv as package manager#48611
pcmoritz merged 10 commits intoray-project:masterfrom
dentiny:hjiang/uv-installation

Conversation

@dentiny
Copy link
Copy Markdown
Contributor

@dentiny dentiny commented Nov 6, 2024

This PR integrates uv into existing runtime env system, which uses uv to setup environment for better performance.

TODO list:

  • Add uv to public documentation

@dentiny dentiny marked this pull request as draft November 6, 2024 21:11
@pcmoritz
Copy link
Copy Markdown
Contributor

pcmoritz commented Nov 6, 2024

Great progress! Here are two test cases I'm using to try this out:

In [1]: import ray

In [2]: ray.init(runtime_env={"uv": ["emoji"]})
2024-11-06 13:41:00,419	INFO worker.py:1812 -- Started a local Ray instance. View the dashboard at http://127.0.0.1:8265 
Out[2]: RayContext(dashboard_url='127.0.0.1:8265', python_version='3.11.4', ray_version='3.0.0.dev0', ray_commit='{{RAY_COMMIT_SHA}}')

In [3]: @ray.remote
   ...: def f():
   ...:     import emoji
   ...:     return emoji.emojize('Ray and UV is :thumbs_up:')
   ...: 

In [4]: ray.get(f.remote())
In [1]: import ray

In [2]: ray.init(runtime_env={"uv": ["openai-whisper"]})
2024-11-06 13:45:16,284	INFO worker.py:1812 -- Started a local Ray instance. View the dashboard at http://127.0.0.1:8265 
Out[2]: RayContext(dashboard_url='127.0.0.1:8265', python_version='3.11.4', ray_version='3.0.0.dev0', ray_commit='{{RAY_COMMIT_SHA}}')

In [3]: 

In [3]: @ray.remote
   ...: def f():
   ...:     import whisper
   ...:     return str(whisper.load_model("turbo"))
   ...: 

In [4]: ray.get(f.remote())

Currently failing with

ValueError: Local directory /tmp/ray/session_2024-11-06_13-45-15_408387_64642/runtime_resources/uv/fd1fdf03c7d0becce4e97c66770ea43be96743ac for URI uv://fd1fdf03c7d0becce4e97c66770ea43be96743ac does not exist on the cluster. Something may have gone wrong while installing the runtime_env `uv` packages.

(which is probably expected since you marked it as "draft"). Once it is working I'm also happy to test it on workspaces :)

@dentiny dentiny force-pushed the hjiang/uv-installation branch from e0a7f80 to af8e53b Compare November 7, 2024 00:58
@dentiny dentiny changed the title uv installation [core] [3/N ] Use uv as package manager Nov 7, 2024
@dentiny dentiny changed the title [core] [3/N ] Use uv as package manager [core] [3/N] Use uv as package manager Nov 7, 2024
@dentiny dentiny requested review from jjyao and rynewang November 7, 2024 01:01
@dentiny dentiny marked this pull request as ready for review November 7, 2024 01:01
@dentiny dentiny marked this pull request as draft November 7, 2024 01:01
@dentiny dentiny force-pushed the hjiang/uv-installation branch from af8e53b to d485d30 Compare November 7, 2024 01:06
@dentiny dentiny marked this pull request as ready for review November 7, 2024 01:07
@dentiny dentiny added the go add ONLY when ready to merge, run all tests label Nov 7, 2024
Signed-off-by: dentiny <dentinyhao@gmail.com>
@dentiny dentiny force-pushed the hjiang/uv-installation branch from d485d30 to ab6b4e9 Compare November 7, 2024 05:15
Copy link
Copy Markdown
Contributor

@jjyao jjyao left a comment

Choose a reason for hiding this comment

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

LG

# 1. Install specialized version of `uv`.
# 2. Options for `uv install`.
# 3. Use requirement files for packages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most pip integration test can have a uv counterpart. Consider reusing the tests by using @pytest.mark.parametrize. This also shows people can just change pip to uv and things will just work.

Copy link
Copy Markdown
Contributor Author

@dentiny dentiny Nov 7, 2024

Choose a reason for hiding this comment

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

Yeah I considered that, but choose to rewrite in these reasons:

  • (major) uv and pip are not 100% compatible, which means we will have a number of if-else branches
    • For example, we need to add uv-specific tests at the end
    • I've seen a few community discussions on leveraging uv features, I'm afraid the split will become larger and larger
  • (major/minor) pip and uv installation process is different: we consider pip installed by default, while have to install uv ourselves, which means, we need to do extra checking for uv
  • (minor) Not all the features are implemented for uv for now, so quite a lot of existing pip-based tests will be skipped;

Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
@dentiny dentiny requested a review from jjyao November 7, 2024 20:36
Copy link
Copy Markdown
Contributor

@jjyao jjyao left a comment

Choose a reason for hiding this comment

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

Last few comments.

Signed-off-by: dentiny <dentinyhao@gmail.com>
Signed-off-by: dentiny <dentinyhao@gmail.com>
@jjyao jjyao enabled auto-merge (squash) November 7, 2024 22:34
@github-actions github-actions bot disabled auto-merge November 7, 2024 23:39
@pcmoritz pcmoritz enabled auto-merge (squash) November 8, 2024 00:16
@github-actions github-actions bot disabled auto-merge November 8, 2024 03:00
Signed-off-by: dentiny <dentinyhao@gmail.com>
@pcmoritz pcmoritz enabled auto-merge (squash) November 8, 2024 03:20
@dentiny dentiny requested a review from pcmoritz November 8, 2024 03:44
@pcmoritz pcmoritz merged commit c363774 into ray-project:master Nov 8, 2024
JP-sDEV pushed a commit to JP-sDEV/ray that referenced this pull request Nov 14, 2024
This PR integrates `uv` into existing runtime env system, which uses
`uv` to setup environment for better performance.

TODO list:
- [ ] Add `uv` to public documentation

---------

Signed-off-by: dentiny <dentinyhao@gmail.com>
Co-authored-by: Jiajun Yao <jeromeyjj@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-backlog go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants