Skip to content

Commit eb92fdc

Browse files
authored
Feature/deploy (#4)
* Init CI/CD * Replaced mypy with ty type checker, added JSON test exclusions, fixed type hints and code style. * Added jinja2 and tqdm dependencies, pandas dev dependency, improved test skip handling for LMOD and UGE. * Updated shell import to hpc_funcs, removed test_status.py, added UGE skip check. * Removed Development Status classifier from pyproject.toml. * Removed empty test_slurm.py file. * Removed code-quality workflow, simplified publish workflow with make targets. * Updated ty pre-commit hook to use system language. * Updated format check to use activated virtual environment.
1 parent 699c3e9 commit eb92fdc

34 files changed

Lines changed: 382 additions & 604 deletions

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
name: Build & Publish
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
20+
- name: Install build dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install build twine
24+
25+
- name: Build package
26+
run: make build
27+
28+
- name: Check distribution
29+
run: make test-dist
30+
31+
- name: Publish to PyPI
32+
env:
33+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
34+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35+
run: make upload

.github/workflows/test.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
test:
12+
name: Test Python ${{ matrix.python-version }}
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
shell: bash -l {0}
17+
strategy:
18+
matrix:
19+
python-version: ['3.11', '3.12', '3.13']
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: astral-sh/setup-uv@v7
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Create environment
29+
run: make env python-version=${{ matrix.python-version }}
30+
31+
- name: Run tests
32+
run: source ./env/bin/activate && make test python=python
33+
34+
- name: Check format and types
35+
run: source ./env/bin/activate && make format
36+
37+
- name: Build package
38+
run: source ./env/bin/activate && make build
39+
40+
- name: Check distribution
41+
run: source ./env/bin/activate && make test-dist
42+
43+
- name: Test installation from wheel
44+
run: |
45+
pip install dist/*.whl
46+
python -c "import hpc_funcs; print(hpc_funcs.__version__)"

.pre-commit-config.yaml

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
repos:
22

33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v3.4.0
4+
rev: v5.0.0
55
hooks:
66
- id: trailing-whitespace
77
exclude: ^tests/resources/
88
- id: end-of-file-fixer
99
exclude: ^tests/resources/
1010
- id: check-yaml
1111
args: ["--unsafe"]
12-
- id: check-added-large-files
1312
- id: check-ast
1413
- id: check-json
14+
exclude: ^tests/resources/uge/qstat_jobinfo_(array|error)\.json$
1515
- id: debug-statements
1616
- id: detect-aws-credentials
1717
args: [--allow-missing-credentials]
@@ -20,79 +20,31 @@ repos:
2020
- id: check-added-large-files
2121
args: ['--maxkb=3000']
2222

23-
- repo: https://github.com/myint/autoflake
24-
rev: v2.3.1
25-
hooks:
26-
- id: autoflake
27-
name: Removes unused variables
28-
args:
29-
- --in-place
30-
- --remove-all-unused-imports
31-
- --expand-star-imports
32-
- --ignore-init-module-imports
33-
34-
- repo: https://github.com/pre-commit/mirrors-isort
35-
rev: v5.10.1
36-
hooks:
37-
- id: isort
38-
name: Sorts imports
39-
args: [
40-
# Align isort with black formatting
41-
"--multi-line=3",
42-
"--trailing-comma",
43-
"--force-grid-wrap=0",
44-
"--use-parentheses",
45-
"--line-width=99",
46-
]
47-
48-
- repo: https://github.com/psf/black
49-
rev: 24.10.0
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.11.6
5025
hooks:
51-
- id: black
52-
name: Fixes formatting
53-
language_version: python3
54-
args: ["--line-length=99"]
55-
56-
57-
- repo: https://github.com/pycqa/flake8
58-
rev: 7.1.1
59-
hooks:
60-
- id: flake8
61-
name: Checks pep8 style
62-
args: [
63-
"--max-line-length=99",
64-
# Ignore imports in init files
65-
"--per-file-ignores=*/__init__.py:F401,setup.py:E121",
66-
# ignore long comments (E501), as long lines are formatted by black
67-
# ignore Whitespace before ':' (E203)
68-
# ignore Line break occurred before a binary operator (W503)
69-
"--ignore=E501,E203,W503",
70-
]
71-
72-
# - repo: https://github.com/pre-commit/mirrors-mypy
73-
# rev: v0.782
74-
# hooks:
75-
# - id: mypy
76-
# args: [--ignore-missing-imports]
26+
- id: ruff
27+
args: [--fix]
28+
- id: ruff-format
7729

7830
- repo: local
7931
hooks:
8032

81-
- id: mypy
33+
- id: ty
8234
name: Static type checking
83-
entry: mypy
84-
files: \.py$
85-
language: python
35+
entry: ty check
36+
files: ^src/.*\.py$
37+
language: system
8638

