Skip to content

Commit 81641c6

Browse files
Michał Sośnickimichalsosn
authored andcommitted
chore: filter runs by sys/id in neptune2
1 parent 6646b56 commit 81641c6

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/neptune_exporter/exporters/neptune2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ def list_runs(
107107
with neptune.init_project(
108108
api_token=self._api_token, project=project_id, mode="read-only"
109109
) as project:
110-
runs_table = project.fetch_runs_table(
111-
columns=["sys/custom_run_id", "sys/id"]
112-
).to_pandas()
110+
runs_table = project.fetch_runs_table().to_pandas()
113111
if not len(runs_table):
114112
return []
115113

116114
if runs is not None:
117-
runs_table = runs_table[runs_table["sys/custom_run_id"].str.match(runs)]
115+
runs_table = runs_table[runs_table["sys/id"].str.match(runs)]
118116
return list(runs_table["sys/id"])
119117

120118
def download_parameters(

tests/integration/neptune2/test_neptune2.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,24 @@ def test_neptune2_download_files(api_token, project, test_runs, temp_dir):
192192
assert "metadata" in item, "Artifact file data should have metadata"
193193

194194

195+
def test_neptune2_list_runs_with_regex_filter(api_token, project, test_runs):
196+
"""Test list_runs filters runs using regex pattern."""
197+
exporter = Neptune2Exporter(api_token=api_token)
198+
199+
# Test with pattern that matches all (should return at least test_runs)
200+
all_matching = exporter.list_runs(project_id=project, runs=".*")
201+
assert len(all_matching) >= len(test_runs)
202+
assert set(test_runs).issubset(set(all_matching))
203+
204+
first_run_id = test_runs[0]
205+
prefix_pattern = f".*{first_run_id[4:]}$"
206+
prefix_matching = exporter.list_runs(project_id=project, runs=prefix_pattern)
207+
assert first_run_id in prefix_matching
208+
209+
# Test with pattern that matches none
210+
no_matching = exporter.list_runs(project_id=project, runs="^NONEXISTENT-")
211+
assert len(no_matching) == 0
212+
213+
195214
def _to_table(parameters: Generator[pa.RecordBatch, None, None]) -> pa.Table:
196215
return pa.Table.from_batches(parameters, schema=model.SCHEMA)

0 commit comments

Comments
 (0)