Skip to content

Commit f93e0d5

Browse files
authored
Merge branch 'main' into window_by
2 parents 96731b8 + 57f36ab commit f93e0d5

File tree

8 files changed

+235
-1
lines changed

8 files changed

+235
-1
lines changed

.cirun.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Self-Hosted Github Action Runners on GCP via Cirun.io
2+
# Reference: https://docs.cirun.io/reference/yaml.html
3+
runners:
4+
- name: gpu-runner
5+
# Cloud Provider: GCP
6+
cloud: gcp
7+
# Cheapest GPU on GCP
8+
gpu: nvidia-tesla-t4
9+
# Cheapest VM on GCP, with GPU attachable
10+
instance_type: n1-standard-1
11+
# Ubuntu-20.4, can be seen from "gcloud compute images list"
12+
machine_image: ubuntu-minimal-2004-lts
13+
# preemptible instances seems quite less reliable.
14+
preemptible: false
15+
# Path of the relevant workflow file
16+
workflow: .github/workflows/build-gpu.yml
17+
# Number of runners to provision on every trigger on Actions job
18+
# 3 because testing on Python 3.7, 3.8, 3.9
19+
# See .github/workflows/build-gpu.yml
20+
count: 3
21+
# Adding the GPU label, this matches the runs-on param from .github/workflows/build-gpu.yml
22+
# So that this runner is selected for running .github/workflows/build-gpu.yml
23+
labels:
24+
- gpu

.github/scripts/test_sgkit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sgkit as sg
2+
3+
if __name__ == "__main__":
4+
ds = sg.simulate_genotype_call_dataset(n_variant=100, n_sample=50, n_contig=23)
5+
print(ds)

.github/scripts/test_sgkit_bgen.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import urllib.request
2+
3+
from sgkit.io.bgen import read_bgen
4+
5+
if __name__ == "__main__":
6+
urllib.request.urlretrieve(
7+
"https://github.com/pystatgen/sgkit/raw/main/sgkit/tests/io/bgen/data/example.bgen",
8+
"example.bgen",
9+
)
10+
ds = read_bgen("example.bgen")
11+
print(ds)

.github/scripts/test_sgkit_plink.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import urllib.request
2+
3+
from sgkit.io.plink import read_plink
4+
5+
if __name__ == "__main__":
6+
for ext in (".bed", ".bim", ".fam"):
7+
urllib.request.urlretrieve(
8+
f"https://github.com/pystatgen/sgkit/raw/main/sgkit/tests/io/plink/data/plink_sim_10s_100v_10pmiss{ext}",
9+
f"plink_sim_10s_100v_10pmiss{ext}",
10+
)
11+
ds = read_plink(path="plink_sim_10s_100v_10pmiss")
12+
print(ds)

.github/scripts/test_sgkit_vcf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import urllib.request
2+
3+
import xarray as xr
4+
5+
from sgkit.io.vcf import vcf_to_zarr
6+
7+
if __name__ == "__main__":
8+
for ext in (".gz", ".gz.tbi"):
9+
urllib.request.urlretrieve(
10+
f"https://github.com/pystatgen/sgkit/raw/main/sgkit/tests/io/vcf/data/sample.vcf{ext}",
11+
f"sample.vcf{ext}",
12+
)
13+
vcf_to_zarr("sample.vcf.gz", "out")
14+
ds = xr.open_zarr("out") # type: ignore[no-untyped-call]
15+
print(ds)

.github/workflows/build-gpu.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build GPU
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
12+
runs-on: [self-hosted, gpu]
13+
defaults:
14+
run:
15+
shell: bash -l {0}
16+
strategy:
17+
matrix:
18+
python-version: [3.7, 3.8, 3.9]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Run Nvidia-smi
24+
run: |
25+
nvidia-smi
26+
27+
- name: Set up Python
28+
uses: conda-incubator/setup-miniconda@v2
29+
env:
30+
CONDA: /home/runnerx/miniconda3
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
miniconda-version: "latest"
34+
35+
- name: Install dependencies
36+
run: |
37+
conda install -c anaconda cudatoolkit
38+
pip install -r requirements.txt -r requirements-dev.txt
39+
40+
- name: Run GPU tagged tests
41+
run: |
42+
pytest -m gpu -v

