Rimjhim Mittal commited on
Commit
fa849ec
·
1 Parent(s): 52f6e73

minor additions

Browse files
Files changed (3) hide show
  1. app.py +14 -21
  2. examples/keras_to_MDF.json +0 -0
  3. page_icon.png +0 -0
app.py CHANGED
@@ -5,7 +5,7 @@ from modeci_mdf.execution_engine import EvaluableGraph, EvaluableOutput
5
  import json
6
  import numpy as np
7
  import requests
8
- st.set_page_config(layout="wide", page_icon="logo.png", page_title="Model Description Format", menu_items={
9
  'Report a bug': "https://github.com/ModECI/MDF/",
10
  'About': "ModECI (Model Exchange and Convergence Initiative) is a multi-investigator collaboration that aims to develop a standardized format for exchanging computational models across diverse software platforms and domains of scientific research and technology development, with a particular focus on neuroscience, Machine Learning and Artificial Intelligence. Refer to https://modeci.org/ for more."
11
  })
@@ -104,7 +104,6 @@ def show_simulation_results(all_node_results, stateful_nodes):
104
  else:
105
  st.write(all_node_results[node_id])
106
 
107
-
108
  def update_selected_columns(node_id, column):
109
  st.session_state.selected_columns[node_id][column] = st.session_state[f"checkbox_{node_id}_{column}"]
110
 
@@ -114,7 +113,7 @@ def show_mdf_graph(mdf_model):
114
  image_path = mdf_model.id + ".png"
115
  st.image(image_path, caption="Model Graph Visualization")
116
 
117
- def show_json_output(mdf_model):
118
  st.subheader("JSON Model")
119
  st.json(mdf_model.to_json())
120
 
@@ -122,27 +121,17 @@ def show_json_output(mdf_model):
122
  def view_tabs(mdf_model, param_inputs, stateful): # view
123
  tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Model"])
124
  with tab1:
125
- if stateful:
126
- if 'simulation_results' not in st.session_state:
127
- st.session_state.simulation_results = None
128
-
129
- if st.session_state.simulation_results is not None:
130
- show_simulation_results(st.session_state.simulation_results, stateful)
131
- else:
132
- st.write("Run the simulation to see results.") # model
133
  else:
134
- if 'simulation_results' not in st.session_state:
135
- st.session_state.simulation_results = None
136
-
137
- if st.session_state.simulation_results is not None:
138
- show_simulation_results(st.session_state.simulation_results, stateful)
139
- else:
140
- st.write("Stateless.")
141
 
142
  with tab2:
143
  show_mdf_graph(mdf_model) # view
144
  with tab3:
145
- show_json_output(mdf_model) # view
146
 
147
  def display_and_edit_array(array, key):
148
  if isinstance(array, list):
@@ -256,6 +245,9 @@ def parameter_form_to_update_model_and_view(mdf_model):
256
  if param.id in param_inputs:
257
  param.value = param_inputs[param.id]
258
  st.session_state.simulation_results = run_simulation(param_inputs, mdf_model, stateful)
 
 
 
259
 
260
  view_tabs(mdf_model, param_inputs, stateful_nodes)
261
 
@@ -268,10 +260,10 @@ def upload_file_and_load_to_model():
268
  "ABCD": "./examples/ABCD.json",
269
  "FN": "./examples/FN.mdf.json",
270
  "States": "./examples/States.json",
271
- "Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
272
  "Simple":"./examples/Simple.json",
273
  # "Arrays":"./examples/Arrays.json",
274
- # "RNN":"./examples/RNNs.json",
275
  "IAF":"./examples/IAFs.json",
276
  "Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
277
  }
@@ -326,6 +318,7 @@ def main():
326
  mdf_model = upload_file_and_load_to_model() # controller
327
 
328
  if mdf_model:
 
329
  header1, header2 = st.columns([1, 8], vertical_alignment="top")
330
  with header1:
331
  with st.container():
 
5
  import json
6
  import numpy as np
7
  import requests
8
+ st.set_page_config(layout="wide", page_icon="page_icon.png", page_title="Model Description Format", menu_items={
9
  'Report a bug': "https://github.com/ModECI/MDF/",
10
  'About': "ModECI (Model Exchange and Convergence Initiative) is a multi-investigator collaboration that aims to develop a standardized format for exchanging computational models across diverse software platforms and domains of scientific research and technology development, with a particular focus on neuroscience, Machine Learning and Artificial Intelligence. Refer to https://modeci.org/ for more."
11
  })
 
104
  else:
105
  st.write(all_node_results[node_id])
106
 
 
107
  def update_selected_columns(node_id, column):
108
  st.session_state.selected_columns[node_id][column] = st.session_state[f"checkbox_{node_id}_{column}"]
109
 
 
113
  image_path = mdf_model.id + ".png"
114
  st.image(image_path, caption="Model Graph Visualization")
115
 
116
+ def show_json_model(mdf_model):
117
  st.subheader("JSON Model")
118
  st.json(mdf_model.to_json())
119
 
 
121
  def view_tabs(mdf_model, param_inputs, stateful): # view
122
  tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Model"])
123
  with tab1:
124
+ if 'simulation_run' not in st.session_state or not st.session_state.simulation_run:
125
+ st.write("Run the simulation to see results.")
126
+ elif st.session_state.simulation_results is not None:
127
+ show_simulation_results(st.session_state.simulation_results, stateful)
 
 
 
 
128
  else:
129
+ st.write("No simulation results available.")
 
 
 
 
 
 
130
 
131
  with tab2:
132
  show_mdf_graph(mdf_model) # view
133
  with tab3:
134
+ show_json_model(mdf_model) # view
135
 
136
  def display_and_edit_array(array, key):
137
  if isinstance(array, list):
 
245
  if param.id in param_inputs:
246
  param.value = param_inputs[param.id]
247
  st.session_state.simulation_results = run_simulation(param_inputs, mdf_model, stateful)
248
+ st.session_state.simulation_run = True
249
+ else:
250
+ st.error("Please correct the invalid inputs before running the simulation.")
251
 
252
  view_tabs(mdf_model, param_inputs, stateful_nodes)
253
 
 
260
  "ABCD": "./examples/ABCD.json",
261
  "FN": "./examples/FN.mdf.json",
262
  "States": "./examples/States.json",
263
+ "Switched RLC Circuit": "./examples/switched_rlc_circuit.json",
264
  "Simple":"./examples/Simple.json",
265
  # "Arrays":"./examples/Arrays.json",
266
+ # "RNN":"./examples/RNNs.json", # some issue
267
  "IAF":"./examples/IAFs.json",
268
  "Izhikevich Test":"./examples/IzhikevichTest.mdf.json"
269
  }
 
318
  mdf_model = upload_file_and_load_to_model() # controller
319
 
320
  if mdf_model:
321
+ st.session_state.current_model = mdf_model
322
  header1, header2 = st.columns([1, 8], vertical_alignment="top")
323
  with header1:
324
  with st.container():
examples/keras_to_MDF.json ADDED
The diff for this file is too large to render. See raw diff
 
page_icon.png ADDED