Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for python 3.11 #207

Merged
merged 95 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
ebd5444
support py3.11 now that pysam does (in v0.21.0)
aryarm Apr 12, 2023
c95a4e7
update lock file for py3.11
aryarm Apr 12, 2023
4af294e
use newer version of nox-poetry for py3.11
aryarm Apr 12, 2023
684518c
update nox-poetry in pyproject too
aryarm Apr 12, 2023
7e71b9c
downgrade py version in which poetry and nox are installed
aryarm Apr 12, 2023
eeb6764
upgrade nox pin for github action
aryarm Apr 12, 2023
570d3a9
downgrade coverage
aryarm Apr 12, 2023
a4fb97c
completely regenerate lock file
aryarm Apr 12, 2023
abffcdd
add pysam dependencies to install command
aryarm Apr 13, 2023
2cc9ae5
update necessary noxfile version
aryarm Apr 13, 2023
dc3803b
revert poetry lock file to python 3.7
aryarm Apr 19, 2023
1139025
upgrade numpy version used in tests
aryarm Apr 19, 2023
82bf90f
refmt for newer black
aryarm Apr 19, 2023
2072c16
add pysam build dependencies to noxfile in case wheels aren't available
aryarm Apr 19, 2023
82d574e
downgrade numpy version in noxfile
aryarm Apr 19, 2023
effeb36
remove pysam build dependencies
aryarm Apr 19, 2023
8cb5e2d
update docs to install correct gcc
aryarm Jul 11, 2023
a513c89
try to install custom numpy despite nox_poetry constraint
aryarm Jul 11, 2023
c9cce8b
Merge branch 'main' into feat/py311
aryarm Jul 11, 2023
a9a6aac
refmt with black
aryarm Jul 11, 2023
4c7db7d
delete comment bot action
aryarm Oct 1, 2023
21a5cf1
resolve conflicts with main
aryarm Dec 22, 2023
52cc05b
oops try again
aryarm Dec 22, 2023
8843dab
Merge branch 'main' into feat/py311
aryarm Dec 22, 2023
99d3b4b
use poetry-conda in dev setup
aryarm Dec 22, 2023
c4527ff
lock with min versions at py3.8
aryarm Dec 22, 2023
640616b
update lock hash with current pyproject.toml
aryarm Dec 22, 2023
b6e8f70
move extras into groups
aryarm Dec 22, 2023
5815916
allow py versions 3.7 <= x < 4.0
aryarm Dec 22, 2023
7fc2f37
adjust readthedocs for use with dependency groups
aryarm Dec 22, 2023
8df9531
add poetry shell command to install instructions
aryarm Dec 22, 2023
3d16f6e
use nox-poetry workaround
aryarm Dec 22, 2023
b908f0b
bump all constraints
aryarm Dec 22, 2023
594a595
try to use pip instead of pipx in github actions
aryarm Dec 22, 2023
901e4c6
try using system python with pipx
aryarm Dec 22, 2023
2d3f62b
try to use executable name
aryarm Dec 22, 2023
25b4728
note that poetry shell will need to be rerun
aryarm Dec 22, 2023
f0218b8
account for poetry + python 3.7 incompatibility
aryarm Dec 22, 2023
20f0efc
update numpy to support 3.10
aryarm Dec 22, 2023
01cc413
upgrade pip version
aryarm Dec 22, 2023
4e72c13
revert macos test to py3.10
aryarm Dec 22, 2023
0fbae05
try more recent cyvcf2
aryarm Dec 22, 2023
b84f0a4
fix lock file after bumping cyvcf2
aryarm Dec 22, 2023
10d8d57
update to cyvcf2 0.30.18 since that seemed to work on main
aryarm Dec 22, 2023
61f9a0a
bumpy cyvcf2 to 0.30.25 to try to resolve failing tests
aryarm Dec 22, 2023
fa55631
try cyvcf2 0.30.17
aryarm Dec 22, 2023
9dd1ac7
try cyvcf2 0.30.16 instead
aryarm Dec 22, 2023
0ce7ad4
revert to cyvcf2 0.30.17 b/c < 0.30.16 leads to a binary incompatibil…
aryarm Dec 22, 2023
59f7876
remove direct mention of 255 or 254 since they might be platform spec…
aryarm Dec 22, 2023
82cc5c4
refmt for black
aryarm Dec 22, 2023
9087b54
try to lock numpy version at 1.21.6
aryarm Dec 23, 2023
b837542
try to lock at numpy==1.21.6 again
aryarm Dec 23, 2023
8ff1395
try to trick poetry by editing lock file manually
aryarm Dec 23, 2023
746555d
revert to locking at numpy 1.21.1 but switch macos to 3.9
aryarm Dec 23, 2023
117deea
make numpy version conditional on py version
aryarm Dec 23, 2023
e8e8c86
try to lock dev-env.yml
aryarm Dec 23, 2023
2da4d82
try python 3.10 on macos again
aryarm Dec 23, 2023
7f1125b
revert to 746555d
aryarm Dec 23, 2023
ae91852
match constraints and locks for test dependencies
aryarm Dec 24, 2023
2d382e2
move nox and nox-poetry into global env, actually
aryarm Dec 24, 2023
b2c8824
Merge branch 'main' into feat/py311
aryarm Dec 27, 2023
daa8f98
revise devcontainer with new dev env setup
aryarm Dec 27, 2023
c127021
try to use mamba instead of pipx in github actions
aryarm Dec 27, 2023
e16b51d
dont try using mamba
aryarm Dec 27, 2023
c79bef9
try again to remove mamba
aryarm Dec 27, 2023
fbf8738
try to set channels in action
aryarm Dec 27, 2023
4208e83
try removing miniforge
aryarm Dec 27, 2023
3d0d8f4
try caching env instead of packages
aryarm Dec 27, 2023
6b044dd
move lint test into separate github action step
aryarm Dec 27, 2023
c87707d
try to retrigger github actions
aryarm Dec 27, 2023
270bfc7
fix yml error oops
aryarm Dec 27, 2023
5fd7afa
add verbose option to nox
aryarm Dec 27, 2023
12e804f
try building package internally
aryarm Dec 28, 2023
abda1e2
oops fix yml syntax error
aryarm Dec 28, 2023
bb9edab
remove build step to see if it works now
aryarm Dec 28, 2023
13dc270
Revert "remove build step to see if it works now"
aryarm Dec 29, 2023
0a35535
ensure other nox sessions are run with locked py version
aryarm Dec 29, 2023
cb6f23e
remove old lint step in testing workflow
aryarm Dec 29, 2023
1a2efe0
remove constraints.txt, superseded by dev-env.yml
aryarm Dec 29, 2023
502485d
Merge branch 'feat/py311' of github.com:CAST-genomics/haptools into f…
aryarm Dec 29, 2023
5bae0ce
rfmt to fix spacing issue
aryarm Dec 29, 2023
241c3f2
try to use --only in readthedocs build
aryarm Dec 30, 2023
70e48ed
try again but with main
aryarm Dec 30, 2023
8319686
remove --with params from install instructions
aryarm Dec 30, 2023
ca05de1
add check for size of dist/ folder
aryarm Dec 30, 2023
7a6eccd
try to break dist check
aryarm Dec 30, 2023
80625d1
restore dist check
aryarm Dec 30, 2023
da1cd03
downgrade to a 0.3 MB check for dist/
aryarm Dec 30, 2023
7ea61cb
rename dist-size check to size and remove strict channel priority
aryarm Jan 8, 2024
5ec7a44
copy trtools pr checklist
aryarm Jan 8, 2024
84fde9d
Merge branch 'main' into feat/py311
aryarm Jan 8, 2024
74b05a5
copy example from docs
aryarm Jan 12, 2024
5afcc42
adjust example to work as automated test
aryarm Jan 12, 2024
0d914e0
fix buggy example in api docs
aryarm Jan 12, 2024
bd1f466
revert commits 84fde9d..0d914e0 agh
aryarm Jan 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "mamba create -y -n haptools -c conda-forge 'poetry>=1.1.15' 'python=3.7' && conda run -n haptools poetry install -E docs -E tests",
"postCreateCommand": "mamba env create -n haptools -f dev-env.yml && conda run -n haptools poetry install",

// Configure tool-specific properties.
"customizations": {
Expand All @@ -29,7 +29,7 @@
"python.defaultInterpreterPath": "/opt/conda/envs/haptools/bin/python",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"python.venvFolders": ["/opt/conda/envs"],
"python.venvFolders": ["/home/vscode/.cache/pypoetry/virtualenvs"],
mlamkin7 marked this conversation as resolved.
Show resolved Hide resolved
"terminal.integrated.environmentChangesRelaunch": true,
"terminal.integrated.hideOnStartup": "always"
}
Expand Down
54 changes: 9 additions & 45 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
Title your PR according to [the conventional commits specification](https://www.conventionalcommits.org/).

If your pull request resolves any open issues, please list them here at the top of the PR like this:

resolves #0

## Overview

Include a one sentence summary of the changes to our code and a separate paragraph explaining relevant motivation and context.

Also, list any dependencies that are required for this change.

## Usage and Documentation

You can call the new command like this...
Documentation for all of this is linked here...

## Implementation Details

The new command works by calling the following new classes...

### WickedAwesomeClass
The primary method for this class is...

### HelperForWickedClass
This works by...

## Tests

Please describe the tests that you ran to verify your changes. All tests should be added to our test suite in the `tests/` directory. Please also list any relevant details for your test configuration (ex: the version of pip you used, if it's relevant).

1. `test_a()`
Handles the most basic case where...
2. `test_b()`
Tests that we handle...

## Future work
I didn't have a chance to do...
In the future, we may want to refactor for...


## Checklist

* [ ] I've checked to ensure there aren't already other open [pull requests](../../../pulls) for the same update/change
* [ ] I've prefixed the title of my PR according to [the conventional commits specification](https://www.conventionalcommits.org/). If your PR fixes a bug, please prefix the PR with `fix: `. Otherwise, if it introduces a new feature, please prefix it with `feat: `. If it introduces a breaking change, please add an exclamation before the colon, like `feat!: `. If the scope of the PR changes because of a revision to it, please update the PR title, since the title will be used in our CHANGELOG.
* [ ] At the top of the PR, I've [listed any open issues that this PR will resolve](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword). For example, "resolves #0" if this PR resolves issue #0
- [ ] I've explained my changes in a manner that will make it possible for both users and maintainers of haptools to understand them
* [ ] I have followed the [contributing guidelines](https://haptools.readthedocs.io/en/stable/project_info/contributing.html#how-to-fix-a-bug-or-implement-a-new-feature)
* [ ] I have adhered to the [style guidelines](https://haptools.readthedocs.io/en/stable/project_info/contributing.html#style)
* [ ] I have checked to ensure there aren't other open [pull requests](../../../pulls) for the same update/change
* [ ] (if applicable) I have added changes to the dependencies to the pyproject.toml file, and I've run `poetry lock` to ensure the lock file stays up to date

<!-- For an example that follows this PR outline, see [PR #43](https://github.com/CAST-genomics/haptools/pull/43) -->
* [ ] I've added tests for any new functionality. Or, if this PR fixes a bug, I've added test(s) that replicate it
* [ ] I've updated the relevant documentation and checked that the newly built documentation is formatted properly
* [ ] All functions, modules, classes etc. still conform to [numpy docstring standards](https://numpydoc.readthedocs.io/en/latest/format.html)
* [ ] (if applicable) I've updated the pyproject.toml file with any changes I've made to haptools's dependencies, and I've run `poetry lock --no-update` to ensure the lock file stays up to date and that our dependencies are locked to their minimum versions
* [ ] In the body of this PR, I've included a short address to the reviewer highlighting one or two items that might deserve their focus
17 changes: 0 additions & 17 deletions .github/workflows/comment_bot.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

121 changes: 54 additions & 67 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ jobs:
fail-fast: false
matrix:
include:
- { python: "3.7", os: "ubuntu-latest", session: "lint" }
- { python: "3.8", os: "ubuntu-latest", session: "lint" }
- { python: "3.7", os: "ubuntu-latest", session: "tests" }
- { python: "3.8", os: "ubuntu-latest", session: "tests" }
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
# - { python: "3.10", os: "windows-latest", session: "tests" }
- { python: "3.10", os: "macos-latest", session: "tests" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
# - { python: "3.11", os: "windows-latest", session: "tests" }
- { python: "3.9", os: "macos-latest", session: "tests" }
- { python: "3.8", os: "ubuntu-latest", session: "size" }

env:
NOXSESSION: ${{ matrix.session }}
Expand All @@ -25,90 +27,75 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}
activate-environment: haptools
miniforge-variant: Mambaforge
auto-activate-base: false
miniforge-version: latest
use-mamba: true

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Cache Conda env
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('dev-env.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if dev-env.yml has not changed
CACHE_NUMBER: 0
id: cache

- name: Install dev environment
run:
mamba env update -n haptools -f dev-env.yml
if: steps.cache.outputs.cache-hit != 'true'

- name: Try to build haptools
shell: bash -el {0}
run: |
pipx install --python python3.10 --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
poetry build --no-ansi

- name: Check distribution size
if: matrix.session == 'size'
run: |
pipx install --python python3.10 --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Run Nox
du -csh dist/*
# check that the generated dist/ directory does not exceed 0.3 MB
# if this check fails, it's because you forgot to list large files in a "tool.poetry.exclude" section of our pyproject.toml
# https://python-poetry.org/docs/pyproject/#include-and-exclude
[ $(du -b dist | cut -f1) -lt 300000 ]

- name: Run tests with nox
if: matrix.session != 'size'
shell: bash -el {0}
run: |
nox --python=${{ matrix.python }}
nox --verbose --python=${{ matrix.python }}

- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3"
with:
name: coverage-data
path: ".coverage.*"

large-files:
name: File sizes
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check for large files
uses: actionsdesk/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }} # Optional
filesizelimit: 500000b
labelName: large-files

# coverage:
# runs-on: ubuntu-latest
# needs: tests
# steps:
# - name: Check out the repository
# uses: actions/checkout@v3

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

# - name: Upgrade pip
# run: |
# pip install --constraint=.github/workflows/constraints.txt pip
# pip --version
# - name: Install Poetry
# run: |
# pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
# poetry --version
# - name: Install Nox
# run: |
# pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
# pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
# nox --version
# - name: Download coverage data
# uses: actions/download-artifact@v3
# with:
# name: coverage-data

# - name: Combine coverage data and display human readable report
# run: |
# nox --session=coverage
# - name: Create coverage report
# run: |
# nox --session=coverage -- xml
# - name: Upload coverage report
# uses: codecov/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ docs/_build/
__pycache__
# pytest and testing-related caches
.pytest_cache
.coverage
.coverage*
.nox
# poetry
dist/
Expand Down
23 changes: 13 additions & 10 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Note: I used https://github.com/readthedocs/readthedocs.org/issues/4912#issuecomment-664002569 for inspiration
# Note: I used https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-poetry for inspiration

version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.7"
python: "3.8"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- poetry install --only main,docs

sphinx:
configuration: docs/conf.py
fail_on_warning: true

python:
install:
- method: pip
path: .
extra_requirements:
- docs
- files
13 changes: 13 additions & 0 deletions dev-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- conda-forge::python=3.8 # the lowest version of python that we formally support
- conda-forge::pip==23.3.2
- conda-forge::poetry==1.7.1
- conda-forge::nox==2023.04.22
- conda-forge::poetry-plugin-export==1.6.0
- pip:
- nox-poetry==1.0.3
- poetry-conda==0.1.1
18 changes: 7 additions & 11 deletions docs/project_info/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,19 @@ Follow these steps to set up a development environment.

.. code-block:: bash

conda create -n haptools-dev -c conda-forge 'poetry>=1.1.15' 'python=3.7'
2. Activate the environment
conda env create -n haptools -f dev-env.yml
2. Install haptools and its dependencies into a separate environment managed by ``poetry``

.. code-block:: bash

conda activate haptools-dev
3. Install our dependencies
conda run -n haptools poetry install

.. code-block:: bash

poetry install -E docs -E tests
3. Now, whenever you'd like to run/import ``haptools`` or ``pytest``, you will first need to activate both environments

Now, try importing ``haptools`` or running it on the command line.

.. note::
If you run into an attribute error ``module 'distutils' has no attribute 'util'`` see `this workaround <https://github.com/python-poetry/poetry/issues/3336#issuecomment-831789763>`_.
.. code-block:: bash

conda activate haptools
poetry shell

---------------------
Managing Dependencies
Expand Down
3 changes: 2 additions & 1 deletion haptools/clump.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ def _FilterGts(candidate_gt, index_gt, log):
once converted to uint8 and sum alleles together.
"""
# Check Alleles for invalid values and remove samples from both sets of alleles
valid_gts = np.all(candidate_gt < 254, axis=1) & np.all(index_gt < 254, axis=1)
miss = np.iinfo(np.uint8).max - 1
valid_gts = np.all(candidate_gt < miss, axis=1) & np.all(index_gt < miss, axis=1)
candidate_gt = candidate_gt[valid_gts, :]
index_gt = index_gt[valid_gts, :]
log.debug(f"Valid Genotype Indices: {valid_gts}")
Expand Down
Loading
Loading