directory_layout: remove outdated checks for old DAG hash

We previously had checks in `directory_layout` to check for build-dependency
conflicts when we weren't storing build dependencies.  We don't need
those anymore; we can just rely on the DAG hash now that it includes everything
we know about each spec.

- [x] Remove vestigial code for checking installed spec against concrete spec
      in `ensure_installed()`
- [x] Remove `SpecHashCollisionError` -- if specs have the same hash now, they're
      the same as far as `DirectoryLayout` should be concerned.
- [x] Convert spec comparison to `dag_hash()` comparison when adding extensions.
This commit is contained in:
Todd Gamblin 2022-05-11 15:36:46 -07:00
parent c93e465134
commit 5cb40cbcd2
2 changed files with 6 additions and 34 deletions

View File

@ -238,10 +238,10 @@ def create_install_directory(self, spec):
def ensure_installed(self, spec):
"""
Throws DirectoryLayoutError if:
Throws InconsistentInstallDirectoryError if:
1. spec prefix does not exist
2. spec prefix does not contain a spec file
3. the spec file does not correspond to the spec
2. spec prefix does not contain a spec file, or
3. We read a spec with the wrong DAG hash out of an existing install directory.
"""
_check_concrete(spec)
path = self.path_for_spec(spec)
@ -257,25 +257,7 @@ def ensure_installed(self, spec):
" " + path)
installed_spec = self.read_spec(spec_file_path)
if installed_spec == spec:
return
# DAG hashes currently do not include build dependencies.
#
# TODO: remove this when we do better concretization and don't
# ignore build-only deps in hashes.
elif (installed_spec.copy(deps=('link', 'run')) ==
spec.copy(deps=('link', 'run'))):
# The directory layout prefix is based on the dag hash, so among
# specs with differing full-hash but matching dag-hash, only one
# may be installed. This means for example that for two instances
# that differ only in CMake version used to build, only one will
# be installed.
return
if spec.dag_hash() == installed_spec.dag_hash():
raise SpecHashCollisionError(spec, installed_spec)
else:
if installed_spec.dag_hash() != spec.dag_hash():
raise InconsistentInstallDirectoryError(
'Spec file in %s does not match hash!' % spec_file_path)
@ -463,8 +445,8 @@ def add_extension(self, spec, ext_spec):
def check_extension_conflict(self, spec, ext_spec):
exts = self._extension_map(spec)
if ext_spec.name in exts:
installed_spec = exts[ext_spec.name].copy(deps=('link', 'run'))
if ext_spec.copy(deps=('link', 'run')) == installed_spec:
installed_spec = exts[ext_spec.name]
if ext_spec.dag_hash() == installed_spec.dag_hash():
raise ExtensionAlreadyInstalledError(spec, ext_spec)
else:
raise ExtensionConflictError(spec, ext_spec, installed_spec)
@ -584,15 +566,6 @@ def __init__(self, message, long_msg=None):
super(DirectoryLayoutError, self).__init__(message, long_msg)
class SpecHashCollisionError(DirectoryLayoutError):
"""Raised when there is a hash collision in an install layout."""
def __init__(self, installed_spec, new_spec):
super(SpecHashCollisionError, self).__init__(
'Specs %s and %s have the same SHA-1 prefix!'
% (installed_spec, new_spec))
class RemoveFailedError(DirectoryLayoutError):
"""Raised when a DirectoryLayout cannot remove an install prefix."""

View File

@ -1828,7 +1828,6 @@ def _read_lockfile_dict(self, d):
spec = Spec.from_node_dict(node_dict)
if not spec._hash:
# in v1 lockfiles, the hash only occurs as a key
print("HERE")
spec._hash = lockfile_key
specs_by_hash[lockfile_key] = spec