Skip to content

Commit 5f528fb

Browse files
birka0veluca93
authored andcommitted
italy_yaml loader: support batch-and-output task type
1 parent 4425f7b commit 5f528fb

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

cmscontrib/loaders/italy_yaml.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def get_task(self, get_statement=True) -> Task | None:
459459

460460
args["submission_format"] = ["%s.%%l" % name]
461461

462-
# Import the feedback level when explicitly set to full
462+
# Import the feedback level when explicitly set
463463
# (default behaviour is restricted)
464464
if conf.get("feedback_level", None) == FEEDBACK_LEVEL_FULL:
465465
args["feedback_level"] = FEEDBACK_LEVEL_FULL
@@ -756,7 +756,7 @@ def get_task(self, get_statement=True) -> Task | None:
756756
Manager(other_filename, digest)]
757757
break
758758

759-
# Otherwise, the task type is Batch
759+
# Otherwise, the task type is Batch or BatchAndOutput
760760
else:
761761
args["task_type"] = "Batch"
762762
args["task_type_parameters"] = [
@@ -765,6 +765,15 @@ def get_task(self, get_statement=True) -> Task | None:
765765
evaluation_param,
766766
]
767767

768+
output_only_testcases = load(conf, None, "output_only_testcases",
769+
conv=lambda x: "" if x is None else x)
770+
if len(output_only_testcases) > 0:
771+
args["task_type"] = "BatchAndOutput"
772+
output_codenames = \
773+
["%03d" % int(x.strip()) for x in output_only_testcases.split(',')]
774+
task.submission_format.extend(["output_%s.txt" % s in output_codenames])
775+
args["task_type_parameters"].append(','.join(output_codenames))
776+
768777
args["testcases"] = []
769778
for i in range(n_input):
770779
input_digest = self.file_cacher.put_file_from_path(
@@ -773,11 +782,18 @@ def get_task(self, get_statement=True) -> Task | None:
773782
output_digest = self.file_cacher.put_file_from_path(
774783
os.path.join(self.path, "output", "output%d.txt" % i),
775784
"Output %d for task %s" % (i, task.name))
785+
test_codename = "%03d" % i
776786
args["testcases"] += [
777-
Testcase("%03d" % i, False, input_digest, output_digest)]
787+
Testcase(test_codename, False, input_digest, output_digest)]
788+
add_attachment = False
778789
if args["task_type"] == "OutputOnly":
779790
task.attachments.set(
780-
Attachment("input_%03d.txt" % i, input_digest))
791+
Attachment("input_%s.txt" % test_codename, input_digest))
792+
elif args["task_type"] == "BatchAndOutput":
793+
if output_codenames is not None and test_codename in output_codenames:
794+
task.attachments.set(
795+
Attachment("input_%s.txt" % test_codename, input_digest))
796+
781797
public_testcases = load(conf, None, ["public_testcases", "risultati"],
782798
conv=lambda x: "" if x is None else x)
783799
if public_testcases == "all":

0 commit comments

Comments
 (0)