galb-dai commited on
Commit
6446f53
·
1 Parent(s): 5d63385

Fix problem ID validation.

Browse files
Files changed (3) hide show
  1. app.py +5 -1
  2. src/submission/submit.py +2 -1
  3. src/validation/validate.py +14 -4
app.py CHANGED
@@ -156,7 +156,10 @@ with blocks:
156
  if len(submission_path) == 0:
157
  return styled_error("Please upload JSONL submission file.")
158
 
159
- if not is_submission_file_valid(submission_path):
 
 
 
160
  return styled_error("Failed to read JSONL submission file. Please try again later.")
161
 
162
  # Validating all user-supplied arguments.
@@ -185,6 +188,7 @@ with blocks:
185
  sys_type,
186
  submission_path,
187
  ensure_all_present=ENSURE_ALL_PRESENT,
 
188
  )
189
 
190
  submit_button.click(
 
156
  if len(submission_path) == 0:
157
  return styled_error("Please upload JSONL submission file.")
158
 
159
+ if not is_submission_file_valid(
160
+ submission_path,
161
+ is_warmup_dataset=(SPLIT == "warmup"),
162
+ ):
163
  return styled_error("Failed to read JSONL submission file. Please try again later.")
164
 
165
  # Validating all user-supplied arguments.
 
188
  sys_type,
189
  submission_path,
190
  ensure_all_present=ENSURE_ALL_PRESENT,
191
+ is_warmup_dataset=(SPLIT == "warmup"),
192
  )
193
 
194
  submit_button.click(
src/submission/submit.py CHANGED
@@ -47,6 +47,7 @@ def add_new_solutions(
47
  sys_type: str,
48
  submission_path: str,
49
  ensure_all_present: bool = False,
 
50
  ):
51
  logger.info(
52
  f"Adding new submission! {system_name=}, {org=}, {sys_type=} and {submission_path=}",
@@ -55,7 +56,7 @@ def add_new_solutions(
55
  # Double-checking.
56
  for val in [system_name, org, sys_type]:
57
  assert is_valid(val)
58
- assert is_submission_file_valid(submission_path)
59
 
60
  sys_type = ModelType.from_str(sys_type).name
61
 
 
47
  sys_type: str,
48
  submission_path: str,
49
  ensure_all_present: bool = False,
50
+ is_warmup_dataset: bool,
51
  ):
52
  logger.info(
53
  f"Adding new submission! {system_name=}, {org=}, {sys_type=} and {submission_path=}",
 
56
  # Double-checking.
57
  for val in [system_name, org, sys_type]:
58
  assert is_valid(val)
59
+ assert is_submission_file_valid(submission_path, is_warmup_dataset=is_warmup_dataset)
60
 
61
  sys_type = ModelType.from_str(sys_type).name
62
 
src/validation/validate.py CHANGED
@@ -4,6 +4,7 @@ import string
4
 
5
  from src.logger import get_logger
6
 
 
7
  DATASET_SIZE = 120
8
 
9
  MIN_INPUT_LENGTH = 2
@@ -46,10 +47,14 @@ def is_valid(
46
  return True
47
 
48
 
49
- def is_submission_file_valid(submission_path: str) -> bool:
 
 
 
50
  """
51
  @brief Checks whether the given submission file is valid.
52
  @param submission_path The path to the submission file.
 
53
  @return True iff the file is within the size constraints, a JSONL, and every line is no longer than
54
  the fixed maximum bound.
55
  """
@@ -93,9 +98,14 @@ def is_submission_file_valid(submission_path: str) -> bool:
93
  logger.warning("Could not convert problem ID to int")
94
  return False
95
 
96
- if problem_id < 0 or problem_id >= DATASET_SIZE:
97
- logger.warning(f"Problem ID {problem_id} is beyond allowed bounds")
98
- return False
 
 
 
 
 
99
 
100
  if problem_id in seen_ids:
101
  logger.warning(f"Got duplicate submission -- ID {problem_id} appears twice")
 
4
 
5
  from src.logger import get_logger
6
 
7
+ WARMUP_DATASET_SIZE = 100
8
  DATASET_SIZE = 120
9
 
10
  MIN_INPUT_LENGTH = 2
 
47
  return True
48
 
49
 
50
+ def is_submission_file_valid(
51
+ submission_path: str,
52
+ is_warmup_dataset: bool,
53
+ ) -> bool:
54
  """
55
  @brief Checks whether the given submission file is valid.
56
  @param submission_path The path to the submission file.
57
+ @param is_warmup_dataset Whether we are working on the regular or the warmup dataset.
58
  @return True iff the file is within the size constraints, a JSONL, and every line is no longer than
59
  the fixed maximum bound.
60
  """
 
98
  logger.warning("Could not convert problem ID to int")
99
  return False
100
 
101
+ if is_warmup_dataset:
102
+ if problem_id < DATASET_SIZE or problem_id >= DATASET_SIZE + WARMUP_DATASET_SIZE:
103
+ logger.warning(f"Problem ID {problem_id} is beyond allowed bounds")
104
+ return False
105
+ else:
106
+ if problem_id < 0 or problem_id >= DATASET_SIZE:
107
+ logger.warning(f"Problem ID {problem_id} is beyond allowed bounds")
108
+ return False
109
 
110
  if problem_id in seen_ids:
111
  logger.warning(f"Got duplicate submission -- ID {problem_id} appears twice")