Coverage for mlos_bench/mlos_bench/environments/status.py: 92%
26 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-22 01:18 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Enum for the status of the benchmark/environment."""
7import enum
10class Status(enum.Enum):
11 """Enum for the status of the benchmark/environment."""
13 UNKNOWN = 0
14 PENDING = 1
15 READY = 2
16 RUNNING = 3
17 SUCCEEDED = 4
18 CANCELED = 5
19 FAILED = 6
20 TIMED_OUT = 7
22 def is_good(self) -> bool:
23 """Check if the status of the benchmark/environment is good."""
24 return self in {
25 Status.PENDING,
26 Status.READY,
27 Status.RUNNING,
28 Status.SUCCEEDED,
29 }
31 def is_completed(self) -> bool:
32 """Check if the status of the benchmark/environment is one of {SUCCEEDED,
33 CANCELED, FAILED, TIMED_OUT}.
34 """
35 return self in {
36 Status.SUCCEEDED,
37 Status.CANCELED,
38 Status.FAILED,
39 Status.TIMED_OUT,
40 }
42 def is_pending(self) -> bool:
43 """Check if the status of the benchmark/environment is PENDING."""
44 return self == Status.PENDING
46 def is_ready(self) -> bool:
47 """Check if the status of the benchmark/environment is READY."""
48 return self == Status.READY
50 def is_succeeded(self) -> bool:
51 """Check if the status of the benchmark/environment is SUCCEEDED."""
52 return self == Status.SUCCEEDED
54 def is_failed(self) -> bool:
55 """Check if the status of the benchmark/environment is FAILED."""
56 return self == Status.FAILED
58 def is_canceled(self) -> bool:
59 """Check if the status of the benchmark/environment is CANCELED."""
60 return self == Status.CANCELED
62 def is_timed_out(self) -> bool:
63 """Check if the status of the benchmark/environment is TIMED_OUT."""
64 return self == Status.FAILED