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

1from dataclasses import dataclass 

2from typing import Optional 

3 

4from dataclass_wizard import JSONWizard 

5 

6from o2.models.days import DAY 

7 

8 

9@dataclass(frozen=True) 

10class ParallelTaskProbability(JSONWizard): 

11 """The probability of a resource to be used for a certain number of parallel tasks.""" 

12 

13 parallel_tasks: int 

14 probability: float 

15 

16 

17@dataclass(frozen=True) 

18class TimePeriodWithParallelTaskProbability(JSONWizard): 

19 """A time period with information about the probability of parallel tasks.""" 

20 

21 from_: "DAY" 

22 """The start of the time period (day, uppercase, e.g. MONDAY) 

23 

24 NOTE: In the json the field is called `from` (from is a reserved keyword in Python) 

25 """ 

26 

27 to: "DAY" 

28 """The end of the time period (day, uppercase, e.g. FRIDAY)""" 

29 

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 

35 

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 } 

43 

44 

45@dataclass(frozen=True) 

46class MultitaskResourceInfo(JSONWizard): 

47 """The information about a resource that can handle multiple tasks in parallel.""" 

48 

49 resource_id: str 

50 r_workload: float 

51 multitask_info: Optional[list[ParallelTaskProbability]] = None 

52 weekly_probability: Optional[list[list[TimePeriodWithParallelTaskProbability]]] = None 

53 

54 

55@dataclass(frozen=True) 

56class Multitask(JSONWizard): 

57 """The information about all resources that can handle multiple tasks in parallel.""" 

58 

59 type: str 

60 values: list[MultitaskResourceInfo]