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

ENH: Separate workflow for histopathology #354

Merged
merged 15 commits into from
May 18, 2022
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: PR BuildAndTest.CI
name: HI-ML HI-ML-Azure PR
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
paths:
- "hi-ml-azure/**"
- "hi-ml/**"
- ".github/workflows/hi-ml-pr.yml"

env:
pythonVersion: 3.7
Expand All @@ -18,10 +22,6 @@ env:
HIML_DIST_ARTIFACT_SUFFIX: '-dist'
HIML_PACKAGE_NAME_ARTIFACT_SUFFIX: '-package_name'
HIML_VERSION_ARTIFACT_SUFFIX: '-latest_version'
HIML_COV_DOT_ARTIFACT_SUFFIX: '-code_coverage_report_dot'
HIML_COV_HTML_ARTIFACT_SUFFIX: '-code_coverage_report_html'
HIML_COV_TXT_ARTIFACT_SUFFIX: '-code_coverage_txt'
HIML_COV_XML_ARTIFACT_SUFFIX: '-code_coverage_xml'

jobs:

Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
folder: [ hi-ml, hi-ml-azure, hi-ml-histopathology ]
folder: [ hi-ml, hi-ml-azure ]
# This will let all parts of the matrix run, to collect as many errors as possible, rather than aborting after first fail
fail-fast: false
steps:
Expand Down Expand Up @@ -177,7 +177,6 @@ jobs:

- name: Download package artifacts
id: download
if: ${{ matrix.folder != 'hi-ml-histopathology' }}
uses: ./.github/actions/download_package_artifacts
with:
folder: ${{ matrix.folder }}
Expand All @@ -187,11 +186,9 @@ jobs:
run: |
cd ${{ matrix.folder }}

if [ ${{ matrix.folder }} != 'hi-ml-histopathology' ]; then
make pip_upgrade
# Install package
pip install ${{ steps.download.outputs.package_filename }}
fi
make pip_upgrade
# Install package
pip install ${{ steps.download.outputs.package_filename }}

if [ ${{ matrix.packageName }} == '*.whl' ]; then
# Set env vars so wheel is sent to azureml as a private package
Expand All @@ -210,68 +207,6 @@ jobs:
with:
name: ${{ matrix.folder }}

test-project-folders:
runs-on: ubuntu-18.04
needs: [ build-python ]
strategy:
matrix:
folder: [ hi-ml-histopathology ]
packageName: [ '*.whl' ]
steps:
- uses: actions/checkout@v2
with:
lfs: true

- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}

- name: PIP upgrade
run: |
cd hi-ml-azure
make pip_upgrade

- name: Download hi-ml-azure
id: download_himlazure
uses: ./.github/actions/download_package_artifacts
with:
folder: hi-ml-azure
package_type: ${{ matrix.packageName }}

- name: Download hi-ml
id: download_himl
uses: ./.github/actions/download_package_artifacts
with:
folder: hi-ml
package_type: ${{ matrix.packageName }}

- name: Install dependencies
run: |
cd hi-ml-azure
pip install ${{ steps.download_himlazure.outputs.package_filename }}
cd ../hi-ml
pip install ${{ steps.download_himl.outputs.package_filename }}

- name: Run tests
run: |
cd ${{ matrix.folder }}
make pip_local
make pytest_and_coverage

- name: Upload coverage report to Codecov
if: ${{ matrix.packageName == '*.whl' }}
uses: codecov/codecov-action@v2
with:
name: ${{ matrix.folder }}

