feature : register external packages in the DB#1167
Conversation
|
@tgamblin @becker33 @mathstuf @mplegendre I think this is ready to be reviewed |
lib/spack/spack/database.py
Outdated
| d = dictionary | ||
| return InstallRecord(spec, d['path'], d['installed'], d['ref_count'], | ||
| d.get('explicit', False)) | ||
| d['explicit'], d['external']) |
There was a problem hiding this comment.
Hmm. Seems this would be best as **dictionary. Does that work?
There was a problem hiding this comment.
@mathstuf Apparently not... spec may be in dictionary, so I had to resort to popping it out before doing a **d. Would this be good enough ?
|
@alalazo: this looks good to me except for one thing. I think the spec should be where things are stored as external or not. If I build a package with one version of an external package, and then I change the external location, that should be considered a different build and a different package, and it should change the hash. Would you agree with that? Places where this would help:
Right now the external:
path: /path/to/package
module: name-of-moduleEither path or module could be specified in the spec. What do you think? |
lib/spack/spack/package.py
Outdated
| def installed(self): | ||
| return os.path.isdir(self.prefix) | ||
| try: | ||
| rec = spack.installed_db.get_record(self.spec) |
There was a problem hiding this comment.
@tgamblin If I remember well this line was slowing things down. Maybe the situation won't be that bad after JSON indexing though...
|
@tgamblin Do you want this for v0.10 ? |
It seems a good plan to me |
|
Depends on how long it would take. If you can do it this week I think it is reasonable to put in. Imho it's how this should work... what do you think? |
Fine with me. I'll try to do this asap. |
b272410 to
fddb921
Compare
|
@tgamblin Just to let you know: I restarted working on this. The current version should work as you asked, but I didn't have the possibility to check it on Cray (for the |
8dcc62c to
15c6ecd
Compare
|
@mplegendre @tgamblin PR ready for review, unit tests have been added. |
|
@tgamblin A thought I had on changing hashes. Since Spack is no longer compatible with installations done under a previous hashing mechanism, users are forced to either uninstall everything or create a new Spack installation. Could we increment the version number of Spack every time this happens? Instead of incrementing the version during each release, the version of develop should be incremented to reflect changes in the hashing mechanism. |
|
@adamjstewart Just my 2 cents: I don't like very much this idea. I think that as the core of Spack becomes more stable we should try to go for time-based releases (e.g. every
|
|
I agree, and this makes perfect sense for a regular project. But I currently have a |
…f a spec/yaml round-trip for things that involve an external
* Improve implementation of external packages * Don't find external module path at each step of concretization it's not necessary.. The paths are retrieved at the end of concretizaion * Don't find replacements for external packages. * Test root of the DAG if external No reason not to test if the root of the DAG is external when external packages are now first class citizens! * Clean up statements in package for external modules * Correct serious flaw with external package code I made earlier * Create external property for Spec. * Remove some stray externals * Allow users to specify external package paths relative to spack Canonicalize external package paths so that users may specify their locations relative to spack's directory. * Remove leftover external= statement * Update tests to use new external_path and external properly.
3f0760e to
5af97a7
Compare
|
Tested manually with this packages:
zlib:
buildable: False
paths:
[email protected]%[email protected]: /usr/lib/x86_64-linux-gnu
openssl:
buildable: False
paths:
openssl@system%[email protected]: /usr/lib/x86_64-linux-gnuThe result is the following: $ spack install openssl
==> openssl@system : externally installed in /usr/lib/x86_64-linux-gnu
==> openssl@system : generating module file
==> openssl@system : registering into DB
$ spack install hdf5~mpi+szip
==> [email protected] : externally installed in /usr/lib/x86_64-linux-gnu
==> [email protected] : generating module file
==> [email protected] : registering into DB
==> Installing szip
==> Using cached archive: /home/mculpo/PycharmProjects/spack/var/spack/cache/szip/szip-2.1.tar.gz
==> Staging archive: /home/mculpo/PycharmProjects/spack/var/spack/stage/szip-2.1-uxcvrxb4jpm3rkqjwmburqcaobtac6mw/szip-2.1.tar.gz
==> Created stage in /home/mculpo/PycharmProjects/spack/var/spack/stage/szip-2.1-uxcvrxb4jpm3rkqjwmburqcaobtac6mw
==> Ran patch() for szip
==> Building szip [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
==> Executing phase : 'build'
==> Executing phase : 'install'
==> Successfully installed szip
Fetch: 0.00s. Build: 8.60s. Total: 8.60s.
[+] /home/mculpo/PycharmProjects/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.8/szip-2.1-uxcvrxb4jpm3rkqjwmburqcaobtac6mw
==> Installing hdf5
==> Using cached archive: /home/mculpo/PycharmProjects/spack/var/spack/cache/hdf5/hdf5-1.10.0-patch1.tar.gz
==> Staging archive: /home/mculpo/PycharmProjects/spack/var/spack/stage/hdf5-1.10.0-patch1-slyc4764jhitnou4jpaf4lo5l3qvovdp/hdf5-1.10.0-patch1.tar.gz
==> Created stage in /home/mculpo/PycharmProjects/spack/var/spack/stage/hdf5-1.10.0-patch1-slyc4764jhitnou4jpaf4lo5l3qvovdp
==> Ran patch() for hdf5
==> Building hdf5 [AutotoolsPackage]
==> Executing phase : 'autoreconf'
==> Executing phase : 'configure'
==> Executing phase : 'build'
==> Executing phase : 'install'
==> Successfully installed hdf5
Fetch: 0.04s. Build: 6m 24.44s. Total: 6m 24.48s.
[+] /home/mculpo/PycharmProjects/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.8/hdf5-1.10.0-patch1-slyc4764jhitnou4jpaf4lo5l3qvovdp
$ cp -r opt/spack/.spack-db/ ~/tmp/
$ spack -d reindex
==> WRITE LOCK: /home/mculpo/PycharmProjects/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> RECONSTRUCTING FROM SPEC.YAML: [email protected]%[email protected] arch=linux-ubuntu14-x86_64
==> RECONSTRUCTING FROM SPEC.YAML: [email protected]%[email protected]+cxx~debug+fortran~mpi+pic+shared+szip~threadsafe arch=linux-ubuntu14-x86_64 ^[email protected]%[email protected] arch=linux-ubuntu14-x86_64 ^[email protected]%[email protected]+pic+shared arch=linux-ubuntu14-x86_64
==> RECONSTRUCTING FROM OLD DB: [email protected]%[email protected]+pic+shared arch=linux-ubuntu14-x86_64
==> SKIPPING RECONSTRUCTION FROM OLD DB: [email protected]%[email protected] arch=linux-ubuntu14-x86_64 [already reconstructed from spec.yaml]
==> RECONSTRUCTING FROM OLD DB: openssl@system%[email protected] arch=linux-ubuntu14-x86_64
==> SKIPPING RECONSTRUCTION FROM OLD DB: [email protected]%[email protected]+cxx~debug+fortran~mpi+pic+shared+szip~threadsafe arch=linux-ubuntu14-x86_64 ^[email protected]%[email protected] arch=linux-ubuntu14-x86_64 ^[email protected]%[email protected]+pic+shared arch=linux-ubuntu14-x86_64 [already reconstructed from spec.yaml]
==> WRITE LOCK: /home/mculpo/PycharmProjects/spack/opt/spack/.spack-db/lock[0:0] [Released]
$ diff opt/spack/.spack-db/index.json ~/tmp/.spack-db/index.json
|
I added the logic to take care of the fact that you may have registered external packages that are not dependencies of anything else (think of an externally installed Intel compiler, or an external licensed application), so that they could be reconstructed as well. I agree that the logic should be reversed, and this is fixed now. I also added comments in the code to not lose memory of what we said here. Let me kow if I need to rephrase anything to make it clearer. |
|
Ok, this should be ready for another review round. |
tgamblin
left a comment
There was a problem hiding this comment.
LGTM! Minor comments but finally done. Thanks for all the updates!
| # considered authoritative with respect to DB reindexing, as | ||
| # entries in the DB may be corrupted in a way that still makes | ||
| # them readable. If we considered DB entries authoritative | ||
| # instead, we would perpetuate errors over a reindex. |
There was a problem hiding this comment.
We probably should add an option to propagate only specs from spec.yaml files, but that can wait for a separate PR. I don't think there is an immediate need for it.
| except Exception as e: | ||
| # Something went wrong, so the spec was not restored | ||
| # from old data | ||
| tty.debug(e.message) |
There was a problem hiding this comment.
Also for separate PR: it would be good to add something like:
if spack.debug:
print(traceback.format_exc())So we don't lose the trace.
| tty.msg(message.format(s=self, module=self.spec.external_module)) | ||
| message = '{s.name}@{s.version} : is actually installed in {path}' | ||
| tty.msg(message.format(s=self, path=self.spec.external_path)) | ||
| else: |
There was a problem hiding this comment.
generally good style to either assert self.spec.external or to say eilf self.spec.external_path: ... else: raise ValueError("spec was not external")
Fixes spack#4026 spack#1167 updated Database.reindex to keep old installation records to support external packages. However, when a user manually removes a prefix and reindexes this kept the records so the packages were still installed according to "spack find" etc. This adds a check for non-external packages to ensure they are properly installed according to the directory layout.
Fixes #4026 #1167 updated Database.reindex to keep old installation records to support external packages. However, when a user manually removes a prefix and reindexes this kept the records so the packages were still installed according to "spack find" etc. This adds a check for non-external packages to ensure they are properly installed according to the directory layout.
* treats correctly a change from `explicit=False` to `explicit=True` in an external package DB entry. * added unit tests * fixed issues raised by @tgamblin . In particular the PR is no more hash-changing for packages that are not external. * added a test to check correctness of a spec/yaml round-trip for things that involve an external * Don't find external module path at each step of concretization * it's not necessary.. The paths are retrieved at the end of concretizaion * Don't find replacements for external packages. * Test root of the DAG if external * No reason not to test if the root of the DAG is external when external packages are now first class citizens! * Create `external` property for Spec (for external_path and external_module) * Allow users to specify external package paths relative to spack * Canonicalize external package paths so that users may specify their locations relative to spack's directory. * Update tests to use new external_path and external properly. * skip license hooks on external
Fixes spack#4026 spack#1167 updated Database.reindex to keep old installation records to support external packages. However, when a user manually removes a prefix and reindexes this kept the records so the packages were still installed according to "spack find" etc. This adds a check for non-external packages to ensure they are properly installed according to the directory layout.
* treats correctly a change from `explicit=False` to `explicit=True` in an external package DB entry. * added unit tests * fixed issues raised by @tgamblin . In particular the PR is no more hash-changing for packages that are not external. * added a test to check correctness of a spec/yaml round-trip for things that involve an external * Don't find external module path at each step of concretization * it's not necessary.. The paths are retrieved at the end of concretizaion * Don't find replacements for external packages. * Test root of the DAG if external * No reason not to test if the root of the DAG is external when external packages are now first class citizens! * Create `external` property for Spec (for external_path and external_module) * Allow users to specify external package paths relative to spack * Canonicalize external package paths so that users may specify their locations relative to spack's directory. * Update tests to use new external_path and external properly. * skip license hooks on external
Fixes spack#4026 spack#1167 updated Database.reindex to keep old installation records to support external packages. However, when a user manually removes a prefix and reindexes this kept the records so the packages were still installed according to "spack find" etc. This adds a check for non-external packages to ensure they are properly installed according to the directory layout.
* treats correctly a change from `explicit=False` to `explicit=True` in an external package DB entry. * added unit tests * fixed issues raised by @tgamblin . In particular the PR is no more hash-changing for packages that are not external. * added a test to check correctness of a spec/yaml round-trip for things that involve an external * Don't find external module path at each step of concretization * it's not necessary.. The paths are retrieved at the end of concretizaion * Don't find replacements for external packages. * Test root of the DAG if external * No reason not to test if the root of the DAG is external when external packages are now first class citizens! * Create `external` property for Spec (for external_path and external_module) * Allow users to specify external package paths relative to spack * Canonicalize external package paths so that users may specify their locations relative to spack's directory. * Update tests to use new external_path and external properly. * skip license hooks on external
Fixes spack#4026 spack#1167 updated Database.reindex to keep old installation records to support external packages. However, when a user manually removes a prefix and reindexes this kept the records so the packages were still installed according to "spack find" etc. This adds a check for non-external packages to ensure they are properly installed according to the directory layout.
* treats correctly a change from `explicit=False` to `explicit=True` in an external package DB entry. * added unit tests * fixed issues raised by @tgamblin . In particular the PR is no more hash-changing for packages that are not external. * added a test to check correctness of a spec/yaml round-trip for things that involve an external * Don't find external module path at each step of concretization * it's not necessary.. The paths are retrieved at the end of concretizaion * Don't find replacements for external packages. * Test root of the DAG if external * No reason not to test if the root of the DAG is external when external packages are now first class citizens! * Create `external` property for Spec (for external_path and external_module) * Allow users to specify external package paths relative to spack * Canonicalize external package paths so that users may specify their locations relative to spack's directory. * Update tests to use new external_path and external properly. * skip license hooks on external
* Updates the CoreNEURON package to be consistent with the CI * Clean references and configurations to old versions
Modifications
externalto each spec in the DB entryfixes #1066