File tree Expand file tree Collapse file tree 4 files changed +13
-31
lines changed Expand file tree Collapse file tree 4 files changed +13
-31
lines changed Original file line number Diff line number Diff line change 6
6
# pyre-strict
7
7
8
8
from enum import Enum
9
- from typing import Any , Optional , Protocol
9
+ from typing import Optional , Protocol
10
10
11
11
import pandas as pd
12
12
from ax .core .experiment import Experiment
@@ -33,9 +33,11 @@ class AnalysisCard:
33
33
34
34
df : pd .DataFrame # Raw data produced by the Analysis
35
35
36
- # pyre-ignore[4] We explicitly want to allow any type here, blob is narrowed in
37
- # AnalysisCard's subclasses
38
- blob : Any # Data processed and ready for end-user consumption
36
+ # Blob is the data processed for end-user consumption, encoded as a string,
37
+ # typically JSON. Subclasses of Analysis can define their own methods for consuming
38
+ # the blob and presenting it to the user (ex. PlotlyAnalysisCard.get_figure()
39
+ # decodes the blob into a go.Figure object).
40
+ blob : str
39
41
40
42
# How to interpret the blob (ex. "dataframe", "plotly", "markdown")
41
43
blob_annotation = "dataframe"
@@ -47,9 +49,7 @@ def __init__(
47
49
subtitle : str ,
48
50
level : AnalysisCardLevel ,
49
51
df : pd .DataFrame ,
50
- # pyre-ignore[2] We explicitly want to allow any type here, blob is narrowed in
51
- # AnalysisCard's subclasses
52
- blob : Any ,
52
+ blob : str ,
53
53
) -> None :
54
54
self .name = name
55
55
self .title = title
Original file line number Diff line number Diff line change 7
7
8
8
from typing import Optional
9
9
10
- import pandas as pd
11
- from ax .analysis .analysis import Analysis , AnalysisCard , AnalysisCardLevel
10
+ from ax .analysis .analysis import Analysis , AnalysisCard
12
11
from ax .core .experiment import Experiment
13
12
from ax .modelbridge .generation_strategy import GenerationStrategy
14
13
15
14
16
15
class MarkdownAnalysisCard (AnalysisCard ):
17
- name : str
18
-
19
- title : str
20
- subtitle : str
21
- level : AnalysisCardLevel
22
-
23
- df : pd .DataFrame
24
- blob : str
25
16
blob_annotation = "markdown"
26
17
27
18
def get_markdown (self ) -> str :
Original file line number Diff line number Diff line change 16
16
from ax .core .objective import MultiObjective , ScalarizedObjective
17
17
from ax .exceptions .core import UnsupportedError , UserInputError
18
18
from ax .modelbridge .generation_strategy import GenerationStrategy
19
- from plotly import graph_objects as go
19
+ from plotly import graph_objects as go , io as pio
20
20
21
21
22
22
class ParallelCoordinatesPlot (PlotlyAnalysis ):
@@ -61,7 +61,7 @@ def compute(
61
61
subtitle = "View arm parameterizations with their respective metric values" ,
62
62
level = AnalysisCardLevel .HIGH ,
63
63
df = df ,
64
- blob = fig ,
64
+ blob = pio . to_json ( fig ) ,
65
65
)
66
66
67
67
Original file line number Diff line number Diff line change 7
7
8
8
from typing import Optional
9
9
10
- import pandas as pd
11
- from ax .analysis .analysis import Analysis , AnalysisCard , AnalysisCardLevel
10
+ from ax .analysis .analysis import Analysis , AnalysisCard
12
11
from ax .core .experiment import Experiment
13
12
from ax .modelbridge .generation_strategy import GenerationStrategy
14
- from plotly import graph_objects as go
13
+ from plotly import graph_objects as go , io as pio
15
14
16
15
17
16
class PlotlyAnalysisCard (AnalysisCard ):
18
- name : str
19
-
20
- title : str
21
- subtitle : str
22
- level : AnalysisCardLevel
23
-
24
- df : pd .DataFrame
25
- blob : go .Figure
26
17
blob_annotation = "plotly"
27
18
28
19
def get_figure (self ) -> go .Figure :
29
- return self .blob
20
+ return pio . from_json ( self .blob )
30
21
31
22
32
23
class PlotlyAnalysis (Analysis ):
You can’t perform that action at this time.
0 commit comments