Skip to content

Commit 32ed4a5

Browse files
authored
Merge pull request #62 from kaitj/fix/cloudpaths
Fix cloudpathlib error when package not available
2 parents f3d111c + fdf5552 commit 32ed4a5

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ jobs:
4141
uses: astral-sh/setup-uv@v6
4242
with:
4343
python-version: ${{ matrix.python-version }}
44-
- name: Run tests
44+
45+
- name: Run tests without cloudpathlib
46+
run: |
47+
uv run pytest tests
48+
- name: Run tests with cloudpathlib
4549
run: |
4650
uv run --all-extras pytest \
4751
--junitxml=pytest.xml \

bids2table/_indexing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from typing import Any, Callable, Generator, Iterable, Sequence
1616

1717
import pyarrow as pa
18-
from cloudpathlib import CloudPath
1918
from tqdm import tqdm
2019

2120
from ._entities import (
@@ -24,7 +23,7 @@
2423
validate_bids_entities,
2524
)
2625
from ._logging import setup_logger
27-
from ._pathlib import PathT, as_path
26+
from ._pathlib import CloudPath, PathT, as_path, cloudpathlib_is_available
2827

2928
_BIDS_SUBJECT_DIR_PATTERN = re.compile(r"sub-[a-zA-Z0-9]+")
3029

@@ -404,7 +403,7 @@ def _index_bids_subject_dir(
404403

405404
records = []
406405
# Use built-in rglob methods for CloudPath and py3.13+
407-
if isinstance(path, CloudPath):
406+
if cloudpathlib_is_available() and isinstance(path, CloudPath):
408407
paths = map(as_path, path.rglob("sub-*"))
409408
elif sys.version_info >= (3, 13):
410409
paths = map(as_path, path.rglob("sub-*", recurse_symlinks=True))

tests/test_indexing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def test_find_bids_datasets():
5252
assert datasets_no_derivatives == expected_datasets_no_derivatives
5353

5454

55+
@pytest.mark.skipif(
56+
not cloudpathlib_is_available(), reason="cloudpathlib not installed"
57+
)
5558
def test_find_bids_datasets_s3():
5659
root = "s3://openneuro.org"
5760
datasets = list(islice(indexing.find_bids_datasets(root, maxdepth=2), 10))

0 commit comments

Comments
 (0)