- name: Run GPU tests
run: |
branch_prefix="refs/heads/"
full_branch_name=$GITHUB_REF
branch_name_without_prefix=${full_branch_name#$branch_prefix}
python hi-ml-azure/run_pytest.py --mark=gpu --cluster=pr-gpu --conda_env=${{ matrix.folder }}/environment.yml --folder=${{ matrix.folder }} --experiment="$branch_name_without_prefix"

publish-testpypi-pkg:
runs-on: ubuntu-18.04
needs: [ test-artifact-pkg ]
Expand Down
114 changes: 114 additions & 0 deletions .github/workflows/histopathology-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Histopathology PR
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
paths:
- "hi-ml-histopathology/**"
- ".github/workflows/histopathology-pr.yml"
# When the core hi-ml libraries change, test the histo test too, to find problems with backwards compatibility
- "hi-ml-azure/**"
- "hi-ml/**"

env:
pythonVersion: 3.7
folder: hi-ml-histopathology
HIML_TENANT_ID: ${{ secrets.HIML_TENANT_ID }}
HIML_RESOURCE_GROUP: ${{ secrets.HIML_RESOURCE_GROUP }}
HIML_SUBSCRIPTION_ID: ${{ secrets.HIML_SUBSCRIPTION_ID }}
HIML_WORKSPACE_NAME: ${{ secrets.HIML_WORKSPACE_NAME }}
HIML_SERVICE_PRINCIPAL_ID: ${{ secrets.HIML_SERVICE_PRINCIPAL_ID }}
HIML_SERVICE_PRINCIPAL_PASSWORD: ${{ secrets.HIML_SERVICE_PRINCIPAL_PASSWORD }}

jobs:

flake8:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true

- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}

- name: flake8
run: |
cd ${{ env.folder }}
make pip_test
make flake8

mypy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true

- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}

- name: mypy
run: |
cd ${{ env.folder }}
make pip_test
make mypy

pytest:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
lfs: true

- name: Set up Python ${{ env.pythonVersion }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.pythonVersion }}

- name: PIP upgrade
run: |
cd ${{ env.folder }}
make pip_upgrade

- name: Install required packages
run: |
cd ${{ env.folder }}
make pip_from_conda

- name: Install hi-ml locally
run: |
cd hi-ml
make pip_local

- name: Install hi-ml-azure locally
run: |
cd hi-ml-azure
make pip_local

- name: Test with pytest
run: |
cd ${{ env.folder }}

# Run tests
make pip_test
make pytest_coverage

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v2
with:
name: ${{ env.folder }}

