Skip to content

Commit 3443a43

Browse files
Stabilize remote source provenance
1 parent f42c034 commit 3443a43

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/spine/io/read/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def get_source_provenance(
146146
file_path = self.file_paths[file_idx]
147147
provenance = {
148148
"source_file_name": os.path.basename(file_path),
149+
"source_file_size": -1,
150+
"source_file_mtime_ns": -1,
149151
"source_file_entry_index": int(file_entry_idx),
150152
}
151153
if not self.is_remote_path(file_path):

test/test_io/test_read/test_base.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,29 @@ def test_reader_base_process_file_paths(tmp_path):
6464
assert not ReaderBase.is_remote_path(str(first))
6565

6666

67+
def test_reader_base_source_provenance_local_and_remote(tmp_path):
68+
"""Source provenance should expose a stable key set for all path types."""
69+
local_path = tmp_path / "input.root"
70+
local_path.write_text("data", encoding="utf-8")
71+
72+
reader = DummyReader()
73+
reader.file_paths = [str(local_path)]
74+
local = reader.get_source_provenance(0, 3)
75+
assert local["source_file_name"] == local_path.name
76+
assert local["source_file_size"] == local_path.stat().st_size
77+
assert local["source_file_mtime_ns"] == local_path.stat().st_mtime_ns
78+
assert local["source_file_entry_index"] == 3
79+
80+
reader.file_paths = ["root://server/path/input.root"]
81+
remote = reader.get_source_provenance(0, 4)
82+
assert remote == {
83+
"source_file_name": "input.root",
84+
"source_file_size": -1,
85+
"source_file_mtime_ns": -1,
86+
"source_file_entry_index": 4,
87+
}
88+
89+
6790
def test_reader_base_process_file_paths_errors(tmp_path):
6891
"""ReaderBase should reject invalid file path inputs."""
6992
reader = DummyReader()

0 commit comments

Comments
 (0)