8739
- id: jupyisort
8840
name: Sorts ipynb imports
89-
entry: jupytext --pipe-fmt ".py" --pipe "isort - --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=99" --sync
41+
entry: jupytext --pipe-fmt ".py" --pipe "ruff check --select I --fix -" --sync
9042
files: \.ipynb$
9143
language: python
9244

93-
- id: jupyblack
45+
- id: jupyformat
9446
name: Fixes ipynb format
95-
entry: jupytext --pipe-fmt ".py" --pipe "black - --line-length=99" --sync
47+
entry: jupytext --pipe-fmt ".py" --pipe "ruff format -" --sync
9648
files: \.ipynb$
9749
language: python
9850

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: update-format format test test-dist build types upload cov
1+
.PHONY: update-format format check test test-dist build types upload cov clean clean-env
22

33
package=hpc_funcs
44
version_file1=./src/hpc_funcs/version.py
@@ -21,16 +21,10 @@ env: ${env}_uv
2121

2222
env_uv:
2323
uv venv ${env}
24-
uv pip install -r requirements.txt --python ${env}/bin/python
2524
uv pip install -e . --python ${env}/bin/python
25+
uv pip install -e .[dev] --python ${env}/bin/python
2626
${python} -m pre_commit install
2727

28-
env_conda:
29-
conda env create -f ./environment.yml -p ${env} --quiet
30-
${python} -m pre_commit install
31-
${python} -m pip install -e .
32-
33-
3428
## Development
3529

3630
update-format:
@@ -39,6 +33,8 @@ update-format:
3933
format:
4034
${python} -m pre_commit run --all-files
4135

36+
check: format types
37+
4238
test:
4339
${python} -m pytest ./tests
4440

@@ -107,3 +103,7 @@ clean:
107103
rm -rf *.whl
108104
rm -rf ./build/ ./__pycache__/
109105
rm -rf ./dist/
106+
107+
clean-env:
108+
rm -rf ./${env}/
109+
rm -f .git/hooks/pre-commit

pyproject.toml

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,96 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm"]
2+
requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "hpce_utils"
6+
name = "hpc_funcs"
77
dynamic = ["version"]
88
authors = []
9+
description = "HPC utility functions"
10+
readme = "README.md"
11+
license = {text = "MIT"}
912
requires-python = ">=3.11"
13+
classifiers = [
14+
"Intended Audience :: Science/Research",
15+
"License :: OSI Approved :: MIT License",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
20+
]
21+
dependencies = [
22+
"jinja2",
23+
"tqdm",
24+
]
25+
26+
[project.optional-dependencies]
27+
dev = [
28+
"ruff",
29+
"ty",
30+
"pip",
31+
"pre-commit",
32+
"pytest",
33+
"pytest-cov",
34+
"pandas",
35+
"twine",
36+
"build",
37+
"monkeytype",
38+
]
1039

1140
[tool.setuptools.dynamic]
12-
version = {attr = "hpce_utils.version.VERSION"}
41+
version = {attr = "hpc_funcs.version.__version__"}
1342

14-
[options.packages.find]
15-
where="src"
43+
[tool.setuptools.packages.find]
44+
where = ["src"]
1645

1746
[tool.setuptools.package-data]
18-
"*" = ["*.jinja"]
47+
"*" = ["*.jinja", "py.typed"]
48+
49+
[tool.ruff]
50+
line-length = 99
51+
target-version = "py311"
52+
exclude = [
53+
".git",
54+
".github",
55+
"__pycache__",
56+
"build",
57+
"dist",
58+
"*.egg-info",
59+
"env",
60+
]
61+
62+
[tool.ruff.lint]
63+
select = [
64+
"E", # pycodestyle errors
65+
"F", # pyflakes
66+
"I", # isort (import sorting)
67+
"UP", # pyupgrade (modern Python syntax)
68+
"B", # flake8-bugbear
69+
"C4", # flake8-comprehensions
70+
"SIM", # flake8-simplify
71+
]
72+
73+
[tool.ruff.lint.isort]
74+
known-first-party = ["hpc_funcs"]
75+
76+
[tool.ruff.lint.per-file-ignores]
77+
"tests/*" = ["B017", "B023", "E501"]
78+
"*/__init__.py" = ["F401"]
79+
80+
[tool.ty]
81+
# Type checking with ty (Astral's extremely fast Python type checker)
82+
83+
[tool.ty.environment]
84+
python-version = "3.11"
85+
86+
[tool.ty.src]
87+
exclude = ["tests/"]
88+
89+
[tool.ty.rules]
90+
# Ignore unresolved imports since pre-commit env doesn't have all packages
91+
unresolved-import = "ignore"
92+
93+
[tool.pytest.ini_options]
94+
testpaths = ["tests"]
95+
log_cli = true
96+
log_cli_level = "DEBUG"

setup.py

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

0 commit comments

Comments
 (0)