feat: less arguments
This commit is contained in:
parent
0c2fdaaa34
commit
a686b5df5a
|
@ -209,21 +209,18 @@ def unsubscribe_from_repos(pattern: str = Argument("")) -> None:
|
|||
"joj3-scoreboard",
|
||||
help="parse JOJ3 score json file into scoreboard and upload to gitea",
|
||||
)
|
||||
def JOJ3_scoreboard(
|
||||
def joj3_scoreboard(
|
||||
env_path: str = Argument("", help="path to .env file"),
|
||||
scorefile_path: str = Argument(
|
||||
"", help="path to score json file generated by JOJ3"
|
||||
),
|
||||
submitter: str = Argument(
|
||||
"", help="name of submitter, either student name + id, or group name"
|
||||
),
|
||||
submitter: str = Argument("", help="submitter ID"),
|
||||
repo_name: str = Argument(
|
||||
"",
|
||||
help="name of local gitea repo folder, or link to remote gitea repo, to push scoreboard file",
|
||||
help="name of grading repo to push scoreboard file",
|
||||
),
|
||||
exercise_name: str = Argument("", help="exercise name of this json score file"),
|
||||
scoreboard_file_name: str = Argument(
|
||||
"", help="name of scoreboard file in the gitea repo"
|
||||
"scoreboard.csv", help="name of scoreboard file in the gitea repo"
|
||||
),
|
||||
) -> None:
|
||||
set_settings(Settings(_env_file=env_path))
|
||||
|
@ -241,7 +238,6 @@ def JOJ3_scoreboard(
|
|||
joj3.generate_scoreboard(
|
||||
scorefile_path,
|
||||
submitter,
|
||||
exercise_name,
|
||||
os.path.join(repo_path, scoreboard_file_name),
|
||||
)
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
@ -254,25 +250,21 @@ def JOJ3_scoreboard(
|
|||
"joj3-failed-table",
|
||||
help="parse JOJ3 score json file into failed table markdown file and upload to gitea",
|
||||
)
|
||||
def JOJ3_failed_table(
|
||||
def joj3_failed_table(
|
||||
env_path: str = Argument("", help="path to .env file"),
|
||||
scorefile_path: str = Argument(
|
||||
"", help="path to score json file generated by JOJ3"
|
||||
),
|
||||
repo_name: str = Argument(
|
||||
"",
|
||||
help="name of local gitea repo folder, or link to remote gitea repo, to push scoreboard file",
|
||||
help="name of grading repo to push scoreboard file",
|
||||
),
|
||||
submitter_repo_name: str = Argument(
|
||||
"",
|
||||
help="repository's name of the submitter",
|
||||
),
|
||||
submitter_repo_link: str = Argument(
|
||||
"",
|
||||
help="repository's url link of the submitter",
|
||||
),
|
||||
failedtable_file_name: str = Argument(
|
||||
"", help="name of failed table file in the gitea repo"
|
||||
failed_table_file_name: str = Argument(
|
||||
"failed-table.md", help="name of failed table file in the gitea repo"
|
||||
),
|
||||
) -> None:
|
||||
set_settings(Settings(_env_file=env_path))
|
||||
|
@ -287,15 +279,19 @@ def JOJ3_failed_table(
|
|||
logger.error('"grading" branch not found in local, create it first.')
|
||||
return
|
||||
repo.git.reset("--hard", "origin/grading")
|
||||
submitter_repo_link = (
|
||||
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
|
||||
+ f"{settings.gitea_org_name}/{submitter_repo_name}"
|
||||
)
|
||||
joj3.generate_failed_table(
|
||||
scorefile_path,
|
||||
submitter_repo_name,
|
||||
submitter_repo_link,
|
||||
os.path.join(repo_path, failedtable_file_name),
|
||||
os.path.join(repo_path, failed_table_file_name),
|
||||
)
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
tea.pot.git.add_commit_and_push(
|
||||
repo_name, [failedtable_file_name], f"test: JOJ3-dev testing at {now}"
|
||||
repo_name, [failed_table_file_name], f"test: JOJ3-dev testing at {now}"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from joint_teapot.utils.logger import logger
|
|||
|
||||
|
||||
def generate_scoreboard(
|
||||
score_file_path: str, submitter: str, exercise_name: str, scoreboard_file_path: str
|
||||
score_file_path: str, submitter: str, scoreboard_file_path: str
|
||||
) -> None:
|
||||
if not scoreboard_file_path.endswith(".csv"):
|
||||
logger.error(
|
||||
|
@ -46,6 +46,15 @@ def generate_scoreboard(
|
|||
) # FIXME: In formal version should be -2
|
||||
data.append(submitter_row)
|
||||
|
||||
# Update data
|
||||
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":
|
||||
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:]
|
||||
|
@ -55,10 +64,6 @@ def generate_scoreboard(
|
|||
for row in data:
|
||||
row.insert(index, "")
|
||||
|
||||
# Update data
|
||||
with open(score_file_path) as json_file:
|
||||
stages: List[Dict[str, Any]] = json.load(json_file)
|
||||
|
||||
exercise_total_score = 0
|
||||
for stage in stages:
|
||||
for result in stage["results"]:
|
||||
|
|
Loading…
Reference in New Issue
Block a user