Skip to content

Commit b71ab52

Browse files
committed
Auto-detect dataset directory name from extracted archive
Instead of hardcoding DATASET_ID as the expected subdirectory name, find the single directory inside the extracted archive. Errors if there is not exactly one directory. https://claude.ai/code/session_01X3Dg23mnjFYU1fjJBrahjt
1 parent ac9db87 commit b71ab52

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

tests/symmetry/make_artifacts/dataset/test_download_ingested.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ def test_download_ingested_artifacts(self):
8888
for dot_underscore in artifact_dir.rglob("._*"):
8989
dot_underscore.unlink()
9090

91-
# The extracted directory is the dataset
92-
dataset_path = artifact_dir / DATASET_ID
93-
assert dataset_path.is_dir(), f"Expected extracted directory {DATASET_ID} not found."
91+
# The extracted directory is the dataset (name may differ from the archive)
92+
subdirs = [p for p in artifact_dir.iterdir() if p.is_dir()]
93+
assert len(subdirs) == 1, (
94+
f"Expected exactly one directory inside the archive, found {len(subdirs)}: "
95+
f"{[p.name for p in subdirs]}"
96+
)
97+
dataset_path = subdirs[0]
9498

9599
# Open the dataset
96100
dataset = Dataset(dataset_path)

tests/symmetry/read_artifacts/dataset/test_download_ingested.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from ndi.util import compareSessionSummary, sessionSummary
2525
from tests.symmetry.conftest import SOURCE_TYPES, SYMMETRY_BASE
2626

27-
DATASET_ID = "69a8705aa9ab25373cdc6563"
2827

2928

3029
@pytest.fixture(params=SOURCE_TYPES)
@@ -57,11 +56,17 @@ def _open_dataset(self, source_type):
5756
if not summary_path.exists():
5857
pytest.skip(f"datasetSummary.json not found in {source_type} artifact directory.")
5958

60-
dataset_path = artifact_dir / DATASET_ID
61-
if not dataset_path.exists():
59+
# Find the single dataset subdirectory (name may differ from archive)
60+
subdirs = [
61+
p for p in artifact_dir.iterdir()
62+
if p.is_dir() and p.name != "jsonDocuments"
63+
]
64+
if len(subdirs) != 1:
6265
pytest.skip(
63-
f"Expected dataset directory {DATASET_ID} not found in {source_type} artifacts."
66+
f"Expected exactly one dataset directory in {source_type} artifacts, "
67+
f"found {len(subdirs)}."
6468
)
69+
dataset_path = subdirs[0]
6570

6671
expected = json.loads(summary_path.read_text(encoding="utf-8"))
6772
dataset = Dataset(dataset_path)

0 commit comments

Comments
 (0)