Skip to content

Commit

Permalink
fix: Detect pandas availability to select serializer (snakemake#2300)
Browse files Browse the repository at this point in the history
### Description

- previous try catch solution wasn't triggered
- use detecting availability of the module instead

### QC
<!-- Make sure that you can tick the boxes below. -->

* [ ] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).

---------

Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
3 people authored and vsoch committed Jun 20, 2023
1 parent 8aed62c commit 69d822e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 7 additions & 4 deletions snakemake/persistence.py
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions tests/common.py
Expand Up @@ -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")

Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions tests/test_azure_batch_executor.py
Expand Up @@ -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")
Expand Down

0 comments on commit 69d822e

Please sign in to comment.