Skip to content

Commit dd1934b

Browse files
author
Eric T. Dawson
committed
Fix a bug in scdl header saving. Files were saved to data_path, but this was occasionally changed over the lifetime of an object, leading to issues where the header_path was not updated to track the new datapath.
Signed-off-by: Eric T. Dawson <edawson@nvidia.com>
1 parent 83e2233 commit dd1934b

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

sub-packages/bionemo-scdl/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
]
2323

2424
[project.optional-dependencies]
25-
dev = [
25+
test = [
2626
"bionemo-core>=2.4.0",
2727
'pytest>=8.4.1'
2828
]

sub-packages/bionemo-scdl/src/bionemo/scdl/io/single_cell_memmap_dataset.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def __init__(
248248
"""
249249
self._version: str = importlib.metadata.version("bionemo.scdl")
250250
self.data_path: str = data_path
251-
self.header_path: Path = Path(data_path) / "header.sch"
251+
self.header_file_name: str = "header.sch"
252252
self.header: SCDLHeader = None
253253
self.mode: Mode = mode
254254
self.paginated_load_cutoff = paginated_load_cutoff
@@ -708,13 +708,13 @@ def load(self, stored_path: str) -> None:
708708
)
709709
self.data_path = stored_path
710710
self.mode = Mode.READ_APPEND
711-
self.header_path = Path(stored_path) / "header.sch"
711+
# self.header_path = Path(stored_path) / self.header_file_name
712712
# Load header if present; keep None if missing or unreadable
713-
if os.path.exists(self.header_path):
713+
if os.path.exists(self.data_path / self.header_file_name):
714714
try:
715-
self.header = SCDLHeader.load(str(self.header_path))
715+
self.header = SCDLHeader.load(str(self.data_path / self.header_file_name))
716716
except Exception as e:
717-
warnings.warn(f"Failed to load SCDL header at {self.header_path}: {e}")
717+
warnings.warn(f"Failed to load SCDL header at {Path(self.data_path) / self.header_file_name}: {e}")
718718
self.header = None
719719
else:
720720
self.header = None
@@ -1024,7 +1024,7 @@ def _write_header(self):
10241024
indexes,
10251025
)
10261026
)
1027-
header.save(str(self.header_path))
1027+
header.save(Path(self.data_path) / self.header_file_name)
10281028

10291029
def save(self, output_path: Optional[str] = None) -> None:
10301030
"""Saves the class to a given output path.

sub-packages/bionemo-scdl/tests/bionemo/scdl/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_directory() -> Path:
2929
Returns:
3030
A Path object that is the directory with test data.
3131
"""
32-
# return load("scdl/sample") / "scdl_data"
3332
return load("scdl/sample_scdl_feature_ids") / "scdl_data_with_feature_ids"
3433

3534

0 commit comments

Comments
 (0)