Skip to content

Commit 513c39d

Browse files
authored
Merge pull request #307 from gkreitz/be_more_helpful_when_uuid_is_missing
Suggest a new UUID when missing from config
2 parents 733f88a + cf5441c commit 513c39d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

problemtools/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Metadata2023_07(BaseModel):
113113

114114
problem_format_version: str
115115
name: dict[str, str] | str
116-
uuid: UUID
116+
uuid: UUID | None = None # UUID *is* mandatory, but we deal with that in verifyproblem for better UX
117117
type: list[ProblemType] | ProblemType = ProblemType.PASS_FAIL
118118
version: str | None = None
119119
credits: dict | str | None = None

problemtools/verifyproblem.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33
from __future__ import annotations
44

5+
import argparse
56
import concurrent.futures
67
from concurrent.futures import ThreadPoolExecutor
78
import threading
@@ -20,8 +21,7 @@
2021
import copy
2122
import random
2223
import traceback
23-
24-
import argparse
24+
import uuid
2525

2626
import yaml
2727

@@ -875,6 +875,13 @@ def check(self, context: Context) -> bool:
875875
if self._metadata.license == metadata.License.UNKNOWN:
876876
self.warning("License is 'unknown'")
877877

878+
if self._metadata.uuid is None:
879+
uuid_msg = f'Missing uuid from problem.yaml. Add "uuid: {uuid.uuid4()}" to problem.yaml.'
880+
if self.problem.format.name == formatversion.VERSION_LEGACY:
881+
self.warning(uuid_msg)
882+
else:
883+
self.error(uuid_msg)
884+
878885
if self._metadata.legacy_grading.show_test_data_groups and self._metadata.is_pass_fail():
879886
self.error('Showing test data groups is only supported for scoring problems, this is a pass-fail problem')
880887
if (

0 commit comments

Comments
 (0)