Skip to content

Commit

Permalink
Move to uv (NVIDIA#94)
Browse files Browse the repository at this point in the history
* Move to uv

Signed-off-by: Hemil Desai <[email protected]>

* fix

Signed-off-by: Hemil Desai <[email protected]>

* fix

Signed-off-by: Hemil Desai <[email protected]>

* fix

Signed-off-by: Hemil Desai <[email protected]>

* Use dependency groups

Signed-off-by: Hemil Desai <[email protected]>

* Update contribution guide

Signed-off-by: Hemil Desai <[email protected]>

* fix

Signed-off-by: Hemil Desai <[email protected]>

---------

Signed-off-by: Hemil Desai <[email protected]>
  • Loading branch information
hemildesai authored Dec 10, 2024
1 parent dd970c9 commit 7145bbc
Show file tree
Hide file tree
Showing 10 changed files with 6,923 additions and 96 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:

jobs:
format:
uses: ./.github/workflows/rye-format.yml
uses: ./.github/workflows/ruff-format.yml
lint:
uses: ./.github/workflows/rye-lint.yml
uses: ./.github/workflows/ruff-lint.yml
test:
uses: ./.github/workflows/rye-test.yml
uses: ./.github/workflows/test.yml
tag:
name: Run Tests and Create Nightly Tag
runs-on: ubuntu-latest
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/ruff-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruff format

on:
workflow_dispatch:
workflow_call:
push:
branches: [main]
pull_request:

jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Ruff fmt
run: uv run --group lint -- ruff format --diff
23 changes: 23 additions & 0 deletions .github/workflows/ruff-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruff lint

on:
workflow_dispatch:
workflow_call:
push:
branches: [main]
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Ruff lint
run: uv run --group lint -- ruff check
19 changes: 0 additions & 19 deletions .github/workflows/rye-format.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/rye-lint.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/rye-test.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run tests

on:
workflow_dispatch:
workflow_call:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: uv sync
run: uv sync --extra skypilot

- shell: bash
run: |
git config --global user.name github-actions[bot]
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Run tests
run: uv run -- pytest test/

- name: Run coverage
run: |
uv run -- coverage run -m pytest
uv run -- coverage report -m
- name: Run example notebooks
run: uv run -- jupyter execute examples/**/*.ipynb

- name: Run example scripts
run: |
cd examples/hello-world && uv run -- python hello_scripts.py
11 changes: 4 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Not all steps are necessary for some contributions, so read the linked sections
1. **Sensible**: code should make sense. If you think a piece of code might be confusing, write comments.

## Environment Setup
We use [rye](https://rye.astral.sh/) to develop NeMo Run. The following steps should get you started with the dev environment:
We use [uv](https://docs.astral.sh/uv/) to develop NeMo Run. The following steps should get you started with the dev environment:

1. Install [rye](https://rye.astral.sh/guide/installation/)
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
2. Clone NeMo-Run
3. Sanity check with `rye test` (This will create a venv and run all unit tests)
3. Sanity check with `uv sync --extra skypilot && uv run -- pytest test/` (This will create a venv and run all unit tests)

If all tests passed, then you should be good to get started with the development of NeMo-Run.

Expand All @@ -55,14 +55,11 @@ The documentation should also cover potential pitfalls and caveats.
This existing examples and documentation should serve as a good reference to what is expected.

## Python style
We use [``ruff``](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `rye check` and `rye fmt` respectively.
We use [``ruff``](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `uv run --group lint -- ruff check` and `uv run --group lint -- ruff format` respectively.

## Unit tests
Unit tests should be simple and fast.
Developers should be able to run them frequently while developing without any slowdown.
```
rye test
```

## Pull Requests (PR) Guidelines

Expand Down
28 changes: 18 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,10 @@ skypilot-all = [
"skypilot[all]>=v0.6.1",
]

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
[dependency-groups]
dev = [
{ include-group = "lint" },
"pytest>=8.2.0",
"ruff>=0.4.4",
"coverage>=7.5.1",
"pre-commit>=3.7.1",
"pytest-sugar>=1.0.0",
Expand All @@ -70,8 +65,21 @@ dev-dependencies = [
"jupyter>=1.1.1"
]

[tool.rye.scripts]
cov = { chain = ["coverage run -m pytest", "coverage report -m" ] }
lint = [
"ruff>=0.4.4",
]

docs = [
"sphinx"
]

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.uv]
managed = true
prerelease = "allow"

[tool.pytest.ini_options]
markers = [
Expand Down
Loading

0 comments on commit 7145bbc

Please sign in to comment.