Skip to content

Commit 8a98e17

Browse files
authored
Merge pull request #83 from apoorvkh/update-docs
Prepare for public release (`0.3.0`)
2 parents b72f201 + 1035b75 commit 8a98e17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5706
-1631
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: astral-sh/setup-uv@v3.2.2
16+
- uses: astral-sh/setup-uv@v5
1717
with:
18-
version: "0.5.0"
19-
python-version-file: ".python-version"
18+
version: "0.5.29"
2019
enable-cache: true
20+
- run: uv lock --check
2121
- run: uv sync
2222
- run: uv run --frozen ruff check
2323
if: success() || failure()
@@ -26,39 +26,83 @@ jobs:
2626
- run: uv run --frozen pyright
2727
if: success() || failure()
2828

29+
build-docs:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: astral-sh/setup-uv@v5
34+
with:
35+
version: "0.5.29"
36+
- run: source ./scripts/build_docs.sh
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: docs-html-build
40+
path: docs/_build/html
41+
retention-days: 14
42+
2943
##
3044

31-
get-pytorch-versions:
45+
get-python-pytorch-versions:
3246
runs-on: ubuntu-latest
3347
outputs:
34-
versions: ${{ steps.get-pytorch-versions.outputs.versions }}
48+
versions: ${{ steps.get-versions.outputs.versions }}
3549
steps:
36-
- name: Get PyTorch versions
37-
id: get-pytorch-versions
50+
- name: "Get (Python, PyTorch) versions"
51+
id: get-versions
3852
run: |
39-
VERSIONS=$(
40-
curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' |
41-
# remove versions <2.0; strip "patch" from versions
42-
grep -v '^1\.' | grep -E '\.[0]+$' | sort -V | sed 's/\.0$//' |
43-
# to JSON array
44-
jq -R . | jq -sc .
53+
MIN_PYTHON_VERSION=3.9
54+
MIN_PYTORCH_VERSION=2.0
55+
56+
# Get PyTorch versions from PyPI
57+
pytorch_versions=$(
58+
curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' |
59+
# strip "patch" from versions
60+
grep -E '\.[0]+$' | sort -V | sed 's/\.0$//'
4561
)
46-
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
47-
# e.g. ["2.0","2.1","2.2","2.3","2.4"]
62+
63+
# For each PyTorch version, get Python versions that have builds
64+
# Generate JSON list of "python,pytorch" versions
65+
66+
version_matrix=()
67+
for pytorch_version in $pytorch_versions; do
68+
# Skip if PyTorch version less than minium
69+
if [[ "$(printf '%s\n' "$pytorch_version" "$MIN_PYTORCH_VERSION" | sort -V | head -n 1)" != "$MIN_PYTORCH_VERSION" ]]; then continue; fi
70+
71+
python_versions=$(
72+
curl -s "https://pypi.org/pypi/torch/$pytorch_version/json" |
73+
jq -r '.urls[].filename | select(test("manylinux1_x86_64")) | capture("(?<cp>cp[0-9]+)-") | .cp |
74+
sub("cp(?<major>[0-9])(?<minor>[0-9]+)"; "\(.major).\(.minor)")'
75+
)
76+
77+
for python_version in $python_versions; do
78+
# Skip if Python version less than minium
79+
if [[ "$(printf '%s\n' "$python_version" "$MIN_PYTHON_VERSION" | sort -V | head -n 1)" != "$MIN_PYTHON_VERSION" ]]; then continue; fi
80+
81+
version_matrix+=($python_version,$pytorch_version)
82+
done
83+
done
84+
version_matrix=$(printf '%s\n' "${version_matrix[@]}" | jq -R . | jq -s -c .)
85+
86+
# Write to outputs
87+
echo "versions=$version_matrix" >> $GITHUB_OUTPUT
4888
4989
test:
5090
runs-on: ubuntu-latest
51-
needs: get-pytorch-versions
91+
needs: get-python-pytorch-versions
5292
strategy:
5393
fail-fast: false
5494
matrix:
55-
python: ["3.9", "3.10", "3.11", "3.12"]
56-
pytorch: ${{fromJson(needs.get-pytorch-versions.outputs.versions)}}
95+
versions: ${{fromJson(needs.get-python-pytorch-versions.outputs.versions)}}
5796
steps:
5897
- uses: actions/checkout@v4
59-
- uses: astral-sh/setup-uv@v3.2.2
98+
- uses: astral-sh/setup-uv@v5
6099
with:
61-
version: "0.5.0"
62-
- if: contains('2.0,2.1,2.2', matrix.pytorch)
63-
run: echo "NUMPY_VERSION=--with \"numpy<2\"" >> $GITHUB_ENV
64-
- run: uv run --python ${{ matrix.python }} --with torch~=${{ matrix.pytorch }} ${{ env.NUMPY_VERSION }} pytest --verbose tests/test_ci.py
100+
version: "0.5.29"
101+
- run: |
102+
IFS=',' read -r python_version pytorch_version <<< ${{ matrix.versions }}
103+
echo "PYTHON_VERSION=$python_version" >> $GITHUB_ENV
104+
echo "PYTORCH_VERSION=$pytorch_version" >> $GITHUB_ENV
105+
if [[ "$pytorch_version" =~ ^2\.(0|1|2)$ ]]; then
106+
echo "NUMPY_VERSION=--with \"numpy<2\"" >> $GITHUB_ENV
107+
fi
108+
- run: uv run --python ${{ env.PYTHON_VERSION }} --with torch~=${{ env.PYTORCH_VERSION }} ${{ env.NUMPY_VERSION }} pytest --verbose tests/test_ci.py

.github/workflows/release.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,35 @@ on:
55
types: [published]
66

77
jobs:
8-
release:
8+
release-to-pypi:
99
runs-on: ubuntu-latest
1010
permissions:
1111
id-token: write
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: astral-sh/setup-uv@v3
14+
- uses: astral-sh/setup-uv@v5
1515
with:
16-
version: "0.5.0"
16+
version: "0.5.29"
1717
- run: uv build
1818
- run: uv publish
19+
20+
publish-docs:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
pages: write
24+
id-token: write
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: astral-sh/setup-uv@v5
31+
with:
32+
version: "0.5.29"
33+
- run: source ./scripts/build_docs.sh
34+
- uses: actions/configure-pages@v5
35+
- uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: docs/_build/html
38+
- id: deployment
39+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
docs/source/README.md
2+
docs/source/contributing.md
3+
docs/source/examples/scripts/
4+
15
torchrunx_logs/
2-
.pixi/
36
.ruff_cache/
47
.vscode/
58

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ authors:
99
family-names: Curtin
1010
1111
repository-code: 'https://github.com/apoorvkh/torchrunx'
12-
url: torchrunx.readthedocs.io
13-
license: MIT
14-
year: 2024
12+
url: 'https://torchrun.xyz'
13+
license: GPL-3.0
14+
year: 2025

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
We use the [`uv`](https://github.com/astral-sh/uv) package manager. Simply [install `uv`](https://github.com/astral-sh/uv#installation) and run `uv sync` in this repository to build the environment. Run `source .venv/bin/activate` to activate the environment.
44

5-
We use `ruff check` for linting, `ruff format` for formatting, `pyright` for static type checking, and `pytest` for testing.
6-
7-
We build wheels with `uv build` and upload to [PyPI](https://pypi.org/project/torchrunx) with `uv publish`. Our release pipeline is powered by Github Actions.
5+
We use `ruff check` for linting, `ruff format` for formatting, `pyright` for static type checking, and `pytest` for testing. We expect all such checks to pass before merging changes to the main branch. We build wheels with `uv build` and upload to [PyPI](https://pypi.org/project/torchrunx) with `uv publish`. Our CI pipelines are powered by Github Actions.
86

97
## Pull Requests
108

11-
Make a pull request with your changes on Github and we'll try to look at soon! If addressing a specific issue, mention it in the PR, and offer a short explanation of your fix. If adding a new feature, explain why it's meaningful and belongs in __torchrunx__.
9+
Make a pull request with your changes on Github and we'll try to look at it soon! If addressing a specific issue, mention it in the PR, and offer a short explanation of your fix. If adding a new feature, explain why it's meaningful and belongs in **torchrunx**.
1210

1311
## Testing
1412

1513
`tests/` contains `pytest`-style tests for validating that code changes do not break the core functionality of our library.
1614

1715
At the moment, we run `pytest tests/test_ci.py` (i.e. simple single-node CPU-only tests) in our Github Actions CI pipeline (`.github/workflows/release.yml`). One can manually run our more involved tests (on GPUs, on multiple machines from SLURM) on their own hardware.
16+
17+
## Documentation
18+
19+
Our documentation is hosted on Github Pages and is updated with every package release. We build our documentation with [Sphinx](https://www.sphinx-doc.org): `source scripts/build_docs.sh`. The documentation will then be generated at `docs/_build/html` (and can be rendered with `python -m http.server --directory docs/_build/html`).

0 commit comments

Comments
 (0)