Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pisek/opendata/managers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pisek.jobs.jobs import Job
from pisek.jobs.status import StatusJobManager
from pisek.jobs.job_pipeline import JobPipeline
from pisek.utils.paths import InputPath, OutputPath, RawPath
from pisek.utils.paths import IInputPath, IOutputPath, IRawPath

from pisek.task_jobs.tools import sanitize_job, sanitize_job_direct
from pisek.task_jobs.data.testcase_info import TestcaseInfo, TestcaseGenerationMode
Expand All @@ -17,12 +17,12 @@ def __init__(
gen_input: bool,
gen_output: bool,
check: bool,
input_: InputPath,
input_: IInputPath,
info: TestcaseInfo,
test: int,
seed: int | None,
correct_output: OutputPath,
contestant_output: RawPath | None,
correct_output: IOutputPath,
contestant_output: IRawPath | None,
):
super().__init__()
self.job_managers = []
Expand Down Expand Up @@ -51,7 +51,7 @@ def verdict(self) -> OpendataVerdict:


class InputManager(StatusJobManager):
def __init__(self, input_: InputPath, info: TestcaseInfo, seed: int | None):
def __init__(self, input_: IInputPath, info: TestcaseInfo, seed: int | None):
super().__init__(f"Generate input {input_:n}")
self._input = input_
self._info = info
Expand All @@ -76,7 +76,7 @@ def _get_jobs(self) -> list[Job]:


class OutputManager(StatusJobManager):
def __init__(self, input_: InputPath, info: TestcaseInfo, output: OutputPath):
def __init__(self, input_: IInputPath, info: TestcaseInfo, output: IOutputPath):
self._input = input_
self._info = info
self._output = output
Expand Down Expand Up @@ -107,11 +107,11 @@ def _get_jobs(self) -> list[Job]:
class CheckerManager(StatusJobManager):
def __init__(
self,
input_: InputPath,
input_: IInputPath,
test: int,
seed: int | None,
correct_output: OutputPath,
contestant_output: RawPath,
correct_output: IOutputPath,
contestant_output: IRawPath,
):
self._input = input_
self._test = test
Expand Down
8 changes: 4 additions & 4 deletions pisek/task_jobs/checker/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Optional

from pisek.env.env import Env
from pisek.utils.paths import InputPath, OutputPath
from pisek.utils.paths import IInputPath, IOutputPath
from pisek.config.config_types import OutCheck, JudgeType
from pisek.task_jobs.solution.solution_result import Verdict

Expand All @@ -28,9 +28,9 @@


