Unable to load in derivable arrays in server mode
When attempting to run a calculation that uses load-mode=server, the process crashes on a step where it is attempting to load in a derivable array (in this case, "ne" for gas particles). This does not occur when running with load-mode=partial. The error comes as a KeyError for gas family.
a5310> applied to <Halo u'h1.cosmo50/h1.cosmo50PLK.1536gst1bwK1BH.003935/halo_1' | NDM=356536379 Nstar=95801512 Ngas=83888973>
Traceback (most recent call last):
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/tangos-1.0.dev0-py2.7.egg/tangos/tools/property_writer.py", line 370, in _get_prope
rty_value
result = property_calculator.calculate(snapshot_data, db_data)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/tangos-1.0.dev0-py2.7.egg/michaels_properties/profiles.py", line 94, in calculate
rho_e = ps['rho_e']
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/analysis/profile.py", line 434, in __ge
titem__
return self._get_profile(name)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/analysis/profile.py", line 346, in _get
_profile
self._profiles[name] = Profile._profile_registry[x[0]](self, *args)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/tangos-1.0.dev0-py2.7.egg/michaels_properties/profiles.py", line 50, in rho_e
n_e[i] = np.sum(subs.g['ne'][use] * subs.g['mass'][use].in_units('m_p'))/self._binsize.in_units('cm**'+str(int(self.ndim)))[i]
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/snapshot/__init__.py", line 263, in __g
etitem__
return self._get_array_with_lazy_actions(i)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/snapshot/__init__.py", line 358, in _ge
t_array_with_lazy_actions
return self._get_array(name)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/snapshot/__init__.py", line 1909, in _g
et_array
return self.base._get_family_array(name, self._unifamily, index, always_writable)
File "/u/mtremmel/anaconda/lib/python2.7/site-packages/pynbody-0.41-py2.7-linux-x86_64.egg/pynbody/snapshot/__init__.py", line 1852, in _g
et_family_array
sl = self._family_indices[fam]
KeyError: <Family gas>```
Could you make your michaels_properties module available somewhere so I can reproduce the exact issue?
I have a forked version... I think you can access it? It was forked from the original halo_database repository... how it is a part of pynbody. Not sure if that matters right now.
github.com/mtremmel/halo_database
OK I think quite a complex range of things have happened here.
First, there is something slightly strange about how _family_indices is getting set which I don't quite understand. However this seems trivially fixable by changing line 1852 of pynbody's pynbody/snapshot/__init__.py to sl = self._family_indices.get(fam,None) (was originally sl = self._family_indices[fam])
Then there is something more annoying but more understandable. Basically the ne property is specific to TipsySnap (see line 980 of pynbody/snapshot/tipsy.py forwards). But the snapshot is now of type RemoteSnap, not TipsySnap. This requires a more permanent fix but for now could you try changing all the TipsySnap.derived_quantity to SimSnap.derived_quantity in your tipsy.py.
With these two modifications does your code operate correctly? If so we have identified the problem and can move onto figuring out more permanent fixes.
Tried load-mode=server with those changes and it works! So the problem has been found.
Permanent fix for this proposed in PR #5
@mtremmel please see if this works for you! Ignore the fact that the Travis tests are failing - this seems to be some py3.5-specific issue with a library somewhere; I'll track this down in the meantime.
I've merged but will wait to hear whether it fixes the original problem before closing the issue