Repartition: retry in case of bad assign
This commit is contained in:
parent
0514f80a77
commit
0e7a6c54ae
1 changed files with 18 additions and 2 deletions
|
@ -47,7 +47,7 @@ class AssignError(Exception):
|
||||||
|
|
||||||
|
|
||||||
def assigner_taches(root_task: Category | Task, group_count: int):
|
def assigner_taches(root_task: Category | Task, group_count: int):
|
||||||
"""Assigne les tâches aux groupes (round-robin)"""
|
"""Assigne les tâches aux groupes (multiway number partitioning)"""
|
||||||
|
|
||||||
TaskId = t.NewType("TaskId", int)
|
TaskId = t.NewType("TaskId", int)
|
||||||
UniqueTask: t.TypeAlias = tuple[TaskId, int]
|
UniqueTask: t.TypeAlias = tuple[TaskId, int]
|
||||||
|
@ -209,7 +209,23 @@ def main() -> None:
|
||||||
if args.bare_tasks:
|
if args.bare_tasks:
|
||||||
util.write_to_file(args.bare_tasks, export_bare_tasks_md(config))
|
util.write_to_file(args.bare_tasks, export_bare_tasks_md(config))
|
||||||
|
|
||||||
|
retry: int = 0
|
||||||
|
MAX_RETRY: int = 4
|
||||||
|
while retry < MAX_RETRY:
|
||||||
|
try:
|
||||||
groupes = repartition(config)
|
groupes = repartition(config)
|
||||||
|
break
|
||||||
|
except AssignError as exn:
|
||||||
|
retry += 1
|
||||||
|
logger.warning(
|
||||||
|
"[essai %d/%d] Échec de répartition des tâches : %s",
|
||||||
|
retry,
|
||||||
|
MAX_RETRY,
|
||||||
|
exn,
|
||||||
|
)
|
||||||
|
if retry == MAX_RETRY:
|
||||||
|
logger.critical("Échec de répartition des tâches.")
|
||||||
|
raise exn from exn
|
||||||
|
|
||||||
if args.to_tex:
|
if args.to_tex:
|
||||||
util.write_to_file(args.to_tex, export_latex(config, groupes))
|
util.write_to_file(args.to_tex, export_latex(config, groupes))
|
||||||
|
|
Loading…
Reference in a new issue