Skip to content

Commit

Permalink
split release.yml github action out of test.yml
Browse files Browse the repository at this point in the history
update pre-commit hooks
  • Loading branch information
janosh committed Nov 10, 2024
1 parent f90ba98 commit 3a61cd5
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/paper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
paper-path: paper/paper.md

- name: Upload
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: paper
# This is the output path where Pandoc will write the compiled PDF.
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
tests:
uses: ./.github/workflows/test.yml

release:
runs-on: ubuntu-latest
needs: tests
if: needs.tests.result == 'success'
permissions:
id-token: write
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Build and upload dist
run: |
pip install build twine
python -m build
twine check dist/* --strict
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
paths: ["**/*.py", ".github/workflows/test.yml"]
release:
types: [published]
workflow_dispatch:
workflow_call:

jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
uses: janosh/workflows/.github/workflows/pytest-release.yml@main
uses: janosh/workflows/.github/workflows/pytest.yml@main
with:
os: ${{ matrix.os }}
install-cmd: pip install .[test,excel]
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
rev: v0.7.3
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.13.0
hooks:
- id: mypy

Expand All @@ -39,7 +39,7 @@ repos:
args: [--check-filenames]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.0
hooks:
- id: nbstripout
args: [--drop-empty-cells, --keep-output]
6 changes: 2 additions & 4 deletions examples/functorch_mlp_ensemble.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@
"\n",
" plt.scatter(*points.T, c=labels)\n",
" plt.gca().set(xlabel=\"x\", ylabel=\"y\", title=f\"{noise_std=}\")\n",
" plt.show()\n",
"\n"
" plt.show()"
]
},
{
Expand Down Expand Up @@ -313,8 +312,7 @@
"ax.set_ylabel(\"loss\", color=\"tab:blue\")\n",
"ax2 = ax.twinx()\n",
"ax2.plot(list(metrics), [v[\"acc\"] for v in metrics.values()], color=\"red\")\n",
"ax2.set_ylabel(\"accuracy\", color=\"tab:red\")\n",
"\n"
"ax2.set_ylabel(\"accuracy\", color=\"tab:red\")"
]
},
{
Expand Down
18 changes: 7 additions & 11 deletions examples/wandb_integration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
"\n",
"import pandas as pd\n",
"import torch\n",
"import torch.nn as nn\n",
"import torchvision\n",
"import wandb\n",
"from torch import nn\n",
"from tqdm import tqdm"
]
},
Expand Down Expand Up @@ -183,8 +183,7 @@
" \"learning_rate\": 0.005,\n",
" \"dataset\": \"MNIST\",\n",
" \"architecture\": \"CNN\",\n",
"}\n",
"\n"
"}"
]
},
{
Expand Down Expand Up @@ -282,8 +281,7 @@
" out = self.layer1(x)\n",
" out = self.layer2(out)\n",
" out = out.reshape(out.size(0), -1)\n",
" return self.fc(out)\n",
"\n"
" return self.fc(out)"
]
},
{
Expand Down Expand Up @@ -373,8 +371,7 @@
" wandb.log(\n",
" {\"epoch\": epoch, \"loss\": loss, \"accuracy\": accuracy},\n",
" step=sample_count,\n",
" )\n",
"\n"
" )"
]
},
{
Expand Down Expand Up @@ -520,8 +517,7 @@
"\n",
" wandb.finish()\n",
"\n",
" return model\n",
"\n"
" return model"
]
},
{
Expand Down Expand Up @@ -657,7 +653,7 @@
}
],
"source": [
"timestamp = f\"{datetime.now():%Y-%m-%d@%H:%M}\"\n",
"timestamp = f\"{datetime.now().astimezone():%Y-%m-%d@%H:%M}\"\n",
"config[\"ensemble_id\"] = timestamp\n",
"# Build and train ensemble of models\n",
"n_models = 5\n",
Expand Down Expand Up @@ -707,7 +703,7 @@
}
],
"source": [
"today = f\"{datetime.now():%Y-%m-%d}\"\n",
"today = f\"{datetime.now().astimezone():%Y-%m-%d}\"\n",
"\n",
"api = wandb.Api()\n",
"runs = api.runs(\n",
Expand Down
12 changes: 6 additions & 6 deletions paper/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ @online{fey_fast_2019
author = {Fey, Matthias and Lenssen, Jan Eric},
date = {2019-04-25},
eprint = {1903.02428},
eprinttype = {arxiv},
eprinttype = {arXiv},
eprintclass = {cs, stat},
doi = {10.48550/arXiv.1903.02428},
url = {http://arxiv.org/abs/1903.02428},
urldate = {2022-08-27},
pubstate = {preprint},
pubstate = {prepublished},
keywords = {Computer Science - Machine Learning,Statistics - Machine Learning}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ @unpublished{kendall_what_2017
author = {Kendall, Alex and Gal, Yarin},
date = {2017-10-05},
eprint = {1703.04977},
eprinttype = {arxiv},
eprinttype = {arXiv},
eprintclass = {cs},
url = {http://arxiv.org/abs/1703.04977},
urldate = {2020-08-31},
Expand All @@ -113,7 +113,7 @@ @unpublished{lakshminarayanan_simple_2016
author = {Lakshminarayanan, Balaji and Pritzel, Alexander and Blundell, Charles},
date = {2016-12-05},
eprint = {1612.01474},
eprinttype = {arxiv},
eprinttype = {arXiv},
eprintclass = {cs, stat},
url = {http://arxiv.org/abs/1612.01474},
urldate = {2019-03-03},
Expand All @@ -126,11 +126,11 @@ @online{paszke_pytorch_2019
author = {Paszke, Adam and Gross, Sam and Massa, Francisco and Lerer, Adam and Bradbury, James and Chanan, Gregory and Killeen, Trevor and Lin, Zeming and Gimelshein, Natalia and Antiga, Luca and Desmaison, Alban and Köpf, Andreas and Yang, Edward and DeVito, Zach and Raison, Martin and Tejani, Alykhan and Chilamkurthy, Sasank and Steiner, Benoit and Fang, Lu and Bai, Junjie and Chintala, Soumith},
date = {2019-12-03},
eprint = {1912.01703},
eprinttype = {arxiv},
eprinttype = {arXiv},
eprintclass = {cs, stat},
doi = {10.48550/arXiv.1912.01703},
url = {http://arxiv.org/abs/1912.01703},
urldate = {2022-08-27},
pubstate = {preprint},
pubstate = {prepublished},
keywords = {Computer Science - Machine Learning,Computer Science - Mathematical Software,Statistics - Machine Learning}
}

0 comments on commit 3a61cd5

Please sign in to comment.