Skip to content

Commit

Permalink
feat: JOJ3 issue enhancement (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
mQzLjP authored Oct 9, 2024
1 parent 9647b5d commit 0e54dd5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
15 changes: 14 additions & 1 deletion joint_teapot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ def joj3_scoreboard(
scoreboard_file_name: str = Argument(
"scoreboard.csv", help="name of scoreboard file in the gitea repo"
),
exercise_name: str = Argument(
"unknown",
help="name of the exercise that appears on the issue title",
),
) -> None:
set_settings(Settings(_env_file=env_path))
set_logger(settings.stderr_log_level, diagnose=False, backtrace=False)
Expand All @@ -256,6 +260,7 @@ def joj3_scoreboard(
score_file_path,
submitter,
os.path.join(repo_path, scoreboard_file_name),
exercise_name,
)
actions_link = (
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
Expand Down Expand Up @@ -294,6 +299,10 @@ def joj3_failed_table(
failed_table_file_name: str = Argument(
"failed-table.md", help="name of failed table file in the gitea repo"
),
exercise_name: str = Argument(
"unknown",
help="name of the exercise that appears on the issue title",
),
) -> None:
set_settings(Settings(_env_file=env_path))
set_logger(settings.stderr_log_level, diagnose=False, backtrace=False)
Expand Down Expand Up @@ -355,6 +364,10 @@ def joj3_create_result_issue(
"",
help="gitea actions run number",
),
exercise_name: str = Argument(
"unknown",
help="name of the exercise that appears on the issue title",
),
) -> None:
set_settings(Settings(_env_file=env_path))
set_logger(settings.stderr_log_level, diagnose=False, backtrace=False)
Expand All @@ -367,7 +380,7 @@ def joj3_create_result_issue(
+ f"actions/runs/{run_number}"
)
title, comment = joj3.generate_title_and_comment(
score_file_path, actions_link, run_number
score_file_path, actions_link, run_number, exercise_name
)
tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False)

Expand Down
28 changes: 13 additions & 15 deletions joint_teapot/utils/joj3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def generate_scoreboard(
score_file_path: str, submitter: str, scoreboard_file_path: str
score_file_path: str, submitter: str, scoreboard_file_path: str, exercise_name: str
) -> None:
if not scoreboard_file_path.endswith(".csv"):
logger.error(
Expand Down Expand Up @@ -50,12 +50,12 @@ def generate_scoreboard(
with open(score_file_path) as json_file:
stages: List[Dict[str, Any]] = json.load(json_file)

exercise_name = "unknown"
for stage in stages:
if stage["name"] != "metadata":
continue
comment = stage["results"][0]["comment"]
exercise_name = comment.split("-")[0]
if exercise_name == "unknown":
for stage in stages:
if stage["name"] != "metadata":
continue
comment = stage["results"][0]["comment"]
exercise_name = comment.split("-")[0]
# Find if exercise in table:
if exercise_name not in columns:
column_tail = columns[3:]
Expand Down Expand Up @@ -179,7 +179,7 @@ def generate_failed_table(


def generate_title_and_comment(
score_file_path: str, action_link: str, run_number: str
score_file_path: str, action_link: str, run_number: str, exercise_name: str
) -> Tuple[str, str]:
with open(score_file_path) as json_file:
stages: List[Dict[str, Any]] = json.load(json_file)
Expand All @@ -195,19 +195,17 @@ def generate_title_and_comment(
force_quit = stage["force_quit"]
if force_quit:
comment += " - Failed"
single_case = len(stage["results"]) == 1
if single_case:
comment += f" - Score: {stage['results'][0]['score']}"
comment += "\n"
for i, result in enumerate(stage["results"]):
if not single_case:
comment += f"### Case {i} - Score: {result['score']}\n"
comment += (
f"<details><summary>Case {i} - Score: {result['score']}</summary>\n"
)
if result["comment"].strip() != "":
comment += f"{result['comment']}\n"
total_score += result["score"]
comment += "</details>\n\n"
comment += "\n"
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
title = f"JOJ3 Result {now} - Score: {total_score}"
title = f"JOJ3 Result for {exercise_name} - Score: {total_score}"
return title, comment


Expand Down

0 comments on commit 0e54dd5

Please sign in to comment.