Skip to content

Commit ae28691

Browse files
committed
code refactoring, fastkde==2.1.3
0 parents  commit ae28691

39 files changed

+8356
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# This workflow builds a Python package and publishes it to PyPI and TestPyPI.
2+
name: Publish to PyPI and TestPyPI
3+
4+
on:
5+
push:
6+
branches: ["main"]
7+
tags:
8+
- "v*.*.*" # Match semantic version tags
9+
workflow_dispatch:
10+
# Allow manual dispatch for testing or immediate releases
11+
12+
jobs:
13+
build:
14+
name: Build distributions
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python 3.11
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.11
24+
25+
- name: Cache pip
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
30+
31+
- name: Install uv and sync deps, build sdist and wheel
32+
run: |
33+
python3 -m pip install --upgrade pip
34+
python3 -m pip install uv
35+
python3 -m uv sync --extra cpu
36+
python3 -m uv build
37+
38+
- name: Upload dist/*
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: python-distribution-packages
42+
path: dist/*
43+
44+
publish-testpypi:
45+
name: Publish to TestPyPI
46+
needs: build
47+
runs-on: ubuntu-latest
48+
environment:
49+
name: testpypi
50+
url: https://test.pypi.org/p/torchvinecopulib/
51+
permissions:
52+
id-token: write
53+
# contents: write
54+
steps:
55+
- name: Download dist/*
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: python-distribution-packages
59+
path: dist/
60+
61+
- name: Publish to TestPyPI
62+
uses: pypa/gh-action-pypi-publish@release/v1
63+
with:
64+
verbose: true
65+
skip-existing: true
66+
repository-url: https://test.pypi.org/legacy/
67+
env:
68+
TWINE_USERNAME: __token__
69+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
70+
71+
publish-pypi:
72+
name: Publish to PyPI
73+
runs-on: ubuntu-latest
74+
needs: publish-testpypi
75+
if: startsWith(github.ref, 'refs/tags/v')
76+
environment:
77+
name: pypi
78+
url: https://pypi.org/project/torchvinecopulib/
79+
permissions:
80+
id-token: write
81+
# contents: write
82+
steps:
83+
- name: Download dist/*
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: python-distribution-packages
87+
path: dist/
88+
89+
- name: Publish to PyPI via Twine
90+
uses: pypa/gh-action-pypi-publish@release/v1
91+
env:
92+
TWINE_USERNAME: __token__
93+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
94+
with:
95+
verbose: true
96+
skip-existing: true
97+
98+
github-release:
99+
name: Create GitHub Release
100+
runs-on: ubuntu-latest
101+
needs: publish-testpypi
102+
if: startsWith(github.ref, 'refs/tags/v')
103+
permissions:
104+
contents: write
105+
id-token: write
106+
107+
steps:
108+
- name: Download dist/*
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: python-distribution-packages
112+
path: dist/
113+
114+
- name: Sign the distribution packages with Sigstore
115+
uses: sigstore/[email protected]
116+
with:
117+
inputs: |
118+
./dist/*.tar.gz
119+
./dist/*.whl
120+
121+
- name: Create GitHub Release and Upload Assets
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
run: |
125+
gh release create "${{ github.ref_name }}" \
126+
--repo "${{ github.repository }}" \
127+
--title "Release ${{ github.ref_name }}" \
128+
--notes "Automated release for ${{ github.ref_name }}. Signed artifacts are attached." \
129+
dist/*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Lint Pytest
5+
6+
on:
7+
push:
8+
branches: ["main"]
9+
pull_request:
10+
branches: ["main"]
11+
12+
workflow_dispatch:
13+
14+
jobs:
15+
lint-pytest:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest, windows-latest, macos-latest]
21+
python-version: ["3.11", "3.12", "3.13"]
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Cache pip
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
36+
37+
- name: Install uv and sync deps
38+
run: |
39+
python3 -m pip install --upgrade pip
40+
python3 -m pip install uv
41+
python3 -m uv sync --extra cpu
42+
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
43+
44+
- name: Lint with flake8
45+
run: |
46+
# stop the build if there are Python syntax errors or undefined names
47+
uv run flake8 ./torchvinecopulib --exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics
48+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
49+
uv run flake8 ./torchvinecopulib --count --exit-zero --max-complexity=10 --max-line-length=127 --ignore=E203,W503,E501,C901 --statistics
50+
51+
- name: Test with pytest
52+
run: |
53+
uv run python -c "import sys; print(sys.version)"
54+
uv run python -c "import torch; print(torch.cuda.is_available())"
55+
uv run coverage run --source=torchvinecopulib -m pytest tests
56+
uv run coverage report
57+
uv run coverage xml -o coverage.xml
58+
59+
- name: Upload coverage to Codacy
60+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' }}
61+
run: |
62+
export CODACY_API_BASE_URL=${{ secrets.CODACY_API_BASE_URL }}
63+
export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
64+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./coverage.xml

.github/workflows/static.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This workflow builds and deploys the documentation to GitHub Pages
2+
name: Deploy Docs
3+
4+
on:
5+
# Trigger after your Lint Pytest workflow completes on main branch
6+
workflow_run:
7+
workflows: ["Lint Pytest"]
8+
types: [completed]
9+
branches: ["main"]
10+
11+
# ALso allow manual dispatch
12+
workflow_dispatch:
13+
14+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
15+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
deploy:
22+
if: ${{github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write # for pushing to gh-pages branch
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Python 3.11
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.11"
35+
36+
- name: Cache pip
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.cache/pip
40+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
41+
42+
- name: Install uv and sync deps
43+
run: |
44+
python3 -m pip install --upgrade pip
45+
python3 -m pip install uv
46+
python3 -m uv sync --extra cpu
47+
48+
- name: Build Sphinx docs
49+
# regenerate module RST files (force) and build HTML docs
50+
run: |
51+
uv run sphinx-apidoc --force -o docs torchvinecopulib/ --separate
52+
uv run sphinx-build -b html docs/ docs/_build/html
53+
54+
# Deploy to gh-pages branch
55+
56+
- name: Deploy to gh-pages branch
57+
uses: peaceiris/actions-gh-pages@v4
58+
with:
59+
force_orphan: true
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
publish_branch: gh-pages
62+
publish_dir: docs/_build/html

0 commit comments

Comments
 (0)