99from pytest import LogCaptureFixture
1010
1111import bids2table ._indexing as indexing
12- from bids2table ._indexing import index_dataset
13- from bids2table ._pathlib import cloudpathlib_is_available
1412
1513BIDS_EXAMPLES = Path (__file__ ).parents [1 ] / "bids-examples"
1614
@@ -55,9 +53,7 @@ def test_find_bids_datasets():
5553 assert datasets_no_derivatives == expected_datasets_no_derivatives
5654
5755
58- @pytest .mark .skipif (
59- not cloudpathlib_is_available (), reason = "cloudpathlib not installed"
60- )
56+ @pytest .mark .cloud
6157def test_find_bids_datasets_s3 ():
6258 root = "s3://openneuro.org"
6359 datasets = list (islice (indexing .find_bids_datasets (root , maxdepth = 2 ), 10 ))
@@ -83,9 +79,7 @@ def test_index_dataset(root: str, expected_count: int):
8379 assert len (table ) == expected_count
8480
8581
86- @pytest .mark .skipif (
87- not cloudpathlib_is_available (), reason = "cloudpathlib not installed"
88- )
82+ @pytest .mark .cloud
8983def test_index_dataset_s3 ():
9084 root = "s3://openneuro.org/ds000102"
9185 expected_count = 130
@@ -263,7 +257,7 @@ def test_index_dataset_accepts_schema_kwarg(tmp_path):
263257
264258 ns = deepcopy (bidsschematools .schema .load_schema ())
265259 ns .objects .entities .subject ["description" ] = "Modified once"
266- table = index_dataset (tmp_path / "ds" , schema = ns , max_workers = 0 )
260+ table = indexing . index_dataset (tmp_path / "ds" , schema = ns , max_workers = 0 )
267261 assert table .num_rows == 1
268262 assert "sub" in table .column_names
269263 assert table .schema .field ("sub" ).metadata [b"description" ] == b"Modified once"
@@ -281,22 +275,20 @@ def test_index_dataset_propagates_schema_to_workers(tmp_path):
281275
282276 ns = deepcopy (bidsschematools .schema .load_schema ())
283277 ns .objects .entities .subject ["description" ] = "Modified again"
284- table = index_dataset (tmp_path / "ds" , schema = ns , max_workers = 2 , chunksize = 1 )
278+ table = indexing . index_dataset (tmp_path / "ds" , schema = ns , max_workers = 2 , chunksize = 1 )
285279 assert table .num_rows == 1
286280 assert table .schema .field ("sub" ).metadata [b"description" ] == b"Modified again"
287281
288282
289283def test_batch_index_dataset_accepts_schema_kwarg (tmp_path ):
290- from bids2table ._indexing import batch_index_dataset
291-
292284 ds1 = tmp_path / "a"
293285 (ds1 / "sub-A01" / "anat" ).mkdir (parents = True )
294286 (ds1 / "dataset_description.json" ).write_text ('{"Name": "a"}' )
295287 (ds1 / "sub-A01" / "anat" / "sub-A01_T1w.nii.gz" ).touch ()
296288
297289 ns = deepcopy (bidsschematools .schema .load_schema ())
298290 ns .objects .entities .subject ["description" ] = "And again"
299- tables = list (batch_index_dataset ([ds1 ], schema = ns ))
291+ tables = list (indexing . batch_index_dataset ([ds1 ], schema = ns ))
300292 assert len (tables ) == 1
301293 assert tables [0 ].num_rows == 1
302294 assert tables [0 ].schema .field ("sub" ).metadata [b"description" ] == b"And again"
0 commit comments