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

Speed up tests #293

Merged
merged 26 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ff7404b
add folder for user installation test
jarlsondre Jan 16, 2025
2b918c7
update tests to run in parallel
jarlsondre Jan 16, 2025
640268b
Merge branch 'main' into test-user-installation
jarlsondre Jan 16, 2025
958ef21
fix linting errors in dummy script
jarlsondre Jan 16, 2025
5dfe88e
add normal test to compare
jarlsondre Jan 16, 2025
8466a1f
empty dummy script for now
jarlsondre Jan 16, 2025
8f30f15
try to only run loggers
jarlsondre Jan 17, 2025
00e47ef
separate tests into multiple workflows
jarlsondre Jan 17, 2025
a49e3e9
remove horovod setup for all to test which needs it
jarlsondre Jan 17, 2025
6aa38c5
remove old pytest
jarlsondre Jan 17, 2025
d0c570a
remove old directory
jarlsondre Jan 17, 2025
5dd6de1
update tests to hopefully work in parallel
jarlsondre Jan 20, 2025
280d7b2
remove split tests
jarlsondre Jan 20, 2025
6d8cb6a
Merge branch 'main' into test-user-installation
jarlsondre Jan 20, 2025
dcddffc
remove tensorflow building for tests
jarlsondre Jan 20, 2025
3bb0a74
fix linting errors
jarlsondre Jan 20, 2025
dfef658
add missing marker and add uv to generic torch
jarlsondre Jan 20, 2025
f069d90
change version in pytest
jarlsondre Jan 20, 2025
b4f190e
update generic torch with check for NO_CUDA flag
jarlsondre Jan 20, 2025
788bed4
merge
jarlsondre Jan 20, 2025
79a461b
add other fixtures and add comment with how to build tf
jarlsondre Jan 20, 2025
73a0258
fix linting errors
jarlsondre Jan 20, 2025
9dea219
add comment about env variables
jarlsondre Jan 20, 2025
aebd695
fix grammar
jarlsondre Jan 21, 2025
fd3b153
add no cache dir to pip install
jarlsondre Jan 21, 2025
aab9a0e
small bugfix in generic_torch
jarlsondre Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
---
name: Unit and integration tests
name: Testing components with pytest

on:
pull_request:
branches: [main, dev]

jobs:
test-itwinai:
name: Test itwinai with pytest
test-components:
name: Testing components with pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install compilers for Horovod
run: |
sudo apt-get update &&
sudo apt-get install -y gcc-11 g++-11 &&
sudo apt-get install -y cmake &&
sudo apt-get install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev &&
gcc --version &&
cmake --version &&
mpirun --version

- name: Make PyTorch virtualenv
shell: bash -l {0}
Expand All @@ -34,6 +24,6 @@ jobs:
# Default environment names are ".venv-pytorch" and ".venv-tf"
- name: Run pytest for workflows
shell: bash -l {0}
run: .venv-pytorch/bin/pytest -v ./tests/ -m "not hpc"
run: .venv-pytorch/bin/pytest -v ./tests/components -m "not hpc"


29 changes: 29 additions & 0 deletions .github/workflows/pytest-loggers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Testing loggers with pytest

on:
pull_request:
branches: [main, dev]

jobs:
test-loggers:
name: Testing loggers with pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Make PyTorch virtualenv
shell: bash -l {0}
run: make torch-env-cpu

- name: Make Tensorflow virtualenv
shell: bash -l {0}
run: make tensorflow-env-cpu

# NOTE, to change the name in which tests are run, set custom TORCH_ENV and TF_ENV env variables.
jarlsondre marked this conversation as resolved.
Show resolved Hide resolved
# Default environment names are ".venv-pytorch" and ".venv-tf"
- name: Run pytest for workflows
shell: bash -l {0}
run: .venv-pytorch/bin/pytest -v ./tests/loggers -m "not hpc"


29 changes: 29 additions & 0 deletions .github/workflows/pytest-torch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Testing torch with pytest

on:
pull_request:
branches: [main, dev]

jobs:
test-torch:
name: Testing torch with pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Make PyTorch virtualenv
shell: bash -l {0}
run: make torch-env-cpu

- name: Make Tensorflow virtualenv
shell: bash -l {0}
run: make tensorflow-env-cpu

# NOTE, to change the name in which tests are run, set custom TORCH_ENV and TF_ENV env variables.
# Default environment names are ".venv-pytorch" and ".venv-tf"
- name: Run pytest for workflows
shell: bash -l {0}
run: .venv-pytorch/bin/pytest -v ./tests/torch -m "not hpc"


29 changes: 29 additions & 0 deletions .github/workflows/pytest-use-cases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Testing use cases with pytest

on:
pull_request:
branches: [main, dev]

jobs:
test-use-cases:
name: Testing use cases with pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Make PyTorch virtualenv
shell: bash -l {0}
run: make torch-env-cpu

- name: Make Tensorflow virtualenv
shell: bash -l {0}
run: make tensorflow-env-cpu

# NOTE, to change the name in which tests are run, set custom TORCH_ENV and TF_ENV env variables.
# Default environment names are ".venv-pytorch" and ".venv-tf"
- name: Run pytest for workflows
shell: bash -l {0}
run: .venv-pytorch/bin/pytest -v -n logical ./tests/use-cases -m "not hpc"


29 changes: 29 additions & 0 deletions .github/workflows/pytest-utils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Testing utils with pytest

on:
pull_request:
branches: [main, dev]

jobs:
test-utils:
name: Testing utils with pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Make PyTorch virtualenv
shell: bash -l {0}
run: make torch-env-cpu

- name: Make Tensorflow virtualenv
shell: bash -l {0}
run: make tensorflow-env-cpu

# NOTE, to change the name in which tests are run, set custom TORCH_ENV and TF_ENV env variables.
# Default environment names are ".venv-pytorch" and ".venv-tf"
- name: Run pytest for workflows
shell: bash -l {0}
run: .venv-pytorch/bin/pytest -v ./tests/test_utils.py -m "not hpc"


3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ torch = [
]
tf = ["tensorflow==2.16.*", "tf_keras==2.16.*"]
tf-cuda = ["tensorflow[and-cuda]==2.16.*", "tf_keras==2.16.*"]

dev = [
"pytest>=7.4.2",
"pytest-mock>=3.11.1",
"pytest-cov>=4.1.0",
"ipykernel>=6.29.5",
"ipython>=8.30.0",
"ruff>=0.8.3",
"psutil>=6.1.0",
"pytest-xdist>=3.6.1",
]
docs = [
"sphinx-rtd-theme>=2.0.0",
Expand Down
5 changes: 2 additions & 3 deletions use-cases/mnist/torch/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
self.save_path = save_path

@monitor_exec
def execute(self) -> Tuple[Dataset, Dataset]:
def execute(self) -> Tuple[Dataset, Dataset, None]:
train_dataset = datasets.MNIST(
self.save_path,
train=True,
Expand Down Expand Up @@ -95,8 +95,7 @@ def __getitem__(self, index: int) -> Tuple[Any, Any]:

@staticmethod
def generate_jpg_sample(root: str, max_items: int = 100):
"""Generate a sample dataset of JPG images starting from
LeCun's test dataset.
"""Generate a sample dataset of JPG images starting from LeCun's test dataset.

Args:
root (str): sample path on disk
Expand Down
Loading
Loading