-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.py
61 lines (48 loc) · 1.62 KB
/
pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from pathlib import Path
from typing import Dict, Iterable, List, Mapping, Optional
from dto import Verdict
@dataclass(frozen=True)
class Workspace:
name: str
size: int # in bytes
@dataclass(frozen=True)
class Bind:
src: str
dest: str
read_only: bool = field(default=True)
@dataclass(frozen=True)
class Step:
name: str
rootfs: str
cwd: str
exec: str
args: List[str]
stdin: str = field(default='/dev/null')
stdout: str = field(default='/dev/null')
stderr: str = field(default='/dev/null')
message_file: Optional[str] = field(default=None)
prerequisites: List[str] = field(default_factory=list)
bindings: List[Bind] = field(default_factory=list)
memory_limit: int = 268435456 # in bytes
time_limit: float = 3.0 # in seconds
pids_limit: int = 1
envs: Dict[str, str] = field(default_factory=dict)
@dataclass(frozen=True)
class Summary:
score: float
ignored: bool
message: str
class AbstractPipeline(ABC):
def __init__(self, *, name: str, workspaces: List[Workspace], source_dir: str):
self.name = name
self.workspaces: List[Workspace] = workspaces
self.source_dir: str = source_dir
@abstractmethod
def define_steps(self, problem_dir: Path, workspaces: Dict[str, Path]) -> Iterable[Step]:
raise NotImplementedError
@abstractmethod
def summarize(self, verdicts: Mapping[str, Verdict]) -> Summary:
"""Note: if summarization takes a long time, use a new step for computation instead"""
raise NotImplementedError