Skip to content

Commit

Permalink
[Projects] Count aborted job for the failed jobs counter (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Apr 13, 2021
1 parent b7c7b43 commit 4c2a372
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mlrun/api/db/sqldb/db.py
Expand Up @@ -927,7 +927,12 @@ def _get_project_resources_counters(self, session: Session):
)
project_to_running_runs_count[run.project] += 1
if self._is_run_matching_state(
run, run_json, mlrun.runtimes.constants.RunStates.error
run,
run_json,
[
mlrun.runtimes.constants.RunStates.error,
mlrun.runtimes.constants.RunStates.aborted,
],
):
one_day_ago = datetime.now() - timedelta(hours=24)
if run.start_time and run.start_time >= one_day_ago:
Expand Down
13 changes: 12 additions & 1 deletion tests/api/api/test_projects.py
Expand Up @@ -93,6 +93,17 @@ def test_list_projects_summary_format(db: Session, client: TestClient) -> None:
one_hour_ago,
)

# create aborted runs for the project for less than 24 hours ago - make sure we count them as well
recent_aborted_runs_count = 6
one_hour_ago = datetime.datetime.now() - datetime.timedelta(hours=1)
_create_runs(
client,
project_name,
recent_failed_runs_count,
mlrun.runtimes.constants.RunStates.aborted,
one_hour_ago,
)

# create failed runs for the project for more than 24 hours ago to make sure we're not mistakenly count them
two_days_ago = datetime.datetime.now() - datetime.timedelta(hours=48)
_create_runs(
Expand All @@ -113,7 +124,7 @@ def test_list_projects_summary_format(db: Session, client: TestClient) -> None:
functions_count,
feature_sets_count,
models_count,
recent_failed_runs_count,
recent_failed_runs_count + recent_aborted_runs_count,
running_runs_count,
)
else:
Expand Down

0 comments on commit 4c2a372

Please sign in to comment.