Skip to content

Commit bc9ddee

Browse files
committed
Update .gitignore to exclude PyPI build artifacts and enhance README with instructions for using the judge in Google Colab and publishing to PyPI. Modify setup.py to restrict package inclusion to only torch_judge for PyPI distribution.
1 parent 03dbd72 commit bc9ddee

File tree

5 files changed

+139
-1
lines changed

5 files changed

+139
-1
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Publish torch-judge to PyPI when a version tag (v*) is pushed, or manually.
2+
#
3+
# Setup (choose one):
4+
#
5+
# 1) Trusted Publishing (recommended, no token):
6+
# - On PyPI: Project → Publishing → Add a new pending publisher
7+
# - Owner: duoan (or your org), Repository: TorchCode, Workflow: pypi-publish.yml
8+
# - Then run this workflow once; PyPI will link the publisher.
9+
#
10+
# 2) API token:
11+
# - Add repository secret PYPI_API_TOKEN (value = pypi-... from pypi.org)
12+
# - The action will use TWINE_USERNAME=__token__ and TWINE_PASSWORD from secret.
13+
14+
name: Publish torch-judge to PyPI
15+
16+
on:
17+
push:
18+
tags:
19+
- "v*"
20+
workflow_dispatch:
21+
22+
jobs:
23+
pypi-publish:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
id-token: write # for PyPI trusted publishing (OIDC)
27+
contents: read
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3.11"
37+
38+
- name: Install build
39+
run: pip install build
40+
41+
- name: Build package
42+
run: python -m build
43+
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
skip-existing: true
48+
verbose: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ data/*.db
77
.DS_Store
88
notebooks/
99

10+
# PyPI build artifacts
11+
dist/
12+
build/
13+
.venv/
14+
1015
# JupyterLab extension build artifacts
1116
labextension/lib/
1217
labextension/node_modules/

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ No cloud. No signup. No GPU needed. Just `make run` — or try it instantly on H
6565

6666
Or open any problem directly in Google Colab — every notebook has an [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/duoan/TorchCode/blob/master/templates/01_relu.ipynb) badge.
6767

68+
### Option 0b — Use the judge in Colab (pip)
69+
70+
In Google Colab, install the judge from PyPI so you can run `check(...)` without cloning the repo:
71+
72+
```bash
73+
!pip install torch-judge
74+
```
75+
76+
Then in a notebook cell:
77+
78+
```python
79+
from torch_judge import check, status, hint, reset_progress
80+
status() # list all problems and your progress
81+
check("relu") # run tests for the "relu" task
82+
hint("relu") # show a hint
83+
```
84+
6885
### Option 1 — Pull the pre-built image (fastest)
6986

7087
```bash
@@ -260,6 +277,35 @@ No registration needed. The judge picks it up automatically.
260277

261278
---
262279

280+
## 📦 Publishing `torch-judge` to PyPI (maintainers)
281+
282+
The judge is published as a separate package so Colab/users can `pip install torch-judge` without cloning the repo.
283+
284+
### Automatic (GitHub Action)
285+
286+
Pushing a **version tag** (e.g. `v0.1.0`) triggers [`.github/workflows/pypi-publish.yml`](.github/workflows/pypi-publish.yml), which builds and uploads to PyPI.
287+
288+
1. **Bump version** in `pyproject.toml` (e.g. `version = "0.1.1"`).
289+
2. **Configure PyPI Trusted Publisher** (one-time):
290+
- PyPI → Your project **torch-judge****Publishing****Add a new pending publisher**
291+
- Owner: `duoan`, Repository: `TorchCode`, Workflow: `pypi-publish.yml`, Environment: (leave empty)
292+
- Run the workflow once (push a tag or **Actions → Publish torch-judge to PyPI → Run workflow**); PyPI will then link the publisher.
293+
3. **Release**: `git tag v0.1.1 && git push origin v0.1.1` (tag must match the version in `pyproject.toml`).
294+
295+
Alternatively, use an API token: add repository secret `PYPI_API_TOKEN` (value = `pypi-...` from PyPI) and set `TWINE_USERNAME=__token__` and `TWINE_PASSWORD` from that secret in the workflow if you prefer not to use Trusted Publishing.
296+
297+
### Manual
298+
299+
```bash
300+
pip install build twine
301+
python -m build
302+
twine upload dist/*
303+
```
304+
305+
Version is in `pyproject.toml`; bump it before each release.
306+
307+
---
308+
263309
## ❓ FAQ
264310

265311
<details>

pyproject.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[build-system]
2+
requires = ["setuptools>=61", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "torch-judge"
7+
version = "0.1.0"
8+
description = "PyTorch coding judge for Jupyter — check implementations against test cases (TorchCode)."
9+
readme = "README.md"
10+
license = "MIT"
11+
requires-python = ">=3.10"
12+
authors = [
13+
{ name = "duoan" }
14+
]
15+
keywords = ["pytorch", "jupyter", "notebook", "judge", "torchcode", "interview", "practice"]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Intended Audience :: Education",
19+
"Intended Audience :: Developers",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
25+
]
26+
dependencies = [
27+
"torch>=2.0",
28+
]
29+
30+
[project.optional-dependencies]
31+
dev = [
32+
"build",
33+
"twine",
34+
]
35+
36+
[tool.setuptools.packages.find]
37+
include = ["torch_judge*"]
38+
exclude = ["labextension*", "scripts*", "templates*", "solutions*", "jupyter_config*"]

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from setuptools import setup, find_packages
22

3+
# Only ship torch_judge for PyPI; rest of repo (labextension, templates, etc.) stays local.
34
setup(
45
name="torch_judge",
56
version="0.1.0",
6-
packages=find_packages(),
7+
packages=find_packages(include=["torch_judge", "torch_judge.*"]),
78
python_requires=">=3.10",
89
)

0 commit comments

Comments
 (0)