Skip to content

Commit

Permalink
stop using python in antora
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierCladellas committed Jan 15, 2025
1 parent df85dd5 commit 4758b73
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 47 deletions.
13 changes: 10 additions & 3 deletions src/feelpp/benchmarking/report/atomicReports/atomicReport.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import json, os
from feelpp.benchmarking.report.atomicReports.model import AtomicReportModel
from feelpp.benchmarking.report.atomicReports.view import AtomicReportView
from feelpp.benchmarking.report.atomicReports.controller import AtomicReportController

class AtomicReport:
""" Class representing an atomic report. i.e. a report indexed by date, test case, application and machine.
Expand Down Expand Up @@ -158,20 +160,25 @@ def createReport(self, base_dir, renderer):
renderer (Renderer): The renderer to use
"""
hash_params_headers, flat_hash_params = self.parseHashMap()

model=AtomicReportModel( self.runs )
view=AtomicReportView( self.plots_config )
controller=AtomicReportController(model,view)

renderer.render(
f"{base_dir}/{self.filename()}.adoc",
dict(
parent_catalogs = f"{self.application_id}-{self.use_case_id}-{self.machine_id},{self.machine_id}-{self.application_id}-{self.use_case_id},{self.use_case_id}-{self.application_id}-{self.machine_id}",
application_display_name = self.application.display_name,
machine_id = self.machine.id, machine_display_name = self.machine.display_name,
session_info = self.session_info,
runs = self.runs,
date = self.date,
empty = self.empty,
plots_config = self.plots_config,
flat_hash_param_map = flat_hash_params,
hash_params_headers = hash_params_headers,
description_path = self.description_path
description_path = self.description_path,
figures = controller.generateFiguresHtml(),
# csv_data = controller.buildCsvs()
)
)

Expand Down
14 changes: 10 additions & 4 deletions src/feelpp/benchmarking/report/base/baseComponent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os,copy
from feelpp.benchmarking.report.base.model import AggregationModel

from feelpp.benchmarking.report.base.controller import Controller
from feelpp.benchmarking.report.base.view import View
class BaseComponent:
""" Base class for all components (machine, application, test case) """
def __init__(self, id, display_name, description):
Expand Down Expand Up @@ -130,13 +131,18 @@ def createOverview(self,base_dir,renderer,parents,plots_config,master_df):
plots_config (list[dict]). Plot configurations of the current overview to render
master_df (pd.DataFrame): master_df attribute of the model to render, it is a concatenation of the children's model dataframes
"""


model=AggregationModel.fromDataframe(master_df)
view=View( plots_config )
controller=Controller(model,view)

renderer.render(
os.path.join(base_dir,*[parent.id for parent in parents],"overview.adoc"),
data = dict(
parent_catalogs = "-".join([parent.id for parent in parents]),
plots_config = plots_config,
master_df = master_df,
parents = parents
parents = parents,
figures = controller.generateFiguresHtml()
)
)

Expand Down
25 changes: 22 additions & 3 deletions src/feelpp/benchmarking/report/base/controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from feelpp.benchmarking.report.figureFactory import FigureFactory
from feelpp.benchmarking.report.strategies import StrategyFactory

class Controller:
""" Controller component , it orchestrates the model with the view"""
Expand All @@ -11,10 +12,28 @@ def __init__(self, model, view):
self.model = model
self.view = view

def generateAll(self):
""" Creates plotly figures for each plot specified on the view config file
def generateFigures(self):
""" Creates plotly figures in HTML for each plot specified on the view config file
Returns a list of plotly figures.
"""
figures = []
for plot_config in self.view.plots_config:
for plot in FigureFactory.create(plot_config):
yield plot.createFigure(self.model.master_df)
figures.append( plot.createFigure(self.model.master_df) )
return figures

def generateFiguresHtml(self):
figures = self.generateFigures()
return [fig.to_html() for fig in figures]


def buildCsvs(self):
"""
"""
csvs = []
for plot_config in self.view.plots_config:
strategy = StrategyFactory.create(plot_config)
csv_data = strategy.calculate(self.model.master_df).to_csv()
csvs.append(csv_data)

return "<br>".join(csvs)
23 changes: 5 additions & 18 deletions src/feelpp/benchmarking/report/templates/atomicOverview.adoc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,13 @@
- {{parent.type.title()}} : {{parent.display_name}}
{% endfor %}

[%dynamic%close%hide_code,python]
----
from numpy import nan
from feelpp.benchmarking.report.base.controller import Controller
from feelpp.benchmarking.report.base.model import AggregationModel
from feelpp.benchmarking.report.base.view import View
----
{% for figure in figures %}
++++
{{figure}}
++++
{% endfor %}

[%dynamic%close%hide_code,python]
----
model=AggregationModel.fromDataframe({{ master_df }})
view=View({{ plots_config }})
controller=Controller(model,view)
----

[%dynamic%open%hide_code,python]
----
for fig in controller.generateAll():
fig.show()
----

++++
<style>
Expand Down
32 changes: 13 additions & 19 deletions src/feelpp/benchmarking/report/templates/benchmark.adoc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
:author: Your Name
:revdate: {{ session_info.time_end }}

++++
<button id="download-csv-{{parent_catalogs}}" > CSV </button>
<script>
</script>
++++


{% if description_path %}
== Case Description

Expand All @@ -33,25 +41,11 @@ include::ROOT:{{description_path}}[leveloffset=+1]
{% endfor %}
|===

[%dynamic%close%hide_code,python]
----
from feelpp.benchmarking.report.atomicReports.controller import AtomicReportController
from feelpp.benchmarking.report.atomicReports.model import AtomicReportModel
from feelpp.benchmarking.report.atomicReports.view import AtomicReportView
----

[%dynamic%close%hide_code,python]
----
model=AtomicReportModel({{ runs }})
view=AtomicReportView({{ plots_config }})
controller=AtomicReportController(model,view)
----

[%dynamic%open%hide_code,python]
----
for fig in controller.generateAll():
fig.show()
----
{% for figure in figures %}
++++
{{figure}}
++++
{% endfor %}

{% endif %}

Expand Down

0 comments on commit 4758b73

Please sign in to comment.