Skip to content

Commit

Permalink
add Windows GHA for building and running, helper file for retrieving …
Browse files Browse the repository at this point in the history
…clang file, update type in test_smaller, and update v number
  • Loading branch information
Adarsh321123 committed Aug 25, 2023
1 parent f5af5d8 commit 919bfb8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 49 deletions.
114 changes: 67 additions & 47 deletions .github/workflows/run_windows_tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Windows - build package and run tests
on: [push, pull_request] # This test is currently disabled until we can build Armadillo on Windows
on: [push, pull_request]
jobs:
build:
runs-on: windows-latest
Expand All @@ -13,66 +13,86 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# - name: Install Windows dependencies
# run: |
# cmake --version
# - name: Install CPython from Anaconda # TODO: Need to update CMake? # TODO: See https://docs.conda.io/projects/conda/en/latest/user-guide/install/windows.html
# run: |
# curl -XGET https://repo.anaconda.com/archive/Anaconda3-2021.11-Windows-x86_64.exe > Anaconda3-2021.11-Windows-x86_64.exe
# start /wait "" "Anaconda3-latest-Windows-x86_64.exe" /InstallationType=JustMe /AddToPath=1 /RegisterPython=1 /S /D=%UserProfile%\Anaconda3
# conda create -n "$p{{ matrix.python-version }}" python=${{ matrix.python-version }}
# conda activate p${{ matrix.python-version }}
- name: Install Python dependencies

- name: Clone for PR
if: ${{ github.event_name == 'pull_request' }}
run: git clone -b $env:GITHUB_HEAD_REF https://github.com/motiwari/BanditPAM

- name: Clone for Push
if: ${{ github.event_name != 'pull_request' }}
run: git clone -b ($env:GITHUB_REF -replace '^refs/heads/', '') https://github.com/motiwari/BanditPAM

