Skip to content

Commit

Permalink
Testing infra (ML4GW#163)
Browse files Browse the repository at this point in the history
* add initial testing infra

* use container with git

* revert to python3.10 container

* cd into lib directory

* cd into lib directory

* remove fail fast

* remove fail fast

* add some debugs

* cd into test dir

* add basic wavenet tests foor architectures

* remove priors from libs workflows due to lack of tests

* typo in filenam

* fix workflow filter

* add pytest to arch deps

* add project tests ci

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* get project tests running

* run pytest inside container

* update data poetry lock

* separate tests and build

* fix syntax errors

* fix syntax errors

* fix syntax errors

* fix syntax errors

* fix syntax errors

* add pytest as dev dep in data project

* add train tests

* add infer tests

* add export tests

* get export tests working

* fix urllib constraint issue in poetry container

* update infer apptainer file

* install pytest inside containers for CI

* fix injection unit tests

* call pytest directly in CI

* tar in same command as tetsts due to permission issues

* add debug statement to build

* add more debug statements

* add more debug statements

* pin poetry version in infer container

* add conditional for docker push to only run on pushes

* remove debug statements
  • Loading branch information
EthanMarx authored May 26, 2024
1 parent 9f82f4e commit 5f31a18
Show file tree
Hide file tree
Showing 27 changed files with 9,586 additions and 8,149 deletions.
25 changes: 25 additions & 0 deletions .github/lib-filters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# define filters for file changes
# to trigger unit tests

# filter for changes
# to workflow
workflow: &workflow
- '.github/lib-filters.yaml'
- '.github/workflows/lib-tests.yaml'


# use paths for filter names
# for simplicity in ci-test.yaml

# cleaner way to run all jobs
# if workflow file is changed?

# libraries
architectures:
- *workflow
- 'libs/architectures/**'
- 'ml4gw/**'

ledger:
- *workflow
- 'libs/ledger/**'
29 changes: 29 additions & 0 deletions .github/project-filters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
workflow: &workflow
- '.github/lib-filters.yaml'
- '.github/workflows/lib-tests.yaml'

data:
- *workflow
- 'projects/data/**'
- 'ml4gw/**'
- 'libs/ledger/**'
- 'libs/priors/**'

infer:
- *workflow
- 'projects/infer/**'
- 'hermes/**'
- 'libs/ledger/**'

train:
- *workflow
- 'projects/train/**'
- 'ml4gw/**'
- 'libs/ledger/**'
- 'libs/architectures/**'

export:
- *workflow
- 'projects/export/**'
- 'ml4gw/**'
- 'hermes/**'
74 changes: 74 additions & 0 deletions .github/workflows/lib-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: library tests

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- main

jobs:
# first job users filters to output which libraries
# and projects have updates that need testing
changes:
runs-on: ubuntu-latest
outputs:
libraries: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
filters: .github/lib-filters.yaml
if: github.event.pull_request.draft == false

# second job takes those outputs and runs
# unit tests on these libs and projects
tests:
runs-on: ubuntu-latest
needs: changes
strategy:
fail-fast: false # is this desired behavior here?
matrix:
library: ${{ fromJSON(needs.changes.outputs.libraries) }}
exclude:
# don't run non-existent .github/workflow tests,
# and exclude projects, whose tests are run in
# a different CI script
- library: 'workflow'
permissions:
packages: read
container:
# container with python and git
image: cicirello/pyaction:4.8
volumes:
- ${{ github.workspace }}:/github/workspace
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

# build the libraries environment
-
name: build environment
env:
test_dir: /github/workspace/libs/${{ matrix.library }}
run: |
python -m pip install poetry
cd $test_dir
poetry install
shell: bash

# run its unit tests inside that environment
-
name: run tests
env:
test_dir: /github/workspace/libs/${{ matrix.library }}
run: |
cd $test_dir
poetry run pytest
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,62 @@
# to convert between the formats in order to handle
# the large memory footprints of our containers without
# toppling over the GitHub runner nodes this executes on.
name: container-build
on:
name: project tests

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- main

env:
REGISTRY: ghcr.io
PATH: /opt/env/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda-11.8/bin:/opt/tritonserver/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin


jobs:
build:
changes:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.filter.outputs.changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Filter project changes
id: filter
uses: dorny/paths-filter@v2
with:
filters: .github/project-filters.yaml
if: github.event.pull_request.draft == false

build-test:
runs-on: ubuntu-latest
needs: changes
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
project: [train, export, data]
project: ${{ fromJSON(needs.changes.outputs.projects) }}
exclude:
- project: 'workflow' # Fixed the exclusion key
steps:
-
name: Delete huge unnecessary tools folder
name: delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
-
name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
-
name: Log in to the Container registry
name: log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -44,7 +73,7 @@ jobs:
# in one fell swoop because of permissions discrepancies
# inside and outside the container.
-
name: Build singularity image
name: build singularity image
run: |
docker run \
--rm \
Expand All @@ -53,24 +82,40 @@ jobs:
--privileged \
--entrypoint /bin/bash \
quay.io/singularity/singularity:v3.8.1 \
-c 'singularity build --sandbox /tmp/app apptainer.def && tar -czf /opt/aframe/app.tar.gz -C /tmp/app .'
-c 'singularity build --sandbox /opt/aframe/sandbox apptainer.def'
- name: run tests in singularity sandbox and tar
run: |
docker run \
--rm \
-v ${{ github.workspace }}:/opt/aframe \
--workdir /opt/aframe/projects/${{ matrix.project }} \
--privileged \
--entrypoint /bin/bash \
quay.io/singularity/singularity:v3.8.1 \
-c 'singularity exec --env PATH=${{ env.PATH }} /opt/aframe/sandbox pytest && tar -czf /opt/aframe/app.tar.gz -C /opt/aframe/sandbox .'
# now copy the fs contents into an empty
# container and push it to the registry,
# using a lowercase version of the tag since
# the github environment variables are case-sensitive
# TODO: add step to run tests inside docker


# TODO: currently combining path for nvidia variables
# necessary to launch triton in export container
# with path required by train / data projects.
# Should add conditionals in this workflow to set these dynamically
-
name: build docker image
# only run on pushes
if: ${{ github.event_name == 'push' }}
env:
tag: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.project }}:${{ github.ref_name }}
path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/cuda-11.8/bin:/opt/tritonserver/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin
run: |
export TAG_LC=${tag,,}
cat app.tar.gz | docker import --change "ENV PATH=${{ env.path }}" - $TAG_LC
cat app.tar.gz | docker import --change "ENV PATH=${{ env.PATH }}" - $TAG_LC
docker push $TAG_LC
2 changes: 1 addition & 1 deletion libs/architectures/architectures/networks/wavenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
self.init_conv = nn.Conv1d(
in_channels, res_channels, kernel_size=2, dilation=1
)
self.norm1 = norm_layer(res_channels)
self.norm1 = self.norm_layer(res_channels)
self.layers_per_block = layers_per_block
self.num_blocks = num_blocks
self.res_channels = res_channels
Expand Down
97 changes: 96 additions & 1 deletion libs/architectures/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5f31a18

Please sign in to comment.