Skip to content

Commit

Permalink
Fix tool quality
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Oct 26, 2023
1 parent 3838831 commit a4715a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 8 additions & 4 deletions dispatcher/backend/maint-scripts/find_schedules_in_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

""" Find all schedules which are enabled and have at least the last two tasks which
failed in a row
./find_schedules_in_errors"""

import sqlalchemy as sa
Expand All @@ -14,7 +14,7 @@

@dbsession
def find_schedules_in_errors(session: so.Session):
print(f"looking after schedules with bad status")
print("Looking after schedules with bad status")

stmt = (
sa.select(dbm.Schedule).where(dbm.Schedule.enabled).order_by(dbm.Schedule.name)
Expand All @@ -32,7 +32,8 @@ def find_schedules_in_errors(session: so.Session):

if nb_success == 0:
print(
f"Never succeeded: schedule {schedule.name} (periodicity={schedule.periodicity}) never succeeded out of {total} attempts"
f"Never succeeded: schedule {schedule.name} (periodicity="
f"{schedule.periodicity}) never succeeded out of {total} attempts"
)
continue

Expand All @@ -45,7 +46,10 @@ def find_schedules_in_errors(session: so.Session):

if nb_failures_in_a_row > 1:
print(
f"Many failures in a row: schedule {schedule.name} (periodicity={schedule.periodicity}) failed {nb_failures_in_a_row} times in a row, nb_success: {nb_success}, nb_failed: {nb_failed}, total: {total}"
f"Many failures in a row: schedule {schedule.name} (periodicity="
f"{schedule.periodicity}) failed {nb_failures_in_a_row} times in"
f" a row, nb_success: {nb_success}, nb_failed: {nb_failed},"
f" total: {total}"
)
continue

Expand Down
16 changes: 11 additions & 5 deletions dispatcher/backend/maint-scripts/relaunch_failed_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@dbsession
def relaunch_failed_recipes(session: so.Session, start_date: str):
print(f"Loading tasks that have failed since start_date")
print("Loading tasks that have failed since start_date")

start_datetime = datetime.datetime.fromisoformat(start_date)
stmt = (
Expand All @@ -46,7 +46,8 @@ def relaunch_failed_recipes(session: so.Session, start_date: str):
).total_seconds()
if scraper_duration > 60:
print(
f"Ignoring schedule {task.schedule.name}, duration was {scraper_duration}"
f"Ignoring schedule {task.schedule.name}, duration was "
f"{scraper_duration}"
)
continue

Expand All @@ -60,7 +61,8 @@ def relaunch_failed_recipes(session: so.Session, start_date: str):

if nb_success == 0:
print(
f"Ignoring schedule {task.schedule.name}, never succeeded out of {total} attempts"
f"Ignoring schedule {task.schedule.name}, never succeeded out of "
f"{total} attempts"
)
continue

Expand All @@ -73,12 +75,16 @@ def relaunch_failed_recipes(session: so.Session, start_date: str):

if nb_failures_in_a_row > 1:
print(
f"Ignoring schedule {task.schedule.name}, too many failures in a row, failed: {nb_failed}, failure_in_a_row: {nb_failures_in_a_row}, nb_success: {nb_success}, total: {total}"
f"Ignoring schedule {task.schedule.name}, too many failures in a row,"
f" failed: {nb_failed}, failure_in_a_row: {nb_failures_in_a_row},"
f" nb_success: {nb_success}, total: {total}"
)
continue

print(
f"Requesting schedule {task.schedule.name} failed: {nb_failed}, failure_in_a_row: {nb_failures_in_a_row}, nb_success: {nb_success}, total: {total}"
f"Requesting schedule {task.schedule.name} failed: {nb_failed}, "
f"failure_in_a_row: {nb_failures_in_a_row}, nb_success: {nb_success},"
f" total: {total}"
)

# Uncomment below to really request the schedule
Expand Down

0 comments on commit a4715a2

Please sign in to comment.