diff --git a/snakemake/persistence.py b/snakemake/persistence.py index 7d9ad0b4b..add87058f 100755 --- a/snakemake/persistence.py +++ b/snakemake/persistence.py @@ -35,10 +35,13 @@ def __init__( shadow_prefix=None, warn_only=False, ): - try: - self._serialize_param = self._serialize_param_pandas - except ModuleNotFoundError: - self._serialize_param = self._serialize_param_builtin + import importlib.util + + self._serialize_param = ( + self._serialize_param_pandas + if importlib.util.find_spec("pandas") is not None + else self._serialize_param_builtin + ) self._max_len = None diff --git a/tests/common.py b/tests/common.py index 8c6e5c067..e80f25556 100644 --- a/tests/common.py +++ b/tests/common.py @@ -56,6 +56,10 @@ def has_gcloud_service_key(): return "GCP_AVAILABLE" in os.environ +def has_azbatch_account_url(): + return os.environ.get("AZ_BATCH_ACCOUNT_URL") + + def has_zenodo_token(): return os.environ.get("ZENODO_SANDBOX_PAT") @@ -67,6 +71,12 @@ def has_zenodo_token(): "in to gcloud.", ) +azbatch = pytest.mark.skipif( + not is_connected() or not has_azbatch_account_url(), + reason="Skipping AZBATCH tests because " + "no inet connection or no AZ_BATCH_ACCOUNT_URL.", +) + connected = pytest.mark.skipif(not is_connected(), reason="no internet connection") ci = pytest.mark.skipif(not is_ci(), reason="not in CI") diff --git a/tests/test_azure_batch_executor.py b/tests/test_azure_batch_executor.py index 57c52c10f..2e54fd133 100644 --- a/tests/test_azure_batch_executor.py +++ b/tests/test_azure_batch_executor.py @@ -7,6 +7,7 @@ from common import * +@azbatch def test_az_batch_executor(): # AZ_BATCH_ACCOUNT_URL=https://${batch_account_name}.${region}.batch.azure.com bau = os.getenv("AZ_BATCH_ACCOUNT_URL")