This repository was archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path__init__.py
More file actions
77 lines (65 loc) · 2.47 KB
/
__init__.py
File metadata and controls
77 lines (65 loc) · 2.47 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
import os.path
from abc import ABC, abstractmethod
from enum import Enum
from task_maker.remote import ExecutionPool, Execution
from task_maker.task_maker_frontend import File, Result
from typing import Optional, List, Tuple
class StatementCompilationStatus(Enum):
"""
Status of the compilation of a statement
"""
WAITING = 0 # the compilation is pending
COMPILING_DEPS = 1 # the dependencies are compiling
COMPILED_DEPS = 2 # the dependencies are compiled
COMPILING = 3 # the compilation has started
DONE = 4 # the compilation completed successfully
FAILED = 5 # the compilation failed
class StatementDepCompilationStatus(Enum):
"""
Status of the execution of a statement dependency
"""
WAITING = 0 # the execution is pending
RUNNING = 1 # the execution is running
DONE = 2 # the execution completed successfully
FAILED = 3 # the execution failed
class StatementDepInfo:
"""
Information of a statement dependency
"""
def __init__(self, name: str, execution: Execution):
self.name = name
self.execution = execution
self.result = None # type: Optional[Result]
self.status = StatementDepCompilationStatus.WAITING
class Statement(ABC):
"""
Manage and compile statement files, all the executions populated after the
compile method need the getResult method to be called.
"""
def __init__(self, path: str):
self.path = path
self.name = os.path.basename(self.path)
self.compilation = None # type: Execution
self.compilation_result = None # type: Result
self.compilation_status = StatementCompilationStatus.WAITING
self.pdf_file = None # type: Optional[File]
self.other_executions = [] # type: List[StatementDepInfo]
@staticmethod
@abstractmethod
def compile_booklet(pool: ExecutionPool,
statements: List["Statement"],
language: Optional[str] = None
) -> Tuple[Execution, File, List[StatementDepInfo]]:
"""
Compile the booklet composed by the specified statements, the statements
should be already compiled (the compile method already called)
"""
pass
@abstractmethod
def compile(self, pool: ExecutionPool, language: Optional[str] = None):
"""
Compile the statement file by adding some executions to the computation
DAG.
"""
pass