|
34 | 34 | Data, |
35 | 35 | sort_by_trial_index_and_arm_name, |
36 | 36 | ) |
| 37 | +from ax.core.experiment_status import ExperimentStatus |
37 | 38 | from ax.core.generator_run import GeneratorRun |
38 | 39 | from ax.core.metric import Metric, MetricFetchE, MetricFetchResult |
39 | 40 | from ax.core.objective import MultiObjective |
@@ -151,6 +152,7 @@ def __init__( |
151 | 152 | self._optimization_config: OptimizationConfig | None = None |
152 | 153 | self._tracking_metrics: dict[str, Metric] = {} |
153 | 154 | self._time_created: datetime = datetime.now() |
| 155 | + self._status: ExperimentStatus | None = None |
154 | 156 | self._trials: dict[int, BaseTrial] = {} |
155 | 157 | self._properties: dict[str, Any] = properties or {} |
156 | 158 |
|
@@ -236,6 +238,27 @@ def experiment_type(self, experiment_type: str | None) -> None: |
236 | 238 | """Set the type of the experiment.""" |
237 | 239 | self._experiment_type = experiment_type |
238 | 240 |
|
| 241 | + @property |
| 242 | + def status(self) -> ExperimentStatus | None: |
| 243 | + """The current status of the experiment. |
| 244 | +
|
| 245 | + Status tracks the high-level lifecycle phase of the experiment: |
| 246 | + DRAFT, INITIALIZATION, OPTIMIZATION, COMPLETED. |
| 247 | +
|
| 248 | + For new experiments, status defaults to DRAFT. For legacy experiments |
| 249 | + that were created before the status field was added, status may be None. |
| 250 | + """ |
| 251 | + return self._status |
| 252 | + |
| 253 | + @status.setter |
| 254 | + def status(self, status: ExperimentStatus | None) -> None: |
| 255 | + """Set the status of the experiment. |
| 256 | +
|
| 257 | + Args: |
| 258 | + status: The new status for the experiment. |
| 259 | + """ |
| 260 | + self._status = status |
| 261 | + |
239 | 262 | @property |
240 | 263 | def search_space(self) -> SearchSpace: |
241 | 264 | """The search space for this experiment. |
@@ -620,6 +643,18 @@ def remove_tracking_metric(self, metric_name: str) -> Experiment: |
620 | 643 | del self._tracking_metrics[metric_name] |
621 | 644 | return self |
622 | 645 |
|
| 646 | + def set_status(self, status: ExperimentStatus) -> Experiment: |
| 647 | + """Set the status of the experiment. |
| 648 | +
|
| 649 | + Args: |
| 650 | + status: The new status of the experiment. |
| 651 | +
|
| 652 | + Returns: |
| 653 | + The experiment instance. |
| 654 | + """ |
| 655 | + self._status = status |
| 656 | + return self |
| 657 | + |
623 | 658 | @property |
624 | 659 | def metrics(self) -> dict[str, Metric]: |
625 | 660 | """The metrics attached to the experiment.""" |
|
0 commit comments