[Yt-svn] yt-commit r1033 - in branches/yt-object-serialization/yt: fido lagos
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Tue Dec 23 21:59:51 PST 2008
Author: mturk
Date: Tue Dec 23 21:59:50 2008
New Revision: 1033
URL: http://yt.spacepope.org/changeset/1033
Log:
Changed import location in the ParameterFileStorage object, added empty
ObjectStorage class, added import of ParameterFileStore in lagos/__init__.py,
and added a pickler and unpickler for data types.
Spheres (nothing else just yet) can now be pickled and unpickled, and the
parameter file will be grabbed automatically from the SQLite db. __reduce__
could probably be generalized to work with all the classes from a single
function definition.
Modified:
branches/yt-object-serialization/yt/fido/ParameterFileStorage.py
branches/yt-object-serialization/yt/lagos/BaseDataTypes.py
branches/yt-object-serialization/yt/lagos/__init__.py
Modified: branches/yt-object-serialization/yt/fido/ParameterFileStorage.py
==============================================================================
--- branches/yt-object-serialization/yt/fido/ParameterFileStorage.py (original)
+++ branches/yt-object-serialization/yt/fido/ParameterFileStorage.py Tue Dec 23 21:59:50 2008
@@ -40,7 +40,6 @@
from yt.fido import *
import sqlite3
-import yt.lagos.OutputTypes
import os.path
#sqlite3.register_adapter(yt.lagos.OutputTypes.EnzoStaticOutput, _adapt_pf)
@@ -112,7 +111,8 @@
bn, fp, t1, ctid, hash = row
fn = os.path.join(fp, bn)
if os.path.exists(fn):
- pf = yt.lagos.EnzoStaticOutput(
+ import yt.lagos.OutputTypes as ot
+ pf = ot.EnzoStaticOutput(
os.path.join(fp, bn))
else:
raise IOError
@@ -138,3 +138,7 @@
(?,?,?,?,?)""", self._adapt_pf(pf))
self._conn.commit()
c.close()
+
+class ObjectStorage(object):
+ pass
+
Modified: branches/yt-object-serialization/yt/lagos/BaseDataTypes.py
==============================================================================
--- branches/yt-object-serialization/yt/lagos/BaseDataTypes.py (original)
+++ branches/yt-object-serialization/yt/lagos/BaseDataTypes.py Tue Dec 23 21:59:50 2008
@@ -1628,6 +1628,10 @@
self._cut_masks[grid.id] = cm
return cm
+ def __reduce__(self):
+ return (_reconstruct_object,
+ (self.pf._hash(), 'sphere', self.center, self.radius, self.field_parameters))
+
class AMRCoveringGrid(AMR3DData):
"""
Covering grids represent fixed-resolution data over a given region.
@@ -1874,3 +1878,15 @@
class EnzoCoveringGrid(AMRCoveringGrid): pass
class EnzoSmoothedCoveringGrid(AMRSmoothedCoveringGrid): pass
+def _reconstruct_object(*args, **kwargs):
+ pfid = args[0]
+ dtype = args[1]
+ field_parameters = args[-1]
+ # will be much nicer when we can do pfid, *a, fp = args
+ args = args[2:-1]
+ pfs = ParameterFileStore()
+ pf = pfs.get_pf_hash(pfid)
+ cls = getattr(pf.h, dtype)
+ obj = cls(*args)
+ obj.field_parameters.update(field_parameters)
+ return pf, obj
Modified: branches/yt-object-serialization/yt/lagos/__init__.py
==============================================================================
--- branches/yt-object-serialization/yt/lagos/__init__.py (original)
+++ branches/yt-object-serialization/yt/lagos/__init__.py Tue Dec 23 21:59:50 2008
@@ -42,9 +42,6 @@
except ImportError:
mylog.warning("No PyTables. Data serialization will fail.")
-
-
-
from yt.arraytypes import *
import weakref
from new import classobj
@@ -92,6 +89,8 @@
# We by-default add universal fields.
add_field = FieldInfo.add_field
+from yt.fido import ParameterFileStore
+
from DerivedQuantities import DerivedQuantityCollection, GridChildMaskWrapper
from DataReadingFuncs import *
from ClusterFiles import *
@@ -104,6 +103,7 @@
from OutputTypes import *
from Profiles import *
+
# We load plugins. Keep in mind, this can be fairly dangerous -
# the primary purpose is to allow people to have a set of functions
# that get used every time that they don't have to *define* every time.
More information about the yt-svn
mailing list