Skip to content

Commit

Permalink
Add tests for filtering runs and experiments by sys/id
Browse files Browse the repository at this point in the history
  • Loading branch information
kgodlewski committed Oct 25, 2024
1 parent c5e8283 commit dba58d8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/e2e/test_run_filtering.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from operator import itemgetter

import pytest

Expand Down Expand Up @@ -58,6 +59,32 @@ def test__experiments_by_custom_id_regex(project, sys_columns, regex, expect_ids
assert df["sys/name"].tolist() == expect_names


def test__runs_by_sys_id(project, sys_columns, all_run_ids, all_experiment_ids):
runs = sorted(project.list_runs(), key=itemgetter("sys/custom_run_id"))
# Take every 2nd run to test the actual filtering
sys_ids = [run["sys/id"] for i, run in enumerate(runs) if i % 2 == 0]

df = project.fetch_runs_df(columns=sys_columns, with_ids=sys_ids, sort_by="sys/custom_run_id", ascending=True)

expect_ids = (all_experiment_ids + all_run_ids)[::2]
assert df["sys/custom_run_id"].tolist() == expect_ids
assert df["sys/id"].tolist() == sys_ids


def test__experiments_by_sys_id(project, sys_columns, all_experiment_ids):
runs = sorted(project.list_experiments(), key=itemgetter("sys/custom_run_id"))
# Take every 2nd experiment to test the actual filtering
sys_ids = [run["sys/id"] for i, run in enumerate(runs) if i % 2 == 0]

df = project.fetch_experiments_df(
columns=sys_columns, with_ids=sys_ids, sort_by="sys/custom_run_id", ascending=True
)

expect_ids = all_experiment_ids[::2]
assert df["sys/custom_run_id"].tolist() == expect_ids
assert df["sys/id"].tolist() == sys_ids


@pytest.mark.parametrize(
"names_regex, custom_id_regex, custom_ids, expect_ids",
[
Expand Down

0 comments on commit dba58d8

Please sign in to comment.