An, Duo commited on
Commit Β·
bc9ddee
1
Parent(s): 03dbd72
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.
Browse files- .github/workflows/pypi-publish.yml +48 -0
- .gitignore +5 -0
- README.md +46 -0
- pyproject.toml +38 -0
- setup.py +2 -1
.github/workflows/pypi-publish.yml
ADDED
|
@@ -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
CHANGED
|
@@ -7,6 +7,11 @@ data/*.db
|
|
| 7 |
.DS_Store
|
| 8 |
notebooks/
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# JupyterLab extension build artifacts
|
| 11 |
labextension/lib/
|
| 12 |
labextension/node_modules/
|
|
|
|
| 7 |
.DS_Store
|
| 8 |
notebooks/
|
| 9 |
|
| 10 |
+
# PyPI build artifacts
|
| 11 |
+
dist/
|
| 12 |
+
build/
|
| 13 |
+
.venv/
|
| 14 |
+
|
| 15 |
# JupyterLab extension build artifacts
|
| 16 |
labextension/lib/
|
| 17 |
labextension/node_modules/
|
README.md
CHANGED
|
@@ -65,6 +65,23 @@ No cloud. No signup. No GPU needed. Just `make run` β or try it instantly on H
|
|
| 65 |
|
| 66 |
Or open any problem directly in Google Colab β every notebook has an [](https://colab.research.google.com/github/duoan/TorchCode/blob/master/templates/01_relu.ipynb) badge.
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
### Option 1 β Pull the pre-built image (fastest)
|
| 69 |
|
| 70 |
```bash
|
|
@@ -260,6 +277,35 @@ No registration needed. The judge picks it up automatically.
|
|
| 260 |
|
| 261 |
---
|
| 262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
## β FAQ
|
| 264 |
|
| 265 |
<details>
|
|
|
|
| 65 |
|
| 66 |
Or open any problem directly in Google Colab β every notebook has an [](https://colab.research.google.com/github/duoan/TorchCode/blob/master/templates/01_relu.ipynb) badge.
|
| 67 |
|
| 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 |
+
|
| 85 |
### Option 1 β Pull the pre-built image (fastest)
|
| 86 |
|
| 87 |
```bash
|
|
|
|
| 277 |
|
| 278 |
---
|
| 279 |
|
| 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 |
+
|
| 309 |
## β FAQ
|
| 310 |
|
| 311 |
<details>
|
pyproject.toml
ADDED
|
@@ -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
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
from setuptools import setup, find_packages
|
| 2 |
|
|
|
|
| 3 |
setup(
|
| 4 |
name="torch_judge",
|
| 5 |
version="0.1.0",
|
| 6 |
-
packages=find_packages(),
|
| 7 |
python_requires=">=3.10",
|
| 8 |
)
|
|
|
|
| 1 |
from setuptools import setup, find_packages
|
| 2 |
|
| 3 |
+
# Only ship torch_judge for PyPI; rest of repo (labextension, templates, etc.) stays local.
|
| 4 |
setup(
|
| 5 |
name="torch_judge",
|
| 6 |
version="0.1.0",
|
| 7 |
+
packages=find_packages(include=["torch_judge", "torch_judge.*"]),
|
| 8 |
python_requires=">=3.10",
|
| 9 |
)
|