Skip to content

Commit

Permalink
add premerge tests (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyli authored Jun 25, 2024
1 parent ba4e516 commit 0595537
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/premerge-py-min.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: premerge-min

on:
# quick tests for pull requests and the releasing branches
push:
branches:
- vista3d
- main
pull_request:

concurrency:
# automatically cancel the previously triggered workflows when there's a newer version
group: py-min-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
min-dep-py3: # min dependencies installed tests for different python
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Prepare pip wheel
run: |
which python
python -m pip install --user --upgrade pip setuptools wheel
- name: cache weekly timestamp
id: pip-cache
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install the dependencies
run: |
python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install monai pyyaml
python -m pip list
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -c "import monai; monai.config.print_config()"
python tests/test_config.py
39 changes: 39 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import glob
import os
import unittest

from monai.apps.utils import get_logger
from monai.bundle import ConfigParser


class TestConfig(unittest.TestCase):
def test_vista3d_configs_parsing(self):
config_dir = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "configs"
)
get_logger("TestConfig").info(config_dir)

configs = glob.glob(os.path.join(config_dir, "**", "*.yaml"), recursive=True)
for x in configs:
parser = ConfigParser()
parser.read_config(x)
keys = sorted(parser.config.keys())
# verify parser key fetching
get_logger("TestConfig").info(
f"{parser[keys[0]]}, {keys[0]}, {parser[keys[-1]]}, {keys[-1]}"
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 0595537

Please sign in to comment.