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 Edward d'Auvergne on November 22, 2007 - 10:06:
On Nov 22, 2007 9:54 AM, Gary Thompson <garyt@xxxxxxxxxxxxxxx> wrote:

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()
-----


[snip]

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

This can be seen by running the unit tests.  Just edit the file
data/__init__.py which contains the singleton and raname both
instances of Data2 to Data.  Then the unit test will give the relevent
message:

======================================================================
ERROR: The pickling and saving of the relax data storage singleton.
----------------------------------------------------------------------
Traceback (most recent call last):
  File 
"/nmr5/edau/relax/relax-1.3/test_suite/unit_tests/state_testing_base.py",
line 100, in test_save
    self.state.save_state(file='test')
  File "/nmr5/edau/relax/relax-1.3/prompt/state.py", line 178, in save
    save_state(file=file, dir=dir, force=force, compress_type=compress_type)
  File "/nmr5/edau/relax/relax-1.3/generic_fns/state.py", line 77, in 
save_state
    dump(relax_data_store, file, 1)
PicklingError: Can't pickle <class 'data.Data'>: it's not the same
object as data.Data

======================================================================

This looks like a possible namespace issue.  Maybe???



regards
gary

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

Of course, but I think we should still go with the way we voted.  We
just need to work out how to pickle this thing.

Cheers,

Edward


--
Edward d'Auvergne
Website:  http://nmr-relax.com
Profile:  https://gna.org/users/bugman



Related Messages


Powered by MHonArc, Updated Fri Nov 23 09:21:26 2007