- name: Run GPU tests
run: |
branch_prefix="refs/heads/"
full_branch_name=$GITHUB_REF
branch_name_without_prefix=${full_branch_name#$branch_prefix}
python hi-ml-azure/run_pytest.py --mark=gpu --cluster=pr-gpu --conda_env=${{ env.folder }}/environment.yml --folder=${{ env.folder }} --experiment="$branch_name_without_prefix"
10 changes: 2 additions & 8 deletions .github/workflows/multimodal-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Multimodal PR Workflow
name: Multimodal PR
on:
push:
branches: [ main ]
Expand All @@ -8,6 +8,7 @@ on:
branches: [ main ]
paths:
- "multimodal/**"
- ".github/workflows/multimodal-pr.yml"

env:
pythonVersion: 3.7
Expand All @@ -18,13 +19,6 @@ env:
HIML_WORKSPACE_NAME: ${{ secrets.HIML_WORKSPACE_NAME }}
HIML_SERVICE_PRINCIPAL_ID: ${{ secrets.HIML_SERVICE_PRINCIPAL_ID }}
HIML_SERVICE_PRINCIPAL_PASSWORD: ${{ secrets.HIML_SERVICE_PRINCIPAL_PASSWORD }}
HIML_DIST_ARTIFACT_SUFFIX: '-dist'
HIML_PACKAGE_NAME_ARTIFACT_SUFFIX: '-package_name'
HIML_VERSION_ARTIFACT_SUFFIX: '-latest_version'
HIML_COV_DOT_ARTIFACT_SUFFIX: '-code_coverage_report_dot'
HIML_COV_HTML_ARTIFACT_SUFFIX: '-code_coverage_report_html'
HIML_COV_TXT_ARTIFACT_SUFFIX: '-code_coverage_txt'
HIML_COV_XML_ARTIFACT_SUFFIX: '-code_coverage_xml'

jobs:

Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ env:

# call make for each sub package
define call_packages
cd hi-ml-histopathology && ${MAKE} $(1)
cd hi-ml-azure && $(MAKE) $(1)
cd hi-ml && $(MAKE) $(1)
endef
Expand Down
70 changes: 16 additions & 54 deletions hi-ml-histopathology/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,30 @@
# Create a Conda environment for this folder only
env:
conda env create --file environment.yml
pip install -r ../test_requirements.txt
pip install -r ../build_requirements.txt
pip install -r requirements_test.txt
pip install -r requirements_build.txt

# call make for parent
define call_parent
cd .. && $(MAKE) $(1)
endef

## Package management
# Package management

# pip upgrade
pip_upgrade:
$(call call_parent,pip_upgrade)
python -m pip install --upgrade pip

# pip upgrade and install build requirements
pip_build:
$(call call_parent,pip_build)
pip_build: pip_upgrade
pip install -r requirements_build.txt

# pip upgrade and install test requirements
pip_test:
$(call call_parent,pip_test)
pip_test: pip_upgrade
pip install -r requirements_test.txt

# pip install all requirements for histo, read off the Conda file. This is somewhat hacky,
# we could also build a full Conda before starting the tests. Unclear about the performance
# impact of that.
call_pip_local:
pip_from_conda:
sed -e '1,/pip:/ d' environment.yml | grep -v "#" | cut -d "-" -f 2- > temp_requirements.txt
pip install -r temp_requirements.txt

# pip upgrade and install local package in editable mode
pip_local: pip_upgrade call_pip_local


# pip install everything for local development and testing
pip: pip_build pip_test call_pip_local

## Actions
# clean build artifacts
clean:
rm -vrf `find . -type d -name __pycache__`
Expand All @@ -50,48 +37,23 @@ clean:
rm -vf ./coverage ./coverage.txt ./coverage.xml

# run flake8, assuming test requirements already installed
call_flake8:
flake8:
flake8 --count --statistics .

# pip install test requirements and run flake8
flake8: pip_test call_flake8

# run mypy, assuming test requirements already installed
call_mypy:
mypy:
mypy --install-types --non-interactive -p histopathology
mypy --install-types --non-interactive -p SSL
mypy --install-types --non-interactive -p testhisto
mypy --install-types --non-interactive -p testSSL

# pip install test requirements and run mypy
mypy: pip_test call_mypy

# run basic checks
call_check: call_flake8 call_mypy

# install test requirements and run basic checks
check: pip_test call_check
check: flake8 mypy

# run pytest on package, assuming test requirements already installed
call_pytest:
pytest testhisto testSSL

# install test requirements and run tests
pytest: pip_test testhisto testSSL

# run pytest fast subset on package, assuming test requirements already installed
call_pytest_fast:
pytest -m fast testhisto testSSL

# install test requirements and run pytest fast subset
pytest_fast: pip_test call_pytest_fast
pytest:
pytest

# run pytest with coverage on package
call_pytest_and_coverage:
pytest --cov=histopathology --cov-branch --cov-report=html --cov-report=xml --cov-report=term-missing --cov-config=.coveragerc testhisto

# install test requirements and run pytest coverage
pytest_and_coverage: pip_test call_pytest_and_coverage

# install test requirements and run all tests
test_all: pip_test call_flake8 call_mypy call_pytest_and_coverage
pytest_coverage:
pytest --cov=histopathology --cov SSL --cov-branch --cov-report=html --cov-report=xml --cov-report=term-missing --cov-config=.coveragerc
2 changes: 1 addition & 1 deletion hi-ml-histopathology/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ addopts = --strict-markers
markers =
fast: Tests that should run very fast, and can act as smoke tests to see if something goes terribly wrong.
gpu: Tests that should be executed both on a normal machine and on a machine with 2 GPUs.
flaky: Tests will automatically rerun if they fail.
flaky: Tests will automatically rerun if they fail.
Loading