Skip to content

Commit 6aa811f

Browse files
authored
Merge pull request #224 from BioMedicalImaging-Core-NYUAD/kidlang_pipeline
Kidlang pipeline
2 parents 8acb181 + 823fe5e commit 6aa811f

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

.github/workflows/box-dataset-info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
run: |
2525
python -m pip install --upgrade pip
2626
pip install "boxsdk[jwt]"
27+
python -c "import boxsdk; print(f'boxsdk version: {boxsdk.__version__}')"
2728
2829
- name: Run Box Info Script
2930
env:

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@
8787
"env": {
8888
"PYTHONPATH": "${workspaceFolder}"
8989
}
90+
},
91+
{
92+
"name": "Run Tests",
93+
"type": "python",
94+
"module": "pytest",
95+
"request": "launch",
96+
"args": [
97+
"-q",
98+
"tests/test_pipelines_kit_mne.py"
99+
],
100+
"console": "integratedTerminal",
101+
"env": {
102+
"PYTHONPATH": "${workspaceFolder}"
103+
}
90104
}
91105
]
92106
}

pipeline/box_storage/box_utilities.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ def _box_find_dataset_folder_id_direct(client, *, parent_folder_id: str, dataset
3535
f"Dataset '{dataset_name}' not found directly under Box folder {parent_folder_id}."
3636
)
3737

38-
def _box_mirror_folder(client, folder_id: str, out_dir: Path) -> None:
38+
def _box_mirror_folder(client, folder_id: str, out_dir: Path, exclude_folders: list = None) -> None:
39+
"""Mirror a Box folder to local directory, optionally excluding specified folders.
40+
41+
Args:
42+
client: Box client instance
43+
folder_id: Box folder ID to mirror
44+
out_dir: Local output directory
45+
exclude_folders: List of folder names to skip (e.g., ["derivatives"])
46+
"""
47+
if exclude_folders is None:
48+
exclude_folders = []
49+
3950
out_dir.mkdir(parents=True, exist_ok=True)
4051
def _walk(fid: str, local: Path):
4152
local.mkdir(parents=True, exist_ok=True)
@@ -51,7 +62,9 @@ def _walk(fid: str, local: Path):
5162
with open(tgt, "wb") as fh:
5263
client.file(item.id).download_to(fh)
5364
elif item.type == "folder":
54-
_walk(item.id, local / item.name)
65+
# Skip excluded folders
66+
if item.name not in exclude_folders:
67+
_walk(item.id, local / item.name)
5568
if count < limit:
5669
break
5770
offset += limit
@@ -80,7 +93,8 @@ def ensure_dataset_present(project_name: str, meg_data_root: Path) -> Path:
8093
client, parent_folder_id=parent_folder_id, dataset_name=project_name
8194
)
8295

83-
_box_mirror_folder(client, dataset_folder_id, bids_root)
96+
# Exclude derivatives folder to ensure tests generate fresh outputs
97+
_box_mirror_folder(client, dataset_folder_id, bids_root, exclude_folders=["derivatives"])
8498
if not _has_local_dataset(bids_root):
8599
raise AssertionError(f"Downloaded dataset appears empty at {bids_root}")
86100
return bids_root

0 commit comments

Comments
 (0)