Visualization ModuleΒΆ
This houses the core functionality for the visualization application. The visualization uses a Dash application with a Flask backend that updates live as the model runs. The application runs in the background while the model iterates toward convergence. This allows interactivity with plots in a browser setting. The suggested usage for the application is to use a function defined in the utility module to deploy the dash application in your script.
from PyMacroFin.model import macro_model
import PyMacroFin.utilities as util
def define_model():
m = macro_model(name='your-model-name')
... define your model options, equations, parameters, etc.
return m
if __name__=='__main__':
m = define_model()
util.deploy_dash(m)
m.run()
Note that it is essential to define the model prior to deploying the dash application. Also note that
unexpected and undesirable behavior will result from calling util.deploy_dash
outside of the
protection of if __name__=='__main__'
due to the creation of threads. Another important note
is that it is possible to run applications for different models simultaneously. However, you must
use different m.options.dash_port
values for the different models or else the models will
interrupt one another on the same port.