Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Projects] Count aborted job for the failed jobs counter #861

Merged
merged 4 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion mlrun/api/db/sqldb/db.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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