Skip to content

Commit 1efcfce

Browse files
Merge branch 'master' into 215-make-memory-a-parameter
2 parents b21ac82 + ed37fdb commit 1efcfce

File tree

18 files changed

+506
-291
lines changed

18 files changed

+506
-291
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
CXX: clang++
3131

3232
- name: Upload Artifact
33-
uses: actions/upload-artifact@v3
33+
uses: actions/upload-artifact@v4
3434
with:
3535
name: wheel-artifacts
3636
path: dist/*.whl
@@ -43,7 +43,7 @@ jobs:
4343
steps:
4444
- uses: actions/checkout@v4
4545
- name: Download packages
46-
uses: actions/download-artifact@v3
46+
uses: actions/download-artifact@v4
4747
with:
4848
name: wheel-artifacts
4949
path: dist/
@@ -95,7 +95,7 @@ jobs:
9595
- name: Install NPM dependencies
9696
run: npm install
9797
- name: Download
98-
uses: actions/download-artifact@v3
98+
uses: actions/download-artifact@v4
9999
with:
100100
name: wheel-artifacts
101101
path: dist/
@@ -151,7 +151,7 @@ jobs:
151151
run: |
152152
cmake --build --preset default -t package
153153
- name: Upload Artifact
154-
uses: actions/upload-artifact@v3
154+
uses: actions/upload-artifact@v4
155155
with:
156156
name: benchmarking-artifacts
157157
path: build/default/assets/benchmarking-*
@@ -163,7 +163,7 @@ jobs:
163163
steps:
164164
- uses: actions/checkout@v4
165165
- name: Download
166-
uses: actions/download-artifact@v3
166+
uses: actions/download-artifact@v4
167167
with:
168168
# Artifact name
169169
name: benchmarking-artifacts
@@ -206,12 +206,12 @@ jobs:
206206
steps:
207207
- uses: actions/checkout@v4
208208
- name: Download Deb Packages
209-
uses: actions/download-artifact@v3
209+
uses: actions/download-artifact@v4
210210
with:
211211
name: benchmarking-artifacts
212212
path: artifacts/
213213
- name: Download Wheel Packages
214-
uses: actions/download-artifact@v3
214+
uses: actions/download-artifact@v4
215215
with:
216216
name: wheel-artifacts
217217
path: dist/

docs/modules/tutorial/pages/configurationfiles/plots.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Considering the same example axis as above, the software can generate the follow
202202

203203
[%dynamic%open%hide_code,python]
204204
----
205-
from feelpp.benchmarking.report.figureFactory import FigureFactory
205+
from feelpp.benchmarking.report.figures.figureFactory import FigureFactory
206206
figures = FigureFactory.create(Plot(**{
207207
"title": "Absolute performance",
208208
"plot_types": [ "scatter" ],

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ traitlets
1515
tabulate
1616
typing-extensions>=4.12.2
1717
python-dotenv
18-
tikzplotly
1918
.

src/feelpp/benchmarking/report/base/controller.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from feelpp.benchmarking.report.dataGenerationFactory import DataGeneratorFactory
1+
2+
23
class Controller:
34
""" Controller component , it orchestrates the model with the view"""
45
def __init__(self, model, view):
@@ -10,6 +11,41 @@ def __init__(self, model, view):
1011
self.model = model
1112
self.view = view
1213

14+
def generatePlotly(self):
15+
""" Creates plotly figures for each plot specified on the view config file
16+
Returns a list of plotly figures.
17+
"""
18+
return [ figure.createFigure(self.model.master_df) for figure in self.view.figures ]
19+
20+
def generatePlotlyHtml(self):
21+
""" Creates plotly figures in html for each plot specified on the view config file
22+
Returns a list of plotly HTML figures
23+
"""
24+
return [ figure.createFigureHtml(self.model.master_df) for figure in self.view.figures ]
25+
26+
def generateTikz(self):
27+
""" Creates Tikz/Pgf figures for each plot specified on the view config file
28+
Returns:
29+
list[str] LaTeX pgf plots.
30+
"""
31+
return [ figure.createTex(self.model.master_df) for figure in self.view.figures ]
32+
33+
def generateCsv(self):
34+
""" Create a list containing the data for each plot specified on the view config in CSV format.
35+
Returns (list[str]): List of csv data.
36+
"""
37+
return [ figure.createCsv(self.model.master_df) for figure in self.view.figures ]
38+
39+
1340
def generateData(self,format):
1441
""" Creates a list of data depending on the desired format, using the plot configuration and the model's master dataframe"""
15-
return DataGeneratorFactory.create(format).generate(self.view.plots_config,self.model.master_df)
42+
if format == "plotly":
43+
return self.generatePlotly()
44+
elif format == "html":
45+
return self.generatePlotlyHtml()
46+
elif format in ["tikz", "pgf"]:
47+
return self.generateTikz()
48+
elif format == "csv":
49+
return self.generateCsv()
50+
else:
51+
raise NotImplementedError

src/feelpp/benchmarking/report/base/view.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from feelpp.benchmarking.reframe.config.configSchemas import Plot
2+
from feelpp.benchmarking.report.figures.figureFactory import FigureFactory
23

34
class View:
45
""" Abstract view component"""
@@ -8,3 +9,7 @@ def __init__(self,plots_config):
89
plots_config list[dict]. List with dictionaries specifying plots configuration.
910
"""
1011
self.plots_config = [Plot(**d) for d in plots_config]
12+
13+
self.figures = []
14+
for plot_config in self.plots_config:
15+
self.figures.extend(FigureFactory.create(plot_config))

src/feelpp/benchmarking/report/dataGenerationFactory.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/feelpp/benchmarking/report/figures/__init__.py

Whitespace-only changes.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from pandas import MultiIndex
2+
3+
class Figure:
4+
def __init__(self,plot_config,transformation_strategy):
5+
self.config = plot_config
6+
self.transformation_strategy = transformation_strategy
7+
8+
def getIdealRange(self,df):
9+
""" Computes the [(min - eps), (max+eps)] interval for optimal y-axis display
10+
Args:
11+
- df (pd.DataFrame): The dataframe for which the interval should be computed
12+
Returns list[float, float]: The [(min - eps), (max+eps)] interval
13+
"""
14+
range_epsilon= 0.01
15+
return [ df.min().min() - df.min().min()*range_epsilon, df.max().max() + df.min().min()*range_epsilon ]
16+
17+
def createMultiindexFigure(self,df):
18+
raise NotImplementedError("Pure virtual function. Not to be called from the base class")
19+
20+
def createSimpleFigure(self,df):
21+
raise NotImplementedError("Pure virtual function. Not to be called from the base class")
22+
23+
def createCsv(self,df):
24+
return self.transformation_strategy.calculate(df).to_csv()
25+
26+
def createFigure(self,df, **args):
27+
""" Creates a figure from the master dataframe
28+
Args:
29+
df (pd.DataFrame). The master dataframe containing all reframe test data
30+
Returns:
31+
go.Figure: Plotly figure corresponding to the grouped Bar type
32+
"""
33+
df = self.transformation_strategy.calculate(df)
34+
35+
if isinstance(df.index,MultiIndex):
36+
figure = self.createMultiindexFigure(df, **args)
37+
else:
38+
figure = self.createSimpleFigure(df, **args)
39+
40+
return figure
41+
42+
43+
class CompositeFigure:
44+
def createFigure(self, df):
45+
return self.plotly_figure.createFigure(df)
46+
47+
def createTex(self, df):
48+
return self.tikz_figure.createFigure(df)
49+
50+
def createCsv(self,df):
51+
return self.plotly_figure.createCsv(df)
52+
53+
def createFigureHtml(self,df):
54+
return self.plotly_figure.createHtml(df)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from feelpp.benchmarking.report.transformationFactory import TransformationStrategyFactory
2+
3+
from feelpp.benchmarking.report.figures.base import CompositeFigure
4+
from feelpp.benchmarking.report.figures.tikzFigures import TikzScatterFigure, TikzGroupedBarFigure, TikzStackedBarFigure, TikzTableFigure
5+
from feelpp.benchmarking.report.figures.plotlyFigures import PlotlyScatterFigure, PlotlyGroupedBarFigure, PlotlyStackedBarFigure, PlotlyTableFigure
6+
7+
8+
9+
class ScatterFigure(CompositeFigure):
10+
""" Composite figure class for scatter figures"""
11+
def __init__(self, plot_config, transformation_strategy, fill_lines=[]):
12+
self.plotly_figure = PlotlyScatterFigure(plot_config,transformation_strategy,fill_lines)
13+
self.tikz_figure = TikzScatterFigure(plot_config,transformation_strategy,fill_lines)
14+
15+
class TableFigure(CompositeFigure):
16+
""" Composite figure class for table figures"""
17+
def __init__(self, plot_config, transformation_strategy):
18+
self.plotly_figure = PlotlyTableFigure(plot_config,transformation_strategy)
19+
self.tikz_figure = TikzTableFigure(plot_config,transformation_strategy)
20+
21+
class StackedBarFigure(CompositeFigure):
22+
""" Composite figure class for stacked bar figures"""
23+
def __init__(self, plot_config, transformation_strategy):
24+
self.plotly_figure = PlotlyStackedBarFigure(plot_config,transformation_strategy)
25+
self.tikz_figure = TikzStackedBarFigure(plot_config,transformation_strategy)
26+
27+
class GroupedBarFigure(CompositeFigure):
28+
""" Composite figure class for grouped bar figures"""
29+
def __init__(self, plot_config, transformation_strategy):
30+
self.plotly_figure = PlotlyGroupedBarFigure(plot_config,transformation_strategy)
31+
self.tikz_figure = TikzGroupedBarFigure(plot_config,transformation_strategy)
32+
33+
34+
class FigureFactory:
35+
""" Factory class to dispatch concrete figure elements"""
36+
@staticmethod
37+
def create(plot_config):
38+
""" Creates a concrete composite figure element
39+
Args:
40+
plot_config (Plot). Pydantic object with the plot configuration information
41+
"""
42+
strategy = TransformationStrategyFactory.create(plot_config)
43+
figures = []
44+
for plot_type in plot_config.plot_types:
45+
if plot_type == "scatter":
46+
fill_lines = []
47+
if plot_config.transformation=="speedup":
48+
fill_lines = ["optimal","half-optimal"]
49+
figures.append(ScatterFigure(plot_config,strategy, fill_lines))
50+
elif plot_type == "table":
51+
figures.append(TableFigure(plot_config,strategy))
52+
elif plot_type == "stacked_bar":
53+
figures.append(StackedBarFigure(plot_config,strategy))
54+
elif plot_type == "grouped_bar":
55+
figures.append(GroupedBarFigure(plot_config,strategy))
56+
else:
57+
raise NotImplementedError
58+
59+
return figures

0 commit comments

Comments
 (0)