- name: Downloading data files for tests
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install -r requirements.txt
cd BanditPAM
mkdir -p data
curl -XGET https://motiwari.com/banditpam_data/scRNA_1k.csv > data/scRNA_1k.csv
curl -XGET https://motiwari.com/banditpam_data/scrna_reformat.csv.gz > data/scrna_reformat.csv.gz
curl -XGET https://motiwari.com/banditpam_data/MNIST_100.csv > data/MNIST_100.csv
curl -XGET https://motiwari.com/banditpam_data/MNIST_1k.csv > data/MNIST_1k.csv
curl -XGET https://motiwari.com/banditpam_data/MNIST_10k.tar.gz > data/MNIST_10k.tar.gz
tar -xzvf data/MNIST_10k.tar.gz -C data
curl -XGET https://motiwari.com/banditpam_data/MNIST_70k.tar.gz > data/MNIST_70k.tar.gz
tar -xzvf data/MNIST_70k.tar.gz -C data
- name: Install Armadillo 10.7.5+
run: |
cd ~
git clone https://gitlab.com/conradsnicta/armadillo-code.git
cd armadillo-code
cd BanditPAM/headers
git clone https://gitlab.com/conradsnicta/armadillo-code.git armadillo
cd armadillo
cmake .
C:/"Program Files"/"Microsoft Visual Studio"/2022/Enterprise/Common7/IDE/devenv armadillo.sln /Build "Release|x64"
- name: Add environment variables
run: |
Add-Content $env:GITHUB_PATH "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86"
- name: Install carma
run: |
cd ~
cd BanditPAM/headers
git clone https://github.com/RUrlus/carma.git
cd carma
mkdir build
cd build
cmake -DCARMA_INSTALL_LIB=ON ..
cmake --build . --config Release --target install
cd ~
- name: Install BanditPAM package
cd ../../..
- name: Verify that the C++ executable compiles and runs # Building C++ first to avoid armadillo include issues
run: |
python -m pip install -vvv -e .
env:
# The default compiler on the Github Ubuntu runners is gcc
# Would need to make a respective include change for clang
CPLUS_INCLUDE_PATH: /usr/local/include/carma
- name: Downloading data files for tests
cd BanditPAM/scripts
sh retrieve_windows_cmake_files.sh
cd ..
mkdir build
cd build
cmake ..
C:/"Program Files"/"Microsoft Visual Studio"/2022/Enterprise/Common7/IDE/devenv BanditPAM.sln /Build "Release|x64"
cd src/Release
.\BanditPAM.exe -f ../../../data/MNIST_1k.csv -k 5
- name: Install Python dependencies
run: |
mkdir -p data
curl -XGET https://motiwari.com/banditpam_data/scRNA_1k.csv > data/scRNA_1k.csv
curl -XGET https://motiwari.com/banditpam_data/scrna_reformat.csv.gz > data/scrna_reformat.csv.gz
curl -XGET https://motiwari.com/banditpam_data/MNIST_100.csv > data/MNIST_100.csv
curl -XGET https://motiwari.com/banditpam_data/MNIST_1k.csv > data/MNIST_1k.csv
curl -XGET https://motiwari.com/banditpam_data/MNIST_10k.tar.gz > data/MNIST_10k.tar.gz
tar -xzvf data/MNIST_10k.tar.gz -C data
curl -XGET https://motiwari.com/banditpam_data/MNIST_70k.tar.gz > data/MNIST_70k.tar.gz
tar -xzvf data/MNIST_70k.tar.gz -C data
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install --upgrade pip setuptools wheel
- name: Install BanditPAM package
run: |
cd BanditPAM
# The flags are necessary to ignore the pyproject.toml
# See https://github.com/pypa/pip/issues/9738
python -m pip install -vvvv --no-use-pep517 .
cd scripts
sh retrieve_windows_python_files.sh
cd ..
python -m pip install -vvvv --no-use-pep517 .
- name: Run smaller suite of test cases
run : |
pytest tests/test_smaller.py
run: |
cd BanditPAM
python tests/test_smaller.py
# - name: Run larger suite of test cases
# run : |
# pytest tests/test_larger.py
# - name: Verify that the C++ executable compiles and runs
# run : |
# git clone -b ${GITHUB_REF#refs/heads/} https://github.com/motiwari/BanditPAM
# cd BanditPAM
# mkdir build
# cd build
# cmake ..
# make
# src/BanditPAM -f ../data/MNIST_1k.csv -k 5
# python tests/test_larger.py
11 changes: 11 additions & 0 deletions scripts/retrieve_windows_python_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script is used to retrieve the files necessary for the Windows Python build
echo "Retrieving files for Windows Python build..."
cd ..
git clone https://github.com/ThrunGroup/BanditPAM_Windows
cd build
cd -- "$(find . -name 'lib.*')"
mv ../../BanditPAM_Windows/clang_rt.asan_dynamic-x86_64.dll clang_rt.asan_dynamic-x86_64.dll
rm -rf ../../BanditPAM_Windows
echo "Done!"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import distutils.sysconfig
import distutils.spawn

__version__ = "4.0.3"
__version__ = "4.0.4a0"

# TODO(@motiwari): Move this to a separate file
GHA = "GITHUB_ACTIONS"
Expand Down
6 changes: 5 additions & 1 deletion tests/test_smaller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import pandas as pd
import numpy as np
import sys

from banditpam import KMedoids
from utils import bpam_agrees_pam
Expand All @@ -16,7 +17,10 @@
class SmallerTests(unittest.TestCase):
small_mnist = pd.read_csv("data/MNIST_100.csv", header=None).to_numpy()
mnist_70k = pd.read_csv("data/MNIST_70k.csv", sep=" ", header=None)
scrna = pd.read_csv("data/scrna_reformat.csv.gz", header=None)
if sys.platform == "win32":
scrna = pd.read_csv("data/scrna_reformat.csv.gz", header=None, dtype='float16') # float16 for less memory usage
else:
scrna = pd.read_csv("data/scrna_reformat.csv.gz", header=None)

def test_small_mnist(self):
"""
Expand Down

0 comments on commit 919bfb8

Please sign in to comment.