forked from facebook/Ax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshould_generate_candidates.py
More file actions
51 lines (45 loc) · 1.5 KB
/
Copy pathshould_generate_candidates.py
File metadata and controls
51 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from typing import final
import pandas as pd
from ax.adapter.base import Adapter
from ax.analysis.analysis import Analysis
from ax.analysis.healthcheck.healthcheck_analysis import (
create_healthcheck_analysis_card,
HealthcheckAnalysisCard,
HealthcheckStatus,
)
from ax.core.experiment import Experiment
from ax.generation_strategy.generation_strategy import GenerationStrategy
from pyre_extensions import override
@final
class ShouldGenerateCandidates(Analysis):
def __init__(
self,
should_generate: bool,
reason: str,
trial_index: int,
) -> None:
self.should_generate = should_generate
self.reason = reason
self.trial_index = trial_index
@override
def compute(
self,
experiment: Experiment | None = None,
generation_strategy: GenerationStrategy | None = None,
adapter: Adapter | None = None,
) -> HealthcheckAnalysisCard:
status = (
HealthcheckStatus.PASS if self.should_generate else HealthcheckStatus.INFO
)
return create_healthcheck_analysis_card(
name=self.__class__.__name__,
title=f"Ready to Generate Candidates for Trial {self.trial_index}",
subtitle=self.reason,
df=pd.DataFrame(),
status=status,
)