.github/workflows/wheels.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Wheels
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- test
8+
tags:
9+
- '*'
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
build:
15+
# This workflow only runs on the origin org
16+
if: github.repository_owner == 'pystatgen'
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
python-version: [3.7]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install setuptools twine wheel
32+
- name: Build a source distribution and a wheel
33+
run: |
34+
python setup.py sdist bdist_wheel
35+
python -m twine check --strict dist/*
36+
- name: Upload artifacts
37+
uses: actions/upload-artifact@v2
38+
with:
39+
path: dist
40+
41+
unix-test:
42+
# This workflow only runs on the origin org
43+
if: github.repository_owner == 'pystatgen'
44+
needs: ['build']
45+
strategy:
46+
matrix:
47+
os: [ubuntu-latest, macos-latest]
48+
python-version: [3.7, 3.8, 3.9]
49+
runs-on: ${{ matrix.os }}
50+
steps:
51+
# checkout repo to subdirectory to get access to scripts
52+
- uses: actions/checkout@v2
53+
with:
54+
path: sgkit-copy
55+
- name: Download artifacts
56+
uses: actions/download-artifact@v2
57+
- name: Set up Python ${{ matrix.python-version }}
58+
uses: actions/setup-python@v2
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
- name: Install wheel and test
62+
run: |
63+
python -VV
64+
# Install the local wheel
65+
wheel=$(ls artifact/sgkit-*.whl)
66+
pip install ${wheel} ${wheel}[bgen] ${wheel}[plink] ${wheel}[vcf]
67+
python sgkit-copy/.github/scripts/test_sgkit.py
68+
python sgkit-copy/.github/scripts/test_sgkit_bgen.py
69+
python sgkit-copy/.github/scripts/test_sgkit_plink.py
70+
python sgkit-copy/.github/scripts/test_sgkit_vcf.py
71+
72+
# Windows doesn't support vcf
73+
windows-test:
74+
# This workflow only runs on the origin org
75+
if: github.repository_owner == 'pystatgen'
76+
runs-on: windows-latest
77+
needs: ['build']
78+
strategy:
79+
matrix:
80+
python-version: [3.7, 3.8, 3.9]
81+
steps:
82+
# checkout repo to subdirectory to get access to scripts
83+
- uses: actions/checkout@v2
84+
with:
85+
path: sgkit-copy
86+
- name: Download artifacts
87+
uses: actions/download-artifact@v2
88+
- name: Set up Python ${{ matrix.python-version }}
89+
uses: actions/setup-python@v2
90+
with:
91+
python-version: ${{ matrix.python-version }}
92+
- name: Install wheel and test
93+
run: |
94+
python -VV
95+
# Install the local wheel
96+
$env:wheel = $(ls artifact/sgkit-*.whl)
97+
pip install $env:wheel "$env:wheel[bgen]" "$env:wheel[plink]"
98+
python sgkit-copy/.github/scripts/test_sgkit.py
99+
python sgkit-copy/.github/scripts/test_sgkit_bgen.py
100+
python sgkit-copy/.github/scripts/test_sgkit_plink.py
101+
102+
pypi-upload:
103+
if: github.repository_owner == 'pystatgen'
104+
runs-on: ubuntu-latest
105+
needs: ['unix-test', 'windows-test']
106+
steps:
107+
- name: Download all
108+
uses: actions/download-artifact@v2
109+
- name: Move to dist
110+
run: |
111+
mkdir dist
112+
cp */*.{whl,gz} dist/.
113+
- name: Publish package to TestPyPI
114+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
user: __token__
118+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
119+
repository_url: https://test.pypi.org/legacy/
120+
- name: Publish package to PyPI
121+
if: github.event_name == 'release'
122+
uses: pypa/gh-action-pypi-publish@release/v1
123+
with:
124+
user: __token__
125+
password: ${{ secrets.PYPI_API_TOKEN }}

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Ignore VCF files during pytest collection, so it doesn't fail if cyvcf2 isn't installed.
2-
collect_ignore_glob = ["sgkit/io/vcf/*.py"]
2+
collect_ignore_glob = ["sgkit/io/vcf/*.py", ".github/scripts/*.py"]
33

44

55
def pytest_configure(config) -> None: # type: ignore

0 commit comments

Comments
 (0)