Skip to content

Commit

Permalink
Adding more to the output table
Browse files Browse the repository at this point in the history
  • Loading branch information
JBris committed Sep 9, 2024
1 parent 811d2c6 commit e865b89
Show file tree
Hide file tree
Showing 6 changed files with 464 additions and 11 deletions.
17 changes: 8 additions & 9 deletions app/pages/generate_root_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
build_collapsible,
build_common_components,
build_common_layout,
get_out_table_df,
)
from deeprootgen.pipeline import get_simulation_uuid

Expand Down Expand Up @@ -166,13 +167,9 @@ def save_runs(n_clicks: int, simulation_runs: list) -> None:
def load_runs(list_of_contents: list, list_of_names: list) -> tuple:
_, content_string = list_of_contents[0].split(",")
decoded = base64.b64decode(content_string).decode("utf-8")
split_lines = decoded.split("\n")
split_lines.pop(0)
from io import StringIO

workflow_urls = []
for workflow_url in split_lines:
if workflow_url != "":
workflow_urls.append({"workflow_url": workflow_url})
workflow_urls = pd.read_csv(StringIO(decoded)).to_dict("records")

toast_message = f"Loading run history from: {list_of_names[0]}"
return [workflow_urls], True, toast_message
Expand Down Expand Up @@ -279,7 +276,6 @@ def run_root_model(
timeout=0,
)

simulation_uuid
flow_run_id = str(flow_data.id)
flow_name = flow_data.name
simulation_tag = form_inputs["simulation_tag"]
Expand All @@ -295,7 +291,10 @@ def run_root_model(

simulation_runs.append(
{
"workflow_url": f"<a href='{prefect_flow_url}' target='_blank'>{prefect_flow_url}</a>"
"workflow": f"<a href='{prefect_flow_url}' target='_blank'>{flow_name}</a>",
"tag": simulation_tag,
"date": datetime.today().strftime("%Y-%m-%d-%H-%M"),
"seed": form_inputs["random_seed"],
}
)

Expand Down Expand Up @@ -343,7 +342,7 @@ def layout() -> html.Div:
)

input_components = dbc.Col([parameter_components, data_io_components])
simulation_run_df = pd.DataFrame([], columns=["workflow_url"])
simulation_run_df = get_out_table_df()

simulation_results_data = {"simulation-runs-table": simulation_run_df}

Expand Down
7 changes: 6 additions & 1 deletion deeprootgen/form/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .components import build_collapsible, build_common_components, build_common_layout
from .components import (
build_collapsible,
build_common_components,
build_common_layout,
get_out_table_df,
)
12 changes: 12 additions & 0 deletions deeprootgen/form/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pydoc import locate

import dash_bootstrap_components as dbc
import pandas as pd
from dash import dcc, html


Expand Down Expand Up @@ -287,3 +288,14 @@ def build_common_layout(
),
)
return layout


def get_out_table_df() -> pd.DataFrame:
"""Get the default output table as a dataframe.
Returns:
pd.DataFrame:
The output table as a dataframe.
"""
out_df = pd.DataFrame([], columns=["workflow", "tag", "date", "seed"])
return out_df
6 changes: 6 additions & 0 deletions deeprootgen/pipeline/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import mlflow
import yaml
from ydata_profiling import ProfileReport

from ..data_model import RootSimulationModel
from ..model import RootSystemSimulation
Expand Down Expand Up @@ -149,3 +150,8 @@ def log_simulation(
outfile = osp.join(OUT_DIR, f"{time_now}-{task}_hgraph.html")
fig.write_html(outfile)
mlflow.log_artifact(outfile)

profile = ProfileReport(node_df, title="Root Model Report")
outfile = osp.join(OUT_DIR, f"{time_now}-{task}_data_profile.html")
profile.to_file(outfile)
mlflow.log_artifact(outfile)
Loading

0 comments on commit e865b89

Please sign in to comment.