Skip to content

Commit 5e0634a

Browse files
authored
Merge pull request #11 from AdaptiveMotorControlLab/mwm/tests-packaging
some re-arrangement & additions for python packaging
2 parents 7960ad5 + f360df6 commit 5e0634a

File tree

17 files changed

+265
-35
lines changed

17 files changed

+265
-35
lines changed

β€Ž.github/workflows/build.yamlβ€Ž

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
os: [ubuntu-latest]
17+
python-version: ["3.12"]
18+
# We aim to support the versions on pytorch.org
19+
# as well as selected previous versions on
20+
# https://pytorch.org/get-started/previous-versions/
21+
torch-version: ["2.4.0"]
22+
include:
23+
- os: windows-latest
24+
torch-version: 2.4.0
25+
python-version: "3.12"
26+
27+
runs-on: ${{ matrix.os }}
28+
29+
steps:
30+
- name: Cache dependencies
31+
id: pip-cache
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.cache/pip
35+
key: pip-os_${{ runner.os }}-python_${{ matrix.python-version }}-torch_${{ matrix.torch-version }}
36+
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
40+
- name: Set up Python ${{ matrix.python-version }}
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ matrix.python-version }}
44+
45+
- name: Install package
46+
run: |
47+
python -m pip install git+https://github.com/RobustBench/robustbench.git
48+
python -m pip install --upgrade pip setuptools wheel
49+
python -m pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/cpu
50+
pip install '.[dev]'
51+
52+
- name: Run pytest tests
53+
timeout-minutes: 10
54+
run: |
55+
pip install pytest
56+
python -m pytest
57+
58+
- name: Build package
59+
run: |
60+
make build
61+
62+
- name: Check reinstall script
63+
timeout-minutes: 3
64+
run: |
65+
./reinstall.sh
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Codespell
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
codespell:
12+
name: Check for spelling errors
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Codespell
19+
uses: codespell-project/actions-codespell@v1
20+
with:
21+
ignore_words_list: aros, fpr, tpr, idx, fpr95
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
pull_request:
8+
branches:
9+
- main
10+
types:
11+
- labeled
12+
- opened
13+
- edited
14+
- synchronize
15+
- reopened
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Cache dependencies
23+
id: pip-cache
24+
uses: actions/cache@v3
25+
with:
26+
path: ~/.cache/pip
27+
key: ${{ runner.os }}-pip
28+
29+
- name: Checkout code
30+
uses: actions/checkout@v3
31+
32+
- name: Build and publish to Test PyPI
33+
if: ${{ (github.ref != 'refs/heads/main') && (github.event.label.name == 'release') }}
34+
env:
35+
TWINE_USERNAME: __token__
36+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
37+
run: |
38+
make dist
39+
ls dist/
40+
tar tvf dist/aros-node-*.tar.gz
41+
python3 -m twine upload --repository testpypi dist/*
42+
43+
- name: Build and publish to PyPI
44+
if: ${{ github.event_name == 'push' }}
45+
env:
46+
TWINE_USERNAME: __token__
47+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
48+
run: |
49+
make dist
50+
ls dist/
51+
tar tvf dist/aros-node-*.tar.gz
52+
python3 -m twine upload dist/*

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
.tar.gz
23

34
# Byte-compiled / optimized / DLL files
45
__pycache__/

β€ŽAROS/__init__.pyβ€Ž

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

β€Žaros_node/__init__.pyβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Β© M.W. Mathis Lab | Hossein Mirzaei & M.W. Mathis
2+
# https://github.com/AdaptiveMotorControlLab/AROS
3+
# Licensed under Apache 2.0
4+
5+
from aros_node.version import __version__
6+
from aros_node.data_loader import LabelChangedDataset, get_subsampled_subset, get_loaders
7+
from aros_node.evaluate import compute_fpr95, compute_auroc, compute_aupr, get_clean_AUC, wrapper_method
8+
from aros_node.stability_loss_function import *
9+
from aros_node.utils import *
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
from tqdm.notebook import tqdm
33
from sklearn.metrics import roc_curve, roc_auc_score, precision_recall_curve, auc
4-
from utils import *
4+
from aros_node.utils import *
55
import argparse
66
import torch
77
import torch.nn as nn
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from robustbench.utils import load_model
33
import torch.nn as nn
44
from torch.nn.parameter import Parameter
5-
import utils
6-
from utils import *
5+
import aros_node.utils
6+
from aros_node.utils import *
77
from torch.utils.data import DataLoader, Dataset, TensorDataset, Subset, SubsetRandomSampler, ConcatDataset
88
import numpy as np
99
from tqdm.notebook import tqdm
File renamed without changes.

0 commit comments

Comments
Β (0)