Coverage for o2/models/timetable/multitask.py: 100%
31 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-05-16 11:18 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-05-16 11:18 +0000
1from dataclasses import dataclass
2from typing import Optional
4from dataclass_wizard import JSONWizard
6from o2.models.days import DAY
9@dataclass(frozen=True)
10class ParallelTaskProbability(JSONWizard):
11 """The probability of a resource to be used for a certain number of parallel tasks."""
13 parallel_tasks: int
14 probability: float
17@dataclass(frozen=True)
18class TimePeriodWithParallelTaskProbability(JSONWizard):
19 """A time period with information about the probability of parallel tasks."""
21 from_: "DAY"
22 """The start of the time period (day, uppercase, e.g. MONDAY)
24 NOTE: In the json the field is called `from` (from is a reserved keyword in Python)
25 """
27 to: "DAY"
28 """The end of the time period (day, uppercase, e.g. FRIDAY)"""
30 begin_time: str
31 """The start time of the time period (24h format, e.g. 08:00)"""
32 end_time: str
33 """The end time of the time period (24h format, e.g. 17:00)"""
34 multitask_info: Optional[list[ParallelTaskProbability]] = None
36 class _(JSONWizard.Meta): # noqa: N801
37 json_key_to_field = {
38 "__all__": True, # type: ignore
39 "from": "from_",
40 "beginTime": "begin_time",
41 "endTime": "end_time",
42 }
45@dataclass(frozen=True)
46class MultitaskResourceInfo(JSONWizard):
47 """The information about a resource that can handle multiple tasks in parallel."""
49 resource_id: str
50 r_workload: float
51 multitask_info: Optional[list[ParallelTaskProbability]] = None
52 weekly_probability: Optional[list[list[TimePeriodWithParallelTaskProbability]]] = None
55@dataclass(frozen=True)
56class Multitask(JSONWizard):
57 """The information about all resources that can handle multiple tasks in parallel."""
59 type: str
60 values: list[MultitaskResourceInfo]