Coverage for mlos_bench/mlos_bench/environments/status.py: 93%
27 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6Enum for the status of the benchmark/environment.
7"""
9import enum
12class Status(enum.Enum):
13 """
14 Enum for the status of the benchmark/environment.
15 """
17 UNKNOWN = 0
18 PENDING = 1
19 READY = 2
20 RUNNING = 3
21 SUCCEEDED = 4
22 CANCELED = 5
23 FAILED = 6
24 TIMED_OUT = 7
26 def is_good(self) -> bool:
27 """
28 Check if the status of the benchmark/environment is good.
29 """
30 return self in {
31 Status.PENDING,
32 Status.READY,
33 Status.RUNNING,
34 Status.SUCCEEDED,
35 }
37 def is_completed(self) -> bool:
38 """
39 Check if the status of the benchmark/environment is
40 one of {SUCCEEDED, CANCELED, FAILED, TIMED_OUT}.
41 """
42 return self in {
43 Status.SUCCEEDED,
44 Status.CANCELED,
45 Status.FAILED,
46 Status.TIMED_OUT,
47 }
49 def is_pending(self) -> bool:
50 """
51 Check if the status of the benchmark/environment is PENDING.
52 """
53 return self == Status.PENDING
55 def is_ready(self) -> bool:
56 """
57 Check if the status of the benchmark/environment is READY.
58 """
59 return self == Status.READY
61 def is_succeeded(self) -> bool:
62 """
63 Check if the status of the benchmark/environment is SUCCEEDED.
64 """
65 return self == Status.SUCCEEDED
67 def is_failed(self) -> bool:
68 """
69 Check if the status of the benchmark/environment is FAILED.
70 """
71 return self == Status.FAILED
73 def is_canceled(self) -> bool:
74 """
75 Check if the status of the benchmark/environment is CANCELED.
76 """
77 return self == Status.CANCELED
79 def is_timed_out(self) -> bool:
80 """
81 Check if the status of the benchmark/environment is TIMED_OUT.
82 """
83 return self == Status.FAILED