Skip to content

Commit

Permalink
Adding run simulation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
JBris committed Sep 9, 2024
1 parent 8da8d1b commit f853a14
Show file tree
Hide file tree
Showing 25 changed files with 716 additions and 216 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ DB_PASSWORD=password

# MLFlow
MLFLOW_BACKEND_STORE_URI=postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
MLFLOW_TRACKING_URI=http://mlflow:5000

# Prefect
PREFECT_API_DATABASE_CONNECTION_URL=postgresql+asyncpg://${DB_USER}:${DB_PASSWORD}@postgres:5432/prefect
Expand Down
9 changes: 9 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Imports
######################################

import os

import dash_bootstrap_components as dbc
import pandas as pd
import plotly.express as px
Expand All @@ -12,6 +14,13 @@
from hydra import compose, initialize
from hydra.utils import instantiate

######################################
# Environment
######################################

if os.environ.get("PREFECT_API_URL") is None:
os.environ["PREFECT_API_URL"] = "http://127.0.0.1:4200/api"

######################################
# Functions
######################################
Expand Down
5 changes: 0 additions & 5 deletions app/conf/form/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ components:
children: Run model
color: primary
className: me-1
- id: download-sim-data-input
label: Download
help: Download the simulation output data
class_name: dash_daq.BooleanSwitch.BooleanSwitch
kwargs: {}
- id: save-param-button
label: Save
help: Save current parameter configuration to file
Expand Down
38 changes: 0 additions & 38 deletions app/flows/bye_flow.py

This file was deleted.

53 changes: 0 additions & 53 deletions app/flows/hello_flow.py

This file was deleted.

34 changes: 28 additions & 6 deletions app/flows/prefect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,37 @@ pull:

# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: Hello Flow
description: Hello description.
entrypoint: /app/flows/hello_flow.py:hello_flow
- name: run_simulation_flow
description: Run a single simulation for the root model.
entrypoint: /app/flows/run_simulation.py:run_simulation_flow
parameters: {}
work_pool:
name: default
- name: Bye Flow
description: Bye description.
entrypoint: /app/flows/bye_flow.py:bye_flow

- name: run_optimisation_flow
description: Run an optimisation procedure for the root model.
entrypoint: /app/flows/run_optimisation.py:run_optimisation_flow
parameters: {}
work_pool:
name: default

- name: run_sensitivity_analysis_flow
description: Run a sensitivity analysis for the root model.
entrypoint: /app/flows/run_sensitivity_analysis.py:run_sensitivity_analysis_flow
parameters: {}
work_pool:
name: default

- name: run_abc_flow
description: Perform Bayesian parameter estimation for the root model using Approximate Bayesian Computation.
entrypoint: /app/flows/run_abc.py:run_abc_flow
parameters: {}
work_pool:
name: default

- name: run_snpe_flow
description: Perform Bayesian parameter estimation for the root model using Sequential Neural Posterior Estimation.
entrypoint: /app/flows/run_snpe.py:run_snpe_flow
parameters: {}
work_pool:
name: default
40 changes: 0 additions & 40 deletions app/flows/prefect_remote_dispatch.py

This file was deleted.

38 changes: 38 additions & 0 deletions app/flows/run_abc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

######################################
# Imports
######################################

import mlflow
from prefect import context, flow, task
from prefect.task_runners import ConcurrentTaskRunner

from deeprootgen.data_model import RootSimulationModel
from deeprootgen.model import RootSystemSimulation
from deeprootgen.pipeline import (
begin_experiment,
log_config,
log_experiment_details,
log_simulation,
)

######################################
# Main
######################################


@task
def run_abc() -> None:
print("hello")


@flow(
name="abc",
description="Perform Bayesian parameter estimation for the root model using Approximate Bayesian Computation.",
task_runner=ConcurrentTaskRunner(),
)
def run_abc_flow(
# input_params: RootSimulationModel
) -> None:
run_abc.submit()
38 changes: 38 additions & 0 deletions app/flows/run_optimisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

######################################
# Imports
######################################

import mlflow
from prefect import context, flow, task
from prefect.task_runners import ConcurrentTaskRunner

from deeprootgen.data_model import RootSimulationModel
from deeprootgen.model import RootSystemSimulation
from deeprootgen.pipeline import (
begin_experiment,
log_config,
log_experiment_details,
log_simulation,
)

######################################
# Main
######################################


@task
def run_optimisation() -> None:
print("hello")


@flow(
name="optimisation",
description="Run an optimisation procedure for the root model.",
task_runner=ConcurrentTaskRunner(),
)
def run_optimisation_flow(
# input_params: RootSimulationModel
) -> None:
run_optimisation.submit()
38 changes: 38 additions & 0 deletions app/flows/run_sensitivity_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

######################################
# Imports
######################################

import mlflow
from prefect import context, flow, task
from prefect.task_runners import ConcurrentTaskRunner

from deeprootgen.data_model import RootSimulationModel
from deeprootgen.model import RootSystemSimulation
from deeprootgen.pipeline import (
begin_experiment,
log_config,
log_experiment_details,
log_simulation,
)

######################################
# Main
######################################


@task
def run_sensitivity_analysis() -> None:
print("hello")


@flow(
name="sensitivity_analysis",
description="Run a sensitivity analysis for the root model.",
task_runner=ConcurrentTaskRunner(),
)
def run_sensitivity_analysis_flow(
# input_params: RootSimulationModel
) -> None:
run_sensitivity_analysis.submit()
Loading

0 comments on commit f853a14

Please sign in to comment.