def checker_job(
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
test: int,
seed: Optional[int],
expected_verdict: Optional[Verdict],
Expand Down
10 changes: 5 additions & 5 deletions pisek/task_jobs/checker/checker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from functools import cache

from pisek.utils.text import tab
from pisek.utils.paths import InputPath, OutputPath, LogPath
from pisek.utils.paths import IInputPath, IOutputPath, LogPath
from pisek.env.env import Env
from pisek.config.config_types import DataFormat
from pisek.task_jobs.tools import SanitizationResultKind
Expand All @@ -40,7 +40,7 @@ def __init__(
name: str,
test: int,
checker_name: str,
input_: InputPath,
input_: IInputPath,
checker_log_file: LogPath,
expected_verdict: Optional[Verdict],
**kwargs,
Expand Down Expand Up @@ -216,9 +216,9 @@ def __init__(
env: Env,
checker_name: str,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
expected_verdict: Optional[Verdict],
**kwargs,
) -> None:
Expand Down
8 changes: 4 additions & 4 deletions pisek/task_jobs/checker/cms_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tempfile import gettempdir
from uuid import uuid4

from pisek.utils.paths import InputPath, OutputPath
from pisek.utils.paths import IInputPath, IOutputPath
from pisek.env.env import Env
from pisek.config.task_config import RunSection
from pisek.config.config_types import ProgramRole
Expand Down Expand Up @@ -101,9 +101,9 @@ def __init__(
env: Env,
judge: RunSection,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
expected_verdict: Optional[Verdict],
**kwargs,
) -> None:
Expand Down
8 changes: 4 additions & 4 deletions pisek/task_jobs/checker/diff_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import Optional

from pisek.env.env import Env
from pisek.utils.paths import InputPath, OutputPath
from pisek.utils.paths import IInputPath, IOutputPath
from pisek.jobs.jobs import PipelineItemFailure
from pisek.utils.text import tab
from pisek.task_jobs.run_result import RunResult, RunResultKind
Expand All @@ -34,9 +34,9 @@ def __init__(
self,
env: Env,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
expected_verdict: Optional[Verdict],
) -> None:
super().__init__(
Expand Down
14 changes: 7 additions & 7 deletions pisek/task_jobs/checker/judgelib_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Optional

from pisek.env.env import Env
from pisek.utils.paths import TaskPath, InputPath, OutputPath
from pisek.utils.paths import TaskPath, IInputPath, IOutputPath
from pisek.jobs.jobs import PipelineItemFailure
from pisek.utils.text import tab
from pisek.task_jobs.run_result import RunResult, RunResultKind
Expand Down Expand Up @@ -92,9 +92,9 @@ def __init__(
self,
env: Env,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
expected_verdict: Optional[Verdict],
) -> None:
super().__init__(
Expand Down Expand Up @@ -133,9 +133,9 @@ def __init__(
self,
env: Env,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
expected_verdict: Optional[Verdict],
) -> None:
super().__init__(
Expand Down
8 changes: 4 additions & 4 deletions pisek/task_jobs/checker/opendata_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging
from typing import Any

from pisek.utils.paths import InputPath, OutputPath
from pisek.utils.paths import IInputPath, IOutputPath
from pisek.env.env import Env
from pisek.config.config_types import ProgramRole
from pisek.config.task_config import RunSection
Expand Down Expand Up @@ -52,9 +52,9 @@ def __init__(
env: Env,
judge: RunSection,
test: int,
input_: InputPath,
output: OutputPath,
correct_output: OutputPath,
input_: IInputPath,
output: IOutputPath,
correct_output: IOutputPath,
seed: int | None,
expected_verdict: Verdict | None,
**kwargs,
Expand Down
6 changes: 3 additions & 3 deletions pisek/task_jobs/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from pisek.jobs.jobs import PipelineItemFailure
from pisek.env.env import Env
from pisek.utils.paths import TaskPath, InputPath, OutputPath
from pisek.utils.paths import TaskPath, IInputPath, IOutputPath
from pisek.task_jobs.task_job import TaskJob


Expand Down Expand Up @@ -62,7 +62,7 @@ def _run(self):
class InputSmall(DataJob):
"""Checks that input is small enough to download."""

def __init__(self, env: Env, input_: InputPath, **kwargs) -> None:
def __init__(self, env: Env, input_: IInputPath, **kwargs) -> None:
super().__init__(
env=env,
name=f"Input {input_:p} is smaller than {env.config.limits.input_max_size}MB",
Expand All @@ -81,7 +81,7 @@ def _run(self):
class OutputSmall(DataJob):
"""Checks that output is small enough to upload."""

def __init__(self, env: Env, output: OutputPath, **kwargs) -> None:
def __init__(self, env: Env, output: IOutputPath, **kwargs) -> None:
super().__init__(
env=env,
name=f"Output {output:p} is smaller than {env.config.limits.output_max_size}MB",
Expand Down
15 changes: 12 additions & 3 deletions pisek/task_jobs/data/testcase_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@

from pisek.env.env import Env
from pisek.task_jobs.task_job import TaskJob
from pisek.utils.paths import TESTS_DIR, INPUTS_LIST, InputPath, OutputPath, TaskPath
from pisek.utils.paths import (
TESTS_DIR,
INPUTS_LIST,
InputPath,
IInputPath,
IOutputPath,
OutputPath,
TaskPath,
)


class TestcaseGenerationMode(StrEnum):
Expand Down Expand Up @@ -46,7 +54,7 @@ def static(name: str) -> "TestcaseInfo":

def input_path(
self, seed: int | None = None, solution: str | None = None
) -> InputPath:
) -> IInputPath:
filename = self.name
if self.seeded:
assert seed is not None
Expand All @@ -57,10 +65,11 @@ def input_path(

def reference_output(
self, env: Env, seed: int | None = None, solution: str | None = None
) -> OutputPath:
) -> IOutputPath:
is_static = self.generation_mode == TestcaseGenerationMode.static

input_path = self.input_path(seed, solution=env.config.primary_solution)
path: IOutputPath
if is_static:
path = OutputPath.static(input_path.replace_suffix(".out").name)
else:
Expand Down
4 changes: 2 additions & 2 deletions pisek/task_jobs/generator/base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pisek.env.env import Env
from pisek.jobs.jobs import PipelineItemFailure
from pisek.config.task_config import RunSection
from pisek.utils.paths import InputPath
from pisek.utils.paths import IInputPath
from pisek.task_jobs.task_job import TaskJob
from pisek.task_jobs.program import ProgramsJob
from pisek.task_jobs.data.testcase_info import TestcaseInfo, TestcaseGenerationMode
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(
generator: RunSection,
testcase_info: TestcaseInfo,
seed: Optional[int],
input_path: InputPath,
input_path: IInputPath,
*,
name: str = "",
**kwargs,
Expand Down
12 changes: 6 additions & 6 deletions pisek/task_jobs/generator/generator_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from hashlib import blake2b

from pisek.env.env import Env
from pisek.utils.paths import InputPath, OutputPath
from pisek.utils.paths import IInputPath, IOutputPath
from pisek.config.config_types import GenType
from pisek.config.task_config import RunSection
from pisek.jobs.jobs import Job, JobManager
Expand Down Expand Up @@ -91,7 +91,7 @@ def generate_input(


def generate_input_direct(
env: Env, testcase_info: TestcaseInfo, seed: Optional[int], input_path: InputPath
env: Env, testcase_info: TestcaseInfo, seed: Optional[int], input_path: IInputPath
) -> GenerateInput:
assert env.config.tests.in_gen is not None
assert env.config.tests.gen_type is not None
Expand Down Expand Up @@ -126,7 +126,7 @@ def generator_test_determinism(
class TestcaseInfoMixin(JobManager):
def __init__(self, name: str, **kwargs) -> None:
self.inputs: dict[str, tuple[set[int], int | None]] = {}
self.input_dataset: set[InputPath] = set()
self.input_dataset: set[IInputPath] = set()
self._gen_inputs_job: dict[Optional[int], GenerateInput] = {}

self._jobs: list[Job] = []
Expand Down Expand Up @@ -240,7 +240,7 @@ def _add_generate_input_jobs(
)
)

def _validate(self, input_path: InputPath, test_num: int) -> ValidatorJob:
def _validate(self, input_path: IInputPath, test_num: int) -> ValidatorJob:
assert self._env.config.tests.validator is not None
assert self._env.config.tests.validator_type is not None

Expand Down Expand Up @@ -283,7 +283,7 @@ def _add_respects_seed_jobs(
for i in range(2):
check_seeded.add_prerequisite(self._gen_inputs_job[seeds[i]])

def _check_input_jobs(self, input_path: InputPath) -> None:
def _check_input_jobs(self, input_path: IInputPath) -> None:
self._add_job(
sanitize_job(self._env, input_path, True),
new_last=True,
Expand All @@ -294,7 +294,7 @@ def _check_input_jobs(self, input_path: InputPath) -> None:

def _add_check_output_jobs(
self,
output_path: OutputPath,
output_path: IOutputPath,
) -> None:
self._add_job(
sanitize_job(self._env, output_path, False),
Expand Down
4 changes: 2 additions & 2 deletions pisek/task_jobs/generator/opendata_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pisek.env.env import Env
from pisek.config.config_types import ProgramRole
from pisek.config.task_config import RunSection
from pisek.utils.paths import InputPath
from pisek.utils.paths import IInputPath
from pisek.task_jobs.program import ProgramsJob, RunResultKind
from pisek.task_jobs.data.testcase_info import TestcaseInfo

Expand Down Expand Up @@ -45,7 +45,7 @@ class OpendataV1GeneratorJob(ProgramsJob):
generator: RunSection
seed: Optional[int]
testcase_info: TestcaseInfo
input_path: InputPath
input_path: IInputPath

def __init__(self, env: Env, *, name: str = "", **kwargs) -> None:
super().__init__(env=env, name=name, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions pisek/task_jobs/generator/pisek_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pisek.env.env import Env
from pisek.config.config_types import ProgramRole
from pisek.config.task_config import RunSection
from pisek.utils.paths import TaskPath, InputPath, LogPath
from pisek.utils.paths import TaskPath, IInputPath, LogPath
from pisek.task_jobs.program import ProgramsJob, RunResultKind
from pisek.task_jobs.data.testcase_info import TestcaseInfo

Expand Down Expand Up @@ -89,7 +89,7 @@ class PisekV1GeneratorJob(ProgramsJob):
generator: RunSection
seed: Optional[int]
testcase_info: TestcaseInfo
input_path: InputPath
input_path: IInputPath

def __init__(self, env: Env, *, name: str = "", **kwargs) -> None:
super().__init__(env=env, name=name, **kwargs)
Expand Down
Loading