markovmodel / adaptivemd

A python framework to run adaptive Markov state model (MSM) simulation on HPC resources
GNU Lesser General Public License v2.1
18 stars 7 forks source link

Bug with reloading a project? #16

Closed thempel closed 7 years ago

thempel commented 7 years ago

After reloading a project, the project.trajectories object is empty. I'm not sure if I caused this myself by creating the engine and modeller objects again instead of loading them. Probably that's the problem, so maybe it would be good to have an error message or something. Since the files are still in place, it would also be nice to fix that somehow.

Edit: If I load all the objects like engine and modeller, trying to output the trajectories with list(project.trajectories) results in a TypeError.

jhprinz commented 7 years ago

I'm not sure if I caused this myself by creating the engine and modeller objects again instead of loading them.

No, that cannot happen. In that case you would just have more than one engine that does the same. No problem here.

After reloading a project, the project.trajectories object is empty.

That should not happen. Can you confirm that project.files is not empty? If you accidentally closed the project, then all stores will be empty.

Also, the .trajectories is not a store it is only a view on .files of objects with type Trajectory and the .created attribute being positive (meaning it exists)

thempel commented 7 years ago

Two scenarios here:

  1. Created new engine and modeller objects: project.files was not empty but did not contain the trajectory files either.
  2. Reloaded engine and modeller from the project: Trajectories are now in project.files, but list(project.trajectories)produces a print error (cf. below). The rest seems to work, so a model can be build.

When should I close a project? I always closed it after I was finished or had to restart the notebook and opened it again with project = Project('project name') before starting to work - is that wrong?

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    670                 type_pprinters=self.type_printers,
    671                 deferred_pprinters=self.deferred_printers)
--> 672             printer.pretty(obj)
    673             printer.flush()
    674             return stream.getvalue()

/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    366                 if cls in self.type_pprinters:
    367                     # printer registered in self.type_pprinters
--> 368                     return self.type_pprinters[cls](obj, self, cycle)
    369                 else:
    370                     # deferred printer

/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/lib/pretty.pyc in inner(obj, p, cycle)
    550                 p.text(',')
    551                 p.breakable()
--> 552             p.pretty(x)
    553         if len(obj) == 1 and type(obj) is tuple:
    554             # Special case for 1-item tuples.

/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/lib/pretty.pyc in pretty(self, obj)
    381                             if callable(meth):
    382                                 return meth(obj, self, cycle)
--> 383             return _default_pprint(obj, self, cycle)
    384         finally:
    385             self.end_group()

/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle)
    501     if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
    502         # A user-provided repr. Find newlines and replace them with p.break_()
--> 503         _repr_pprint(obj, p, cycle)
    504         return
    505     p.begin_group(1, '<')

/storage/mi/thempel/anaconda3/envs/py27_0/lib/python2.7/site-packages/IPython/lib/pretty.pyc in _repr_pprint(obj, p, cycle)
    699     """A pprint that just redirects to the normal repr function."""
    700     # Find newlines and replace them with p.break_()
--> 701     output = repr(obj)
    702     for idx,output_line in enumerate(output.splitlines()):
    703         if idx:

/storage/mi/thempel/adaptive_MD_test/adaptivemd/adaptivemd/engine/engine.pyc in __repr__(self)
     97     def __repr__(self):
     98         return "Trajectory(%r >> %s[0..%d])" % (
---> 99             self.frame, self.basename, self.length)
    100 
    101     def pick(self):

TypeError: %d format: a number is required, not NoneType
thempel commented 7 years ago

Fixed by #21