hashes: revert spack monitor hash changes to preserve original protocol

`spack monitor` expects a field called `spec_full_hash`, so we shouldn't change that.
Instead, we can pass a `dag_hash` (which is now the full hash) but not change the field
name.
This commit is contained in:
Todd Gamblin 2022-04-12 17:24:54 -07:00
parent 9d9e970367
commit 72b38851eb
4 changed files with 17 additions and 14 deletions

View File

@ -1269,7 +1269,7 @@ def _concretize_separately(self, tests=False):
by_hash = {}
for abstract, concrete in zip(root_specs, concretized_root_specs):
self._add_concrete_spec(abstract, concrete)
by_hash[concrete.build_hash()] = concrete
by_hash[concrete.dag_hash()] = concrete
# Unify the specs objects, so we get correct references to all parents
self._read_lockfile_dict(self._to_lockfile_dict())

View File

@ -132,7 +132,7 @@ def __init__(self, host=None, prefix="ms1", allow_fail=False, tags=None,
self.tags = tags
self.save_local = save_local
# We keey lookup of build_id by dag_hash
# We key lookup of build_id by dag_hash
self.build_ids = {}
self.setup_save()
@ -412,7 +412,9 @@ def new_configuration(self, specs):
spec.concretize()
# Remove extra level of nesting
as_dict = {"spec": spec.to_dict(hash=ht.dag_hash)['spec'],
# This is the only place in Spack we still use full_hash, as `spack monitor`
# requires specs with full_hash-keyed dependencies.
as_dict = {"spec": spec.to_dict(hash=ht.full_hash)['spec'],
"spack_version": self.spack_version}
if self.save_local:
@ -437,8 +439,7 @@ def failed_concretization(self, specs):
meta = spec.to_dict()['spec']
nodes = []
for node in meta.get("nodes", []):
for hashtype in ["hash", "runtime_hash"]:
node[hashtype] = "FAILED_CONCRETIZATION"
node["full_hash"] = "FAILED_CONCRETIZATION"
nodes.append(node)
meta['nodes'] = nodes
@ -476,7 +477,7 @@ def get_build_id(self, spec, return_response=False, spec_exists=True):
# Prepare build environment data (including spack version)
data = self.build_environment.copy()
data['hash'] = dag_hash
data['full_hash'] = dag_hash
# If the build should be tagged, add it
if self.tags:

View File

@ -2056,14 +2056,15 @@ def node_dict_with_hashes(self, hash=ht.dag_hash):
# to be included. This is effectively the last chance we get to compute
# it accurately.
if self.concrete:
# all specs have at least a DAG hash
node[ht.dag_hash.name] = self.dag_hash()
else:
node['concrete'] = False
if hash.name == 'process_hash':
node[hash.name] = self.process_hash()
elif hash.name == 'runtime_hash':
node[hash.name] = self.runtime_hash()
# we can also give them other hash types if we want
if hash.name != ht.dag_hash.name:
node[hash.name] = self._cached_hash(hash)
return node

View File

@ -48,8 +48,10 @@ def mock_monitor_request(monkeypatch):
"""
def mock_do_request(self, endpoint, *args, **kwargs):
# monitor was originally keyed by full_hash, but now dag_hash is the full hash.
# the name of the field in monitor is still spec_full_hash, for now.
build = {"build_id": 1,
"spec_hash": "bpfvysmqndtmods4rmy6d6cfquwblngp",
"spec_full_hash": "bpfvysmqndtmods4rmy6d6cfquwblngp",
"spec_name": "dttop"}
# Service Info
@ -111,7 +113,7 @@ def mock_do_request(self, endpoint, *args, **kwargs):
elif endpoint == "specs/new/":
return {"message": "success",
"data": {
"hash": "bpfvysmqndtmods4rmy6d6cfquwblngp",
"full_hash": "bpfvysmqndtmods4rmy6d6cfquwblngp",
"name": "dttop",
"version": "1.0",
"spack_version": "0.16.0-1379-7a5351d495",
@ -264,12 +266,11 @@ def test_install_monitor_save_local(install_mockery_mutable_config,
# Get the spec name
spec = spack.spec.Spec("dttop")
spec.concretize()
dag_hash = spec.dag_hash()
# Ensure we have monitor results saved
for dirname in os.listdir(str(reports_dir)):
dated_dir = os.path.join(str(reports_dir), dirname)
build_metadata = "build-metadata-%s.json" % dag_hash
build_metadata = "build-metadata-%s.json" % spec.dag_hash()
assert build_metadata in os.listdir(dated_dir)
spec_file = "spec-dttop-%s-config.json" % spec.version
assert spec_file in os.listdir(dated_dir)