Skip to content

Commit

Permalink
modify importorskip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolAbril committed Apr 5, 2024
1 parent 089c542 commit 56b861d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
10 changes: 7 additions & 3 deletions .azure-pipelines/azure-pipelines-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ jobs:
variables:
- name: NUMBA_DISABLE_JIT
value: 1
- name: ARVIZ_CI_MACHINE
value: 1
timeoutInMinutes: 360
strategy:
matrix:
Expand Down Expand Up @@ -82,9 +80,15 @@ jobs:
python -m pip freeze
displayName: 'Print packages'
- script: |
ARVIZ_REQUIRE_ALL_DEPS=TRUE python -m pytest arviz/tests/base_tests --cov arviz --cov-report=xml
condition: and(succeeded(), eq(variables.OptionalRequirements, true))
displayName: 'pytest (require all dependencies)'
- script: |
python -m pytest arviz/tests/base_tests --cov arviz --cov-report=xml
displayName: 'pytest'
condition: and(succeeded(), eq(variables.OptionalRequirements, false))
displayName: 'pytest (skip if dependency missing)'
- script: |
ls -ahl
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
variables:
- name: NUMBA_DISABLE_JIT
value: 1
- name: ARVIZ_CI_MACHINE
- name: ARVIZ_REQUIRE_ALL_DEPS
value: 1
timeoutInMinutes: 360
strategy:
Expand Down
11 changes: 3 additions & 8 deletions arviz/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,6 @@ def test_precompile_models(eight_schools_params, draws, chains):
load_cached_models(eight_schools_params, draws, chains)


def running_on_ci() -> bool:
"""Return True if running on CI machine."""
return os.environ.get("ARVIZ_CI_MACHINE") is not None


def importorskip(
modname: str, minversion: Optional[str] = None, reason: Optional[str] = None
) -> Any:
Expand All @@ -643,9 +638,9 @@ def importorskip(
Example::
docutils = pytest.importorskip("docutils")
"""
# ARVIZ_CI_MACHINE is True if tests run on CI, where ARVIZ_CI_MACHINE env variable exists
ARVIZ_CI_MACHINE = running_on_ci()
if not ARVIZ_CI_MACHINE:
# Unless ARVIZ_REQUIRE_ALL_DEPS is defined, tests that require a missing dependency are skipped
# if set, missing optional dependencies trigger failed tests.
if "ARVIZ_REQUIRE_ALL_DEPS" not in os.environ:
return pytest.importorskip(modname=modname, minversion=minversion, reason=reason)
import warnings

Expand Down

0 comments on commit 56b861d

Please sign in to comment.