def monitoring(): from sqlalchemy import distinct, func from dallinger.experiment_server.experiment_server import Experiment, session from dallinger.models import Network exp = Experiment(session) panes = exp.monitoring_panels(**request.args.to_dict(flat=False)) network_structure = exp.network_structure(**request.args.to_dict( flat=False)) vis_options = exp.node_visualization_options() net_roles = (session.query(Network.role, func.count( Network.role)).group_by(Network.role).order_by(Network.role).all()) net_ids = [ i[0] for i in session.query(distinct(Network.id)).order_by( Network.id).all() ] return render_template( "dashboard_monitor.html", title="Experiment Monitoring", panes=panes, network_structure=json.dumps(network_structure, default=date_handler), net_roles=net_roles, net_ids=net_ids, vis_options=json.dumps(vis_options), )
def test_network_structure(self, a, db_session): from dallinger.experiment_server.experiment_server import Experiment from dallinger.models import Network exp = Experiment(db_session) network = Network.query.all()[0] network_structure = exp.network_structure() assert len(network_structure["networks"]) == 1 assert network_structure["networks"][0]["id"] == network.id assert network_structure["networks"][0]["role"] == network.role assert len(network_structure["nodes"]) == 0 assert len(network_structure["vectors"]) == 0 assert len(network_structure["infos"]) == 0 assert len(network_structure["participants"]) == 0 assert len(network_structure["trans"]) == 0 source = a.source(network=network) network_structure = exp.network_structure() assert len(network_structure["nodes"]) == 1 assert network_structure["nodes"][0]["type"] == source.type # Transformations are not included by default info1 = a.info(origin=source, contents="contents1") info2 = a.info(origin=source, contents="contents2") a.transformation(info_in=info1, info_out=info2) network_structure = exp.network_structure() assert len(network_structure["nodes"]) == 1 assert len(network_structure["infos"]) == 2 assert len(network_structure["trans"]) == 0 network_structure = exp.network_structure(transformations="on") assert len(network_structure["trans"]) == 1