Coverage for mlos_bench/mlos_bench/environments/status.py: 92%
26 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-21 01:50 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-21 01:50 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Enum for the status of the benchmark/environment Trial or Experiment."""
7import enum
10class Status(enum.Enum):
11 """Enum for the status of the benchmark/environment Trial or Experiment."""
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 Trial or Experiment is one
33 of {SUCCEEDED, 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 Trial or Experiment is
44 PENDING.
45 """
46 return self == Status.PENDING
48 def is_ready(self) -> bool:
49 """Check if the status of the benchmark/environment Trial or Experiment is
50 READY.
51 """
52 return self == Status.READY
54 def is_succeeded(self) -> bool:
55 """Check if the status of the benchmark/environment Trial or Experiment is
56 SUCCEEDED.
57 """
58 return self == Status.SUCCEEDED
60 def is_failed(self) -> bool:
61 """Check if the status of the benchmark/environment Trial or Experiment is
62 FAILED.
63 """
64 return self == Status.FAILED
66 def is_canceled(self) -> bool:
67 """Check if the status of the benchmark/environment Trial or Experiment is
68 CANCELED.
69 """
70 return self == Status.CANCELED
72 def is_timed_out(self) -> bool:
73 """Check if the status of the benchmark/environment Trial or Experiment is
74 TIMED_OUT.
75 """
76 return self == Status.FAILED