Command Profile in TVB

This is a simple demo showing for to interract with TVB in the command profile.

More examples can be found here: https://github.com/the-virtual-brain/tvb-framework/tree/master/tvb/interfaces/command/demos

In [1]:
from tvb.basic.profile import TvbProfile
TvbProfile.set_profile(TvbProfile.COMMAND_PROFILE)
from tvb.interfaces.command.lab import *
2019-11-15 08:55:16,579 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.datatypes.time_series.TimeSeries.labels_dimensions = Attr(field_type=<class 'dict'>, default={}, required=True)
2019-11-15 08:55:16,672 - INFO - numexpr.utils - NumExpr defaulting to 3 threads.
2019-11-15 08:55:16,692 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.datatypes.projections.ProjectionMatrix.conductances = Attr(field_type=<class 'dict'>, default={'air': 0.0, 'skin': 1.0, 'skull': 0.01, 'brain': 1.0}, required=False)
2019-11-15 08:55:28,409 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.epileptor.Epileptor.state_variable_range = Final(field_type=<class 'dict'>, default={'x1': array([-2.,  1.]), 'y1': array([-20.,   2.]), 'z': array([2., 5.]), 'x2': array([-2.,  0.]), 'y2': array([0., 2.]), 'g': array([-1.,  1.])}, required=True)
2019-11-15 08:55:28,463 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.epileptor.Epileptor2D.tt = NArray(label='tt', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:28,464 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.epileptor.Epileptor2D.state_variable_range = Final(field_type=<class 'dict'>, default={'x1': array([-2.,  1.]), 'z': array([2., 5.])}, required=True)
2019-11-15 08:55:28,903 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.epileptor_rs.EpileptorRestingState.gamma_rs = NArray(label=":math:'\\gamma_rs'", dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:28,909 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.epileptor_rs.EpileptorRestingState.state_variable_range = Final(field_type=<class 'dict'>, default={'x1': array([-1.8, -1.4]), 'y1': array([-15, -10]), 'z': array([3.6, 4. ]), 'x2': array([-1.1, -0.9]), 'y2': array([0.001, 0.01 ]), 'g': array([-1.,  1.]), 'x_rs': array([-2.,  4.]), 'y_rs': array([-6.,  6.])}, required=True)
2019-11-15 08:55:29,782 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.epileptorcodim3.EpileptorCodim3.state_variable_range = Final(field_type=<class 'dict'>, default={'x': array([0.4, 0.6]), 'y': array([-0.1,  0.1]), 'z': array([0.  , 0.15])}, required=True)
2019-11-15 08:55:30,986 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.epileptorcodim3.EpileptorCodim3SlowMod.state_variable_range = Final(field_type=<class 'dict'>, default={'x': array([0.4, 0.6]), 'y': array([-0.1,  0.1]), 'z': array([0. , 0.1]), 'uA': array([0., 0.]), 'uB': array([0., 0.])}, required=True)
2019-11-15 08:55:32,600 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.hopfield.Hopfield.state_variable_range = Final(field_type=<class 'dict'>, default={'x': array([-1.,  2.]), 'theta': array([0., 1.])}, required=True)
2019-11-15 08:55:33,015 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.12 
   attribute  tvb.simulator.models.jansen_rit.JansenRit.p_min = NArray(label=':math:`p_{min}`', dtype=float64, default=array([0.12]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,016 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.32 
   attribute  tvb.simulator.models.jansen_rit.JansenRit.p_max = NArray(label=':math:`p_{max}`', dtype=float64, default=array([0.32]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,017 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.22 
   attribute  tvb.simulator.models.jansen_rit.JansenRit.mu = NArray(label=':math:`\\mu_{max}`', dtype=float64, default=array([0.22]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,018 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.jansen_rit.JansenRit.state_variable_range = Final(field_type=<class 'dict'>, default={'y0': array([-1.,  1.]), 'y1': array([-500.,  500.]), 'y2': array([-50.,  50.]), 'y3': array([-6.,  6.]), 'y4': array([-20.,  20.]), 'y5': array([-500.,  500.])}, required=True)
2019-11-15 08:55:33,912 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.jansen_rit.ZetterbergJansen.state_variable_range = Final(field_type=<class 'dict'>, default={'v1': array([-100.,  100.]), 'y1': array([-500.,  500.]), 'v2': array([-100.,   50.]), 'y2': array([-100.,    6.]), 'v3': array([-100.,    6.]), 'y3': array([-100.,    6.]), 'v4': array([-100.,   20.]), 'y4': array([-100.,   20.]), 'v5': array([-100.,   20.]), 'y5': array([-500.,  500.]), 'v6': array([-100.,   20.]), 'v7': array([-100.,   20.])}, required=True)
2019-11-15 08:55:33,950 - WARNING - tvb.traits - default contains values out of the declared domain. Ex -0.01 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.TCa = NArray(label=':math:`T_{Ca}`', dtype=float64, default=array([-0.01]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,953 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.3 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.TNa = NArray(label=':math:`T_{Na}`', dtype=float64, default=array([0.3]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,957 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 2.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.aei = NArray(label=':math:`a_{ei}`', dtype=float64, default=array([2.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,961 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 2.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.aie = NArray(label=':math:`a_{ie}`', dtype=float64, default=array([2.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,967 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.ane = NArray(label=':math:`a_{ne}`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,971 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.3 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.Iext = NArray(label=':math:`I_{ext}`', dtype=float64, default=array([0.3]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,974 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.QV_max = NArray(label=':math:`Q_{max}`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,977 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.QZ_max = NArray(label=':math:`Q_{max}`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,979 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.larter_breakspear.LarterBreakspear.t_scale = NArray(label=':math:`t_{scale}`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:33,983 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.larter_breakspear.LarterBreakspear.state_variable_range = Final(field_type=<class 'dict'>, default={'V': array([-1.5,  1.5]), 'W': array([-1.5,  1.5]), 'Z': array([-1.5,  1.5])}, required=True)
2019-11-15 08:55:34,001 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.linear.Linear.state_variable_range = Final(field_type=<class 'dict'>, default={'x': array([-1,  1])}, required=True)
2019-11-15 08:55:34,012 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.oscillator.Generic2dOscillator.gamma = NArray(label=':math:`\\gamma`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,015 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.oscillator.Generic2dOscillator.state_variable_range = Final(field_type=<class 'dict'>, default={'V': array([-2.,  4.]), 'W': array([-6.,  6.])}, required=True)
2019-11-15 08:55:34,282 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.oscillator.Kuramoto.state_variable_range = Final(field_type=<class 'dict'>, default={'theta': array([0.        , 6.28318531])}, required=True)
2019-11-15 08:55:34,285 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.oscillator.SupHopf.state_variable_range = Final(field_type=<class 'dict'>, default={'x': array([-5.,  5.]), 'y': array([-5.,  5.])}, required=True)
2019-11-15 08:55:34,543 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.stefanescu_jirsa.ReducedSetFitzHughNagumo.state_variable_range = Final(field_type=<class 'dict'>, default={'xi': array([-4.,  4.]), 'eta': array([-3.,  3.]), 'alpha': array([-4.,  4.]), 'beta': array([-3.,  3.])}, required=True)
2019-11-15 08:55:34,551 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.stefanescu_jirsa.ReducedSetHindmarshRose.a = NArray(label=':math:`a`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,555 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 3.0 
   attribute  tvb.simulator.models.stefanescu_jirsa.ReducedSetHindmarshRose.b = NArray(label=':math:`b`', dtype=float64, default=array([3.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,558 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.models.stefanescu_jirsa.ReducedSetHindmarshRose.c = NArray(label=':math:`c`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,562 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 3.3 
   attribute  tvb.simulator.models.stefanescu_jirsa.ReducedSetHindmarshRose.mu = NArray(label=':math:`\\mu`', dtype=float64, default=array([3.3]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,570 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.stefanescu_jirsa.ReducedSetHindmarshRose.state_variable_range = Final(field_type=<class 'dict'>, default={'xi': array([-4.,  4.]), 'eta': array([-25.,  20.]), 'tau': array([ 2., 10.]), 'alpha': array([-4.,  4.]), 'beta': array([-20.,  20.]), 'gamma': array([ 2., 10.])}, required=True)
2019-11-15 08:55:34,611 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.wilson_cowan.WilsonCowan.state_variable_range = Final(field_type=<class 'dict'>, default={'E': array([0., 1.]), 'I': array([0., 1.])}, required=True)
2019-11-15 08:55:34,937 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 0.27 
   attribute  tvb.simulator.models.wong_wang.ReducedWongWang.a = NArray(label=':math:`a`', dtype=float64, default=array([0.27]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:34,939 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.wong_wang.ReducedWongWang.state_variable_range = Final(field_type=<class 'dict'>, default={'S': array([0., 1.])}, required=True)
2019-11-15 08:55:34,941 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.wong_wang.ReducedWongWang.state_variable_boundaries = Final(field_type=<class 'dict'>, default={'S': array([0., 1.])}, required=True)
2019-11-15 08:55:35,483 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 10.0 
   attribute  tvb.simulator.models.wong_wang_exc_inh.ReducedWongWangExcInh.tau_i = NArray(label=':math:`\\tau_i`', dtype=float64, default=array([10.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:35,484 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.wong_wang_exc_inh.ReducedWongWangExcInh.state_variable_range = Final(field_type=<class 'dict'>, default={'S_e': array([0., 1.]), 'S_i': array([0., 1.])}, required=True)
2019-11-15 08:55:35,486 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.wong_wang_exc_inh.ReducedWongWangExcInh.state_variable_boundaries = Final(field_type=<class 'dict'>, default={'S_e': array([0., 1.]), 'S_i': array([0., 1.])}, required=True)
2019-11-15 08:55:35,499 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.zerlaut.ZerlautFirstOrder.state_variable_range = Final(field_type=<class 'dict'>, default={'E': array([0. , 0.1]), 'I': array([0. , 0.1]), 'W': array([  0., 100.])}, required=True)
2019-11-15 08:55:35,506 - WARNING - tvb.traits - Field seems mutable and has a default value. Consider using a lambda as a value factory 
   attribute tvb.simulator.models.zerlaut.ZerlautSecondOrder.state_variable_range = Final(field_type=<class 'dict'>, default={'E': array([0. , 0.1]), 'I': array([0. , 0.1]), 'C_ee': array([0., 0.]), 'C_ei': array([0., 0.]), 'C_ii': array([0., 0.]), 'W': array([  0., 100.])}, required=True)
2019-11-15 08:55:35,571 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.coupling.HyperbolicTangent.b = NArray(label=':math:`b`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
2019-11-15 08:55:35,578 - WARNING - tvb.traits - default contains values out of the declared domain. Ex 1.0 
   attribute  tvb.simulator.coupling.Kuramoto.a = NArray(label=':math:`a`', dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
In [2]:
list_projects()
                    name    id
2019-11-15 08:58:13,431 - ERROR - tvb.core.entities.storage.session_maker - Could not commit session...
Traceback (most recent call last):
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: PROJECTS

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/tvb-root/framework_tvb/tvb/core/entities/storage/session_maker.py", line 372, in dec
    result = func(*args, **kwargs)
  File "/root/tvb-root/framework_tvb/tvb/core/entities/storage/project_dao.py", line 236, in get_all_projects
    result = query.offset(max(page_start, 0)).limit(max(page_size, 0)).all()
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2703, in all
    return list(self)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
    return self._execute_and_instances(context)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2878, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: PROJECTS [SQL: 'SELECT "PROJECTS".id AS "PROJECTS_id", "PROJECTS".name AS "PROJECTS_name", "PROJECTS".description AS "PROJECTS_description", "PROJECTS".last_updated AS "PROJECTS_last_updated", "PROJECTS".fk_admin AS "PROJECTS_fk_admin", "PROJECTS".gid AS "PROJECTS_gid", "PROJECTS".version AS "PROJECTS_version" \nFROM "PROJECTS"\n LIMIT ? OFFSET ?'] [parameters: (20, 0)]
---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1181                         parameters,
-> 1182                         context)
   1183         except BaseException as e:

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/default.py in do_execute(self, cursor, statement, parameters, context)
    469     def do_execute(self, cursor, statement, parameters, context=None):
--> 470         cursor.execute(statement, parameters)
    471 

OperationalError: no such table: PROJECTS

The above exception was the direct cause of the following exception:

OperationalError                          Traceback (most recent call last)
<ipython-input-2-4fc2d8c8ee8b> in <module>
----> 1 list_projects()

~/tvb-root/framework_tvb/tvb/interfaces/command/lab.py in list_projects()
     56     fmt = "%24s %5s"
     57     print(fmt % ('name', 'id'))
---> 58     for p in dao.get_all_projects():
     59         print(fmt % (p.name, p.id))
     60 

~/tvb-root/framework_tvb/tvb/core/entities/storage/session_maker.py in dec(*args, **kwargs)
    370 
    371         try:
--> 372             result = func(*args, **kwargs)
    373 
    374         except NoResultFound:

~/tvb-root/framework_tvb/tvb/core/entities/storage/project_dao.py in get_all_projects(self, page_start, page_size, is_count)
    234             result = query.count()
    235         else:
--> 236             result = query.offset(max(page_start, 0)).limit(max(page_size, 0)).all()
    237         return result
    238 

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py in all(self)
   2701 
   2702         """
-> 2703         return list(self)
   2704 
   2705     @_generative(_no_clauseelement_condition)

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py in __iter__(self)
   2853         if self._autoflush and not self._populate_existing:
   2854             self.session._autoflush()
-> 2855         return self._execute_and_instances(context)
   2856 
   2857     def __str__(self):

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/orm/query.py in _execute_and_instances(self, querycontext)
   2876             close_with_result=True)
   2877 
-> 2878         result = conn.execute(querycontext.statement, self._params)
   2879         return loading.instances(querycontext.query, result, querycontext)
   2880 

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in execute(self, object, *multiparams, **params)
    943             raise exc.ObjectNotExecutableError(object)
    944         else:
--> 945             return meth(self, multiparams, params)
    946 
    947     def _execute_function(self, func, multiparams, params):

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/sql/elements.py in _execute_on_connection(self, connection, multiparams, params)
    261     def _execute_on_connection(self, connection, multiparams, params):
    262         if self.supports_execution:
--> 263             return connection._execute_clauseelement(self, multiparams, params)
    264         else:
    265             raise exc.ObjectNotExecutableError(self)

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in _execute_clauseelement(self, elem, multiparams, params)
   1051             compiled_sql,
   1052             distilled_params,
-> 1053             compiled_sql, distilled_params
   1054         )
   1055         if self._has_events or self.engine._has_events:

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1187                 parameters,
   1188                 cursor,
-> 1189                 context)
   1190 
   1191         if self._has_events or self.engine._has_events:

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in _handle_dbapi_exception(self, e, statement, parameters, cursor, context)
   1400                 util.raise_from_cause(
   1401                     sqlalchemy_exception,
-> 1402                     exc_info
   1403                 )
   1404             else:

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/util/compat.py in raise_from_cause(exception, exc_info)
    201     exc_type, exc_value, exc_tb = exc_info
    202     cause = exc_value if exc_value is not exception else None
--> 203     reraise(type(exception), exception, tb=exc_tb, cause=cause)
    204 
    205 if py3k:

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
    184             value.__cause__ = cause
    185         if value.__traceback__ is not tb:
--> 186             raise value.with_traceback(tb)
    187         raise value
    188 

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)
   1180                         statement,
   1181                         parameters,
-> 1182                         context)
   1183         except BaseException as e:
   1184             self._handle_dbapi_exception(

/opt/conda/envs/tvb-run/lib/python3.7/site-packages/sqlalchemy/engine/default.py in do_execute(self, cursor, statement, parameters, context)
    468 
    469     def do_execute(self, cursor, statement, parameters, context=None):
--> 470         cursor.execute(statement, parameters)
    471 
    472     def do_execute_no_params(self, cursor, statement, context=None):

OperationalError: (sqlite3.OperationalError) no such table: PROJECTS [SQL: 'SELECT "PROJECTS".id AS "PROJECTS_id", "PROJECTS".name AS "PROJECTS_name", "PROJECTS".description AS "PROJECTS_description", "PROJECTS".last_updated AS "PROJECTS_last_updated", "PROJECTS".fk_admin AS "PROJECTS_fk_admin", "PROJECTS".gid AS "PROJECTS_gid", "PROJECTS".version AS "PROJECTS_version" \nFROM "PROJECTS"\n LIMIT ? OFFSET ?'] [parameters: (20, 0)]

Create a new project to test with

In [ ]:
proj = new_project("sandbox")

If you have the web UI open at the same time, you'll notice there's now a new project named "sandbox"

In [ ]:
list_datatypes(proj.id)

Nothing! Let's import a connectivity

In [ ]:
import os
import tvb_data
p = os.path.join(os.path.dirname(tvb_data.__file__), 'connectivity/connectivity_66.zip')
import_conn_zip(proj.id, p)
In [ ]:
list_datatypes(proj.id)

Now let's grab that connectivity from the database. IMPORTANT: Make sure to adjust the DT id below to match the value in the id column above

In [8]:
conn = load_dt(21)
conn
Out[8]:

Connectivity

value
Number of connections
1377
Number of regions
66
Undirected
False
is None
True
tract_lengths (connections) [min, median, max]
[7, 78.8134, 238]
tract_lengths [min, median, max]
[0, 0, 238]
tract_lengths-non-zero [min, median, max]
[7, 78.8134, 238]
weights [min, median, max]
[0, 0, 0.512165]
weights dtype
float64
weights shape
(66, 66)
weights-non-zero [min, median, max]
[3.5945e-05, 0.0138183, 0.512165]

and run a simulation with it

In [10]:
sim_op = fire_simulation(proj.id, Simulator(connectivity=conn, simulation_length=100))
wait_to_finish(sim_op)
2019-10-19 17:00:06,524 - INFO - tvb.interfaces.command.lab - Operation launched ....
2019-10-19 17:00:39,282 - INFO - tvb.core.services.backend_client - Finished with launch of operation 12
2019-10-19 17:00:41,822 - INFO - tvb.interfaces.command.lab - Operation finished successfully

We should wait for the simulation to finish, and afterwards, TimeSeries should also be part of this project.

Refresh the Web GUI to see the status of your operation.

In [11]:
list_datatypes(proj.id)
                    type              tag    id                              gid         date
       ConnectivityIndex                     21 c986cf8dcb6a4825aa71d1b02ad1b1f0 2019-10-19 16:59:11.373059
          SimulatorIndex             None    22 9e8f501052fc48d7a7d8c1264774c91b 2019-10-19 17:00:06.018880
  SimulationHistoryIndex                     23 7a8d4115ab534373ba95984c076cb1bd 2019-10-19 17:00:38.703627
   TimeSeriesRegionIndex                     24 f4d189fc1dbf4fcab39442090f1e9f6d 2019-10-19 17:00:38.872877
In [12]:
%pylab inline
import matplotlib.pyplot as plt

ts  = load_dt(24)
for reg in range(66):
    plt.plot(ts.data[:, 0, reg, 0])
plt.show()
Populating the interactive namespace from numpy and matplotlib

You can re-evaluate this cell multiple times while it's running to see how the results gradually show up as the simulation finishes.