Skip to content

Commit

Permalink
Add skip mark for macOS tests in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice committed Nov 20, 2024
1 parent 5ccc0f2 commit 6cbdaf2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
12 changes: 3 additions & 9 deletions project/algorithms/image_classifier_test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
"""Example showing how the test suite can be used to add tests for a new algorithm."""

import sys

import pytest
import torch
from transformers import PreTrainedModel

from project.algorithms.testsuites.lightning_module_tests import LightningModuleTests
from project.configs import Config
from project.conftest import command_line_overrides
from project.conftest import command_line_overrides, skip_on_macos_in_CI
from project.datamodules.image_classification.cifar10 import CIFAR10DataModule
from project.datamodules.image_classification.image_classification import (
ImageClassificationDataModule,
)
from project.utils.testutils import IN_GITHUB_CI, run_for_all_configs_of_type
from project.utils.testutils import run_for_all_configs_of_type

from .image_classifier import ImageClassifier

Expand All @@ -33,11 +31,7 @@ def test_example_experiment_defaults(experiment_config: Config) -> None:
assert isinstance(experiment_config.datamodule, CIFAR10DataModule)


@pytest.mark.skipif(
sys.platform == "darwin" and IN_GITHUB_CI,
# raises=(RuntimeError, hydra.errors.InstantiationException),
reason="Raises 'MPS backend out of memory' error on MacOS in GitHub CI.",
)
@skip_on_macos_in_CI
@run_for_all_configs_of_type("algorithm", ImageClassifier)
@run_for_all_configs_of_type("datamodule", ImageClassificationDataModule)
@run_for_all_configs_of_type("algorithm/network", torch.nn.Module, excluding=PreTrainedModel)
Expand Down
2 changes: 2 additions & 0 deletions project/algorithms/jax_image_classifier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from project.algorithms.jax_image_classifier import JaxImageClassifier
from project.conftest import skip_on_macos_in_CI
from project.datamodules.image_classification.image_classification import (
ImageClassificationDataModule,
)
Expand All @@ -18,6 +19,7 @@ def prevent_jax_from_reserving_all_the_vram(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setenv("XLA_PYTHON_CLIENT_PREALLOCATE", "false")


@skip_on_macos_in_CI
@run_for_all_configs_of_type("algorithm", JaxImageClassifier)
@run_for_all_configs_of_type("algorithm/network", flax.linen.Module)
@run_for_all_configs_of_type("datamodule", ImageClassificationDataModule)
Expand Down
8 changes: 8 additions & 0 deletions project/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
from project.utils.env_vars import REPO_ROOTDIR
from project.utils.hydra_utils import resolve_dictconfig
from project.utils.testutils import (
IN_GITHUB_CI,
PARAM_WHEN_USED_MARK_NAME,
default_marks_for_config_combinations,
default_marks_for_config_name,
Expand All @@ -126,6 +127,13 @@
)


skip_on_macos_in_CI = pytest.mark.skipif(
sys.platform == "darwin" and IN_GITHUB_CI,
# raises=(RuntimeError, hydra.errors.InstantiationException),
reason="Raises 'MPS backend out of memory' error on MacOS in GitHub CI.",
)


@pytest.fixture(autouse=True)
def original_datadir(original_datadir: Path):
"""Overwrite the original_datadir fixture value to change where regression files are created.
Expand Down
2 changes: 1 addition & 1 deletion project/utils/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

IN_GITHUB_CI = "GITHUB_ACTIONS" in os.environ
IN_SELF_HOSTED_GITHUB_CI = IN_GITHUB_CI and "self-hosted" in os.environ.get("RUNNER_LABELS", "")
IN_GITHUB_COULD_CI = IN_GITHUB_CI and not IN_SELF_HOSTED_GITHUB_CI
IN_GITHUB_CLOUD_CI = IN_GITHUB_CI and not IN_SELF_HOSTED_GITHUB_CI
PARAM_WHEN_USED_MARK_NAME = "parametrize_when_used"


Expand Down

0 comments on commit 6cbdaf2

Please sign in to comment.