skypilot-org / skypilot

SkyPilot: Run AI and batch jobs on any infra (Kubernetes or 12+ clouds). Get unified execution, cost savings, and high GPU availability via a simple interface.
https://skypilot.readthedocs.io
Apache License 2.0
6.85k stars 518 forks source link

Run with UV package manager #4428

Open kevinsimper opened 1 day ago

kevinsimper commented 1 day ago

Love skypilot 💝

I was trying to use with UV, but it fails on this command

I guess skypilot is meant to be run within a managed venv, so I get why it fails, but it would be nice if skypilot had uv support.

$ uv run sky launch -c gatx skypilot.yaml
Task from YAML spec: skypilot.yaml
Considered resources (1 node):
---------------------------------------------------------------------------------------------
 CLOUD   INSTANCE       vCPUs   Mem(GB)   ACCELERATORS   REGION/ZONE     COST ($)   CHOSEN
---------------------------------------------------------------------------------------------
 GCP     n1-highmem-4   4       26        T4:1           us-central1-a   0.59          ✔
---------------------------------------------------------------------------------------------
Launching a new cluster 'gatx'. Proceed? [Y/n]: y

Traceback (most recent call last):
  File "/Users/xx/.venv/lib/python3.12/site-packages/sky/backends/wheel_utils.py", line 103, in _build_sky_wheel
    subprocess.run([
  File "/Users/xx/.local/share/uv/python/cpython-3.12.6-macos-aarch64-none/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pip3', 'wheel', '--no-deps', '/var/folders/zy/fgmdfk0123304wg6ck35mcvm0000gn/T/tmpvsinlzlv/', '--wheel-dir', '/var/folders/zy/fgmdfk0123304wg6ck35mcvm0000gn/T/tmpvsinlzlv']' returned non-zero exit status 1.

Version & Commit info:

concretevitamin commented 1 day ago

Thanks for the report @kevinsimper 🙌 cc @cg505 who's been looking into using uv in the backend.

cg505 commented 1 day ago

Hi @kevinsimper! How did you install skypilot? Does uv pip install pip resolve this issue?

cg505 commented 1 day ago

I think we should add pip as a package dependency to resolve this, since we use it during wheel build. At the moment we are just assuming it's present, but this won't be the case in uv venvs. @Michaelvll any concern with this?

kesitrifork commented 1 day ago

@cg505 No, you install with uv add skypilot[gcp]

The bigger problem is that uv is not a pip replacement (their words)

So running subcommand to run a pip command will execute the wrong pip executable, and wheel is not a happy command to support because of legacy reasons https://github.com/astral-sh/uv/issues/1681

cg505 commented 1 day ago

@kevinsimper In my testing, uv add pip (or uv pip install pip if you are just using a venv, outside a project) seems to work. It looks like uv will set up the environment correctly so that we get the right pip executable. (Specifically, it modifies PATH so that the venv bin is the very first element, and sets the VIRTUAL_ENV var as well.) Ideally this can happen without using a subprocess, but it seems like it works either way.

cg505 commented 1 day ago

To clarify, I'm NOT asking you to install pip so that you can use it to install skypilot instead of using uv - just asking you to install it so that skypilot can use it correctly during provisioning.