From 2d16fd158ecb8adde6f78626d1d63c76ed873086 Mon Sep 17 00:00:00 2001 From: Bruce Edelman Date: Wed, 15 Nov 2023 12:34:58 -0800 Subject: [PATCH 1/2] Break up actions into one that does linting and tests python build and other that builds and publishes the wheel --- .../workflows/{ => deprecated}/deploy.yaml | 0 .../{python-app.yml => python-build.yml} | 43 +++++++++++-------- .github/workflows/python-publish.yml | 12 ++++-- 3 files changed, 35 insertions(+), 20 deletions(-) rename .github/workflows/{ => deprecated}/deploy.yaml (100%) rename .github/workflows/{python-app.yml => python-build.yml} (51%) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deprecated/deploy.yaml similarity index 100% rename from .github/workflows/deploy.yaml rename to .github/workflows/deprecated/deploy.yaml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-build.yml similarity index 51% rename from .github/workflows/python-app.yml rename to .github/workflows/python-build.yml index a9a4dcc..35e91fb 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-build.yml @@ -1,36 +1,45 @@ + # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: diploshic +name: Build -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: push jobs: - build: - + Build_Package: runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.10 - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 with: - python-version: "3.10" - - name: Install dependencies + python-version: ${{ matrix.python-version }} + - name: Setup conda + uses: s-weigand/setup-conda@v1 + with: + activate-conda: true + update-conda: true + python-version: ${{ matrix.python-version }} + conda-channels: conda-forge + - name: Install dependencies run: | + conda install pip setuptools python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + - name: Install diploSHIC + run: | + pip install . + - name: List installed run: | - pytest + conda list \ No newline at end of file diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 2f80821..3469abf 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -6,12 +6,18 @@ # separate terms of service, privacy policy, and support # documentation. -name: Upload Python Package +name: Publish -on: [push, pull_request] +on: + push: + branches: + - main + - master + tags: + - v* jobs: - manylinux: + Build_Wheel: runs-on: ubuntu-latest steps: - name: Checkout From 7018cf424ad6cdea7b9d98c2b8dee5bc89296e75 Mon Sep 17 00:00:00 2001 From: Bruce Edelman Date: Wed, 15 Nov 2023 20:56:04 +0000 Subject: [PATCH 2/2] fix flake8 errors for undefined variables (it cant tell about going through loops or cases that end up defining variables before being called --- diploshic/fvTools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/diploshic/fvTools.py b/diploshic/fvTools.py index a2faa6f..63f184c 100644 --- a/diploshic/fvTools.py +++ b/diploshic/fvTools.py @@ -252,6 +252,7 @@ def readFa(faFileName, upper=False): fopen = open with fopen(faFileName, "rt") as faFile: reading = False + currChr = None for line in faFile: if line.startswith(">"): if reading: @@ -493,6 +494,10 @@ def readMaskDataForTraining( readingMasks = False isAccessible, isAccessibleArm = [], [] genoMaskInfo = [] + currChr = None + genos = None + positions = None + positions2SnpIndices = None with fopen(maskFileName, "rt") as maskFile: for line in maskFile: if line.startswith(">"): @@ -916,7 +921,7 @@ def calcAndAppendStatValDiplo( - statVals["pi"][instanceIndex][subWinIndex] ) elif statName == "HapCount": - statVals[statName][instanceIndex].append(len(hapsInSubWin.distinct())) + statVals[statName][instanceIndex].append(len(genosInSubWin.distinct())) elif statName == "nDiplos": diplotypeCounts = dps.getHaplotypeFreqSpec(genosNAlt) nDiplos = diplotypeCounts[genosNAlt.shape[1]] @@ -1021,7 +1026,7 @@ def calcAndAppendStatValForScanDiplo( ) elif statName == "HapCount": # AK: undefined variables - statVals[statName].append(len(hapsInSubWin.distinct())) + statVals[statName].append(len(genosInSubWin.distinct())) elif statName == "nDiplos": diplotypeCounts = dps.getHaplotypeFreqSpec(genosNAlt) nDiplos = diplotypeCounts[genosNAlt.shape[1]]