Skip to content

Commit

Permalink
[Runs] Fix list runs name filter exploding on run with no name (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Dec 20, 2020
1 parent e5d3eb4 commit ee1d28a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mlrun/api/db/sqldb/db.py
Expand Up @@ -1615,7 +1615,7 @@ def _post_query_runs_filter(
if (
not run_json
or not isinstance(run_json, dict)
or name not in run_json.get("metadata", {}).get("name")
or name not in run_json.get("metadata", {}).get("name", "")
):
continue
if state:
Expand Down
8 changes: 7 additions & 1 deletion tests/api/db/test_runs.py
Expand Up @@ -17,17 +17,23 @@ def test_list_runs_name_filter(db: DBInterface, db_session: Session):
run_name_2 = "run_name_2"
run_1 = {"metadata": {"name": run_name_1}, "status": {"bla": "blabla"}}
run_2 = {"metadata": {"name": run_name_2}, "status": {"bla": "blabla"}}
# run with no name
run_3 = {"metadata": {}, "status": {"bla": "blabla"}}
run_uid_1 = "run_uid_1"
run_uid_2 = "run_uid_2"
run_uid_3 = "run_uid_3"

db.store_run(
db_session, run_1, run_uid_1,
)
db.store_run(
db_session, run_2, run_uid_2,
)
db.store_run(
db_session, run_3, run_uid_3,
)
runs = db.list_runs(db_session)
assert len(runs) == 2
assert len(runs) == 3

runs = db.list_runs(db_session, name=run_name_1)
assert len(runs) == 1
Expand Down

0 comments on commit ee1d28a

Please sign in to comment.