Merge pull request #232 from LLNL/bugfix/package-cache-217
Bugfix/package cache 217
This commit is contained in:
@@ -67,27 +67,28 @@ def get(self, spec, **kwargs):
|
|||||||
if spec.virtual:
|
if spec.virtual:
|
||||||
raise UnknownPackageError(spec.name)
|
raise UnknownPackageError(spec.name)
|
||||||
|
|
||||||
|
key = hash(spec)
|
||||||
if kwargs.get('new', False):
|
if kwargs.get('new', False):
|
||||||
if spec in self.instances:
|
if key in self.instances:
|
||||||
del self.instances[spec]
|
del self.instances[key]
|
||||||
|
|
||||||
if not spec in self.instances:
|
if not key in self.instances:
|
||||||
package_class = self.get_class_for_package_name(spec.name)
|
package_class = self.get_class_for_package_name(spec.name)
|
||||||
try:
|
try:
|
||||||
copy = spec.copy()
|
copy = spec.copy() # defensive copy. Package owns its spec.
|
||||||
self.instances[copy] = package_class(copy)
|
self.instances[key] = package_class(copy)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if spack.debug:
|
if spack.debug:
|
||||||
sys.excepthook(*sys.exc_info())
|
sys.excepthook(*sys.exc_info())
|
||||||
raise FailedConstructorError(spec.name, e)
|
raise FailedConstructorError(spec.name, e)
|
||||||
|
|
||||||
return self.instances[spec]
|
return self.instances[key]
|
||||||
|
|
||||||
|
|
||||||
@_autospec
|
@_autospec
|
||||||
def delete(self, spec):
|
def delete(self, spec):
|
||||||
"""Force a package to be recreated."""
|
"""Force a package to be recreated."""
|
||||||
del self.instances[spec]
|
del self.instances[spec.dag_hash()]
|
||||||
|
|
||||||
|
|
||||||
def purge(self):
|
def purge(self):
|
||||||
|
|||||||
@@ -1481,8 +1481,11 @@ def ne_dag(self, other):
|
|||||||
|
|
||||||
def _cmp_node(self):
|
def _cmp_node(self):
|
||||||
"""Comparison key for just *this node* and not its deps."""
|
"""Comparison key for just *this node* and not its deps."""
|
||||||
return (self.name, self.versions, self.variants,
|
return (self.name,
|
||||||
self.architecture, self.compiler)
|
self.versions,
|
||||||
|
self.variants,
|
||||||
|
self.architecture,
|
||||||
|
self.compiler)
|
||||||
|
|
||||||
|
|
||||||
def eq_node(self, other):
|
def eq_node(self, other):
|
||||||
@@ -1496,11 +1499,15 @@ def ne_node(self, other):
|
|||||||
|
|
||||||
|
|
||||||
def _cmp_key(self):
|
def _cmp_key(self):
|
||||||
"""Comparison key for this node and all dependencies *without*
|
"""This returns a key for the spec *including* DAG structure.
|
||||||
considering structure. This is the default, as
|
|
||||||
normalization will restore structure.
|
The key is the concatenation of:
|
||||||
|
1. A tuple describing this node in the DAG.
|
||||||
|
2. The hash of each of this node's dependencies' cmp_keys.
|
||||||
"""
|
"""
|
||||||
return self._cmp_node() + (self.sorted_deps(),)
|
return self._cmp_node() + (
|
||||||
|
tuple(hash(self.dependencies[name])
|
||||||
|
for name in sorted(self.dependencies)),)
|
||||||
|
|
||||||
|
|
||||||
def colorized(self):
|
def colorized(self):
|
||||||
|
|||||||
@@ -340,16 +340,18 @@ def test_normalize_mpileaks(self):
|
|||||||
self.assertEqual(spec, expected_flat)
|
self.assertEqual(spec, expected_flat)
|
||||||
self.assertTrue(spec.eq_dag(expected_flat))
|
self.assertTrue(spec.eq_dag(expected_flat))
|
||||||
|
|
||||||
self.assertEqual(spec, expected_normalized)
|
# Normalized has different DAG structure, so NOT equal.
|
||||||
|
self.assertNotEqual(spec, expected_normalized)
|
||||||
self.assertFalse(spec.eq_dag(expected_normalized))
|
self.assertFalse(spec.eq_dag(expected_normalized))
|
||||||
|
|
||||||
self.assertEqual(spec, non_unique_nodes)
|
# Again, different DAG structure so not equal.
|
||||||
|
self.assertNotEqual(spec, non_unique_nodes)
|
||||||
self.assertFalse(spec.eq_dag(non_unique_nodes))
|
self.assertFalse(spec.eq_dag(non_unique_nodes))
|
||||||
|
|
||||||
spec.normalize()
|
spec.normalize()
|
||||||
|
|
||||||
# After normalizing, spec_dag_equal should match the normalized spec.
|
# After normalizing, spec_dag_equal should match the normalized spec.
|
||||||
self.assertEqual(spec, expected_flat)
|
self.assertNotEqual(spec, expected_flat)
|
||||||
self.assertFalse(spec.eq_dag(expected_flat))
|
self.assertFalse(spec.eq_dag(expected_flat))
|
||||||
|
|
||||||
self.assertEqual(spec, expected_normalized)
|
self.assertEqual(spec, expected_normalized)
|
||||||
|
|||||||
Reference in New Issue
Block a user