Uploaded image for project: 'The Virtual Brain'
  1. The Virtual Brain
  2. TVB-1833

DetachedInstanceError for TimeSeries created by Monitors

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.4
    • None
    • None
    • MRS&after - r1.4

    Description

      I noticed this after testing recent work on monitor transforms in the UI. The simulation actually completes (and the resulting time series object is in the DB correctly, can be visualized), but the post-adapter code fails on the time series object in the persist_full_metadata method. Here's the relevant operations log

      2015-06-24 13:43:10,303 - DEBUG [proc:2768] - tvb.adapters.simulator.simulator_adapter - <tvb.adapters.simulator.simulator_adapter.SimulatorAdapter object at 0x10ba28750>: Simulation state persisted, returning results
      2015-06-24 13:43:10,307 - INFO [proc:2768] - tvb.adapters.simulator.simulator_adapter - <tvb.adapters.simulator.simulator_adapter.SimulatorAdapter object at 0x10ba28750>: Adapter simulation finished!!
      2015-06-24 13:43:10,339 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - We will store entity of type: TimeSeriesRegion with id None
      2015-06-24 13:43:10,374 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - After commit TimeSeriesRegion ID is 17
      2015-06-24 13:43:10,538 - ERROR [proc:2768] - tvb.core.services.operation_service - Could not launch Operation with the given input data!
      2015-06-24 13:43:10,538 - ERROR [proc:2768] - tvb.core.services.operation_service - Instance <TimeSeriesRegion at 0x10ba28a10> is not bound to a Session; attribute refresh operation cannot proceed
      Traceback (most recent call last):
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/services/operation_service.py", line 337, in initiate_prelaunch
      result_msg, nr_datatypes = adapter_instance._prelaunch(operation, unique_id, available_space, **params)
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/adapters/abcadapter.py", line 92, in new_function
      return func(*args, **kw)
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/adapters/abcadapter.py", line 292, in _prelaunch
      return self._capture_operation_results(result, uid)
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/adapters/abcadapter.py", line 338, in _capture_operation_results
      res.persist_full_metadata()
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/traits/types_mapped.py", line 344, in persist_full_metadata
      meta_dictionary[capitalized_name] = getattr(self, str(attr))
      File "/anaconda/envs/tvb-dev/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 237, in _get_
      return self.impl.get(instance_state(instance), dict_)
      File "/anaconda/envs/tvb-dev/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 573, in get
      value = state._load_expired(state, passive)
      File "/anaconda/envs/tvb-dev/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 480, in _load_expired
      self.manager.deferred_scalar_loader(self, toload)
      File "/anaconda/envs/tvb-dev/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 608, in load_scalar_attributes
      (state_str(state)))
      DetachedInstanceError: Instance <TimeSeriesRegion at 0x10ba28a10> is not bound to a Session; attribute refresh operation cannot proceed
      2015-06-24 13:43:10,540 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - We will store entity of type: Operation with id 11
      2015-06-24 13:43:10,552 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - After commit Operation ID is 11
      2015-06-24 13:43:10,580 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - No step found for workflow_id=5 and step_index=1
      2015-06-24 13:43:10,619 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - We will store entity of type: BurstConfiguration with id 5
      2015-06-24 13:43:10,631 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - After commit BurstConfiguration ID is 5
      2015-06-24 13:43:10,633 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - We will store entity of type: BurstConfiguration with id 5
      2015-06-24 13:43:10,638 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - After commit BurstConfiguration ID is 5
      2015-06-24 13:43:10,641 - ERROR [proc:2768] - tvb.core.operation_async_launcher - Could not execute operation 11
      2015-06-24 13:43:10,641 - ERROR [proc:2768] - tvb.core.operation_async_launcher - Instance <TimeSeriesRegion at 0x10ba28a10> is not bound to a Session; attribute refresh operation cannot proceed
      Traceback (most recent call last):
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/operation_async_launcher.py", line 81, in do_operation_launch
      OperationService().initiate_prelaunch(curent_operation, adapter_instance, {}, **PARAMS)
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/services/operation_service.py", line 359, in initiate_prelaunch
      self._handle_exception(excep1, temp_files, msg, operation)
      File "/Users/MW/Documents/TVB/TVB/framework_tvb/tvb/core/services/operation_service.py", line 411, in _handle_exception
      raise exception
      DetachedInstanceError: Instance <TimeSeriesRegion at 0x10ba28a10> is not bound to a Session; attribute refresh operation cannot proceed
      2015-06-24 13:43:10,665 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - We will store entity of type: BurstConfiguration with id 5
      2015-06-24 13:43:10,674 - DEBUG [proc:2768] - tvb.core.entities.storage.root_dao - After commit BurstConfiguration ID is 5

      I added the following to the beginning of MappedType.persist_full_metadata as a workaround:

      from sqlalchemy.orm.exc import DetachedInstanceError
      try:
      self.create_date
      except DetachedInstanceError as exc:
      self.logger.info('ignoring %r on %r', exc, self)
      return

      Rerunning UI with this, and simulations complete correctly, so I'm committing to SVN to unblock Tim's work on the epilepsy tutorial, but this should be addressed.

      Gliffy Diagrams

        Attachments

          Activity

            People

              lia.domide Lia Domide
              marmaduke.woodman Marmaduke Woodman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 4 hours
                  4h
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours Time Not Required
                  3h