Made spec hashes immutable once concrete
This commit is contained in:
parent
2f821b9e9b
commit
addcde4f35
@ -486,6 +486,7 @@ def __init__(self, spec_like, *dep_like, **kwargs):
|
|||||||
self.variants = other.variants
|
self.variants = other.variants
|
||||||
self.variants.spec = self
|
self.variants.spec = self
|
||||||
self.namespace = other.namespace
|
self.namespace = other.namespace
|
||||||
|
self.hash = other.hash
|
||||||
|
|
||||||
# Specs are by default not assumed to be normal, but in some
|
# Specs are by default not assumed to be normal, but in some
|
||||||
# cases we've read them from a file want to assume normal.
|
# cases we've read them from a file want to assume normal.
|
||||||
@ -754,12 +755,16 @@ def dag_hash(self, length=None):
|
|||||||
"""
|
"""
|
||||||
Return a hash of the entire spec DAG, including connectivity.
|
Return a hash of the entire spec DAG, including connectivity.
|
||||||
"""
|
"""
|
||||||
yaml_text = yaml.dump(
|
if self.hash:
|
||||||
self.to_node_dict(), default_flow_style=True, width=sys.maxint)
|
return self.hash
|
||||||
# print yaml_text
|
else:
|
||||||
sha = hashlib.sha1(yaml_text)
|
yaml_text = yaml.dump(
|
||||||
return base64.b32encode(sha.digest()).lower()[:length]
|
self.to_node_dict(), default_flow_style=True, width=sys.maxint)
|
||||||
|
sha = hashlib.sha1(yaml_text)
|
||||||
|
b32_hash = base64.b32encode(sha.digest()).lower()[:length]
|
||||||
|
if self._concrete:
|
||||||
|
self.hash = b32_hash
|
||||||
|
return b32_hash
|
||||||
|
|
||||||
def to_node_dict(self):
|
def to_node_dict(self):
|
||||||
params = dict( (name, v.value) for name, v in self.variants.items() )
|
params = dict( (name, v.value) for name, v in self.variants.items() )
|
||||||
@ -2128,6 +2133,7 @@ def spec(self, name, check_valid_token = False):
|
|||||||
spec.dependents = DependencyMap()
|
spec.dependents = DependencyMap()
|
||||||
spec.dependencies = DependencyMap()
|
spec.dependencies = DependencyMap()
|
||||||
spec.namespace = spec_namespace
|
spec.namespace = spec_namespace
|
||||||
|
spec.hash = None
|
||||||
|
|
||||||
spec._normal = False
|
spec._normal = False
|
||||||
spec._concrete = False
|
spec._concrete = False
|
||||||
|
Loading…
Reference in New Issue
Block a user