mailRe: Pickling problems with the relax data storage singleton.


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Gary Thompson on November 22, 2007 - 09:55:
Edward d'Auvergne wrote:

Chris and Gary,

Remember a long way back we had discussions about the following concept:

-----
class Data(dict):
   """The relax data storage object."""

[snip]

# Rebind the name Data with an instance to prevent accidental creation
# of multiple instances of the Data class
Data = Data()
-----

This was the method we decided upon for creating the data storage
singleton.  For the discussions about this design pattern see:

Parent thread:
https://mail.gna.org/public/relax-devel/2007-03/msg00012.html
(Message-id: <7f080ed10703070006s309a1e1do38e621f48d8f6d9e@xxxxxxxxxxxxxx>).

Second minor thread:
https://mail.gna.org/public/relax-devel/2007-03/msg00038.html
(Message-id: <7f080ed10703130151u6702d44ap7e75240e70893492@xxxxxxxxxxxxxx>).

The vote thread:
https://mail.gna.org/public/relax-devel/2007-03/msg00046.html
(Message-id: <7f080ed10703140609p70d35295ye10ee5939da494a2@xxxxxxxxxxxxxx>).


There is an issue with this approach that has been uncovered through
unit tests.  I have created a single unit test in the 1.3 line for the
saving of the relax state (which is really the pickling of the
singleton) which fails.  We need to work out how to fix the pickling
problem.  I have temporarily renamed the Data class to Data2, but this
means that we no longer have a singleton (see
https://mail.gna.org/public/relax-commits/2007-11/msg00328.html).
Would you be able to have a look at the unit test and this problem?  I
can't find any solutions in the pickling documentation.

Thanks,

Edward


P.S.  I will also implement a unit test or two for
generic_fns.state.load() to have a more comprehensive set of tests,
both for pickling and unpickling, for checking any code changes.

_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

.

Hi Ed

Can you give some details of how it fails? Is there an exception or does it just replace the Data sinleton instance with a class instance?
Anyway i will dig further later in the week

regards
gary

Of course one of the points here is that this isn't the only way to write a singleton ;-)

--
-------------------------------------------------------------------
Dr Gary Thompson
Astbury Centre for Structural Molecular Biology,
University of Leeds, Astbury Building,
Leeds, LS2 9JT, West-Yorkshire, UK             Tel. +44-113-3433024
email: garyt@xxxxxxxxxxxxxxx                   Fax  +44-113-2331407
-------------------------------------------------------------------





Related Messages


Powered by MHonArc, Updated Thu Nov 22 10:23:44 2007