Skip to content

Spack Chain#8014

Closed
amundson wants to merge 36 commits intospack:developfrom
amundson:develop-chain
Closed

Spack Chain#8014
amundson wants to merge 36 commits intospack:developfrom
amundson:develop-chain

Conversation

@amundson
Copy link
Copy Markdown

@amundson amundson commented May 3, 2018

Note: This pull request is being presented for discussion. At the very least, testing and documentation are required before it can be accepted.

Spack Chain

Spack Chain implements a chain of spack install trees.

Use cases:

  • A two-link chain: Packages are provided by a system-level spack
    installation. The user adds packages to his/her own private spack
    installation.
  • A three-link chain: Same as above, but with a group-level installation
    in between the user and system.
  • Another three-link chain: Same as the two-link chain, but with an
    additional development area.
  • An n-link chain: Madness may ensue. Use with caution.

Defining the chain:

  • The chain is defined in config.yaml:
 config:
    chain_prefixes:
      - /Users/amundson/work/projects/spack-chain/systemlike
      - /Users/amundson/work/projects/spack-chain/userlike

  • The precedence is bottom-first -- userlike is searched before
    systemlike.
  • The current spack instance is implicitly at the end of the chain.
  • If the current spack instance is part of the chain, the chain is
    truncated at the current instance.

Demo:

This demonstration uses my toy repo:
[email protected]:amundsonfnal/metasynrepo.git
To use it, do:

git clone [email protected]:amundsonfnal/metasynrepo.git
cd metasynrepo
spack repo add metasynrepo `pwd`

It contains three packages, corge, which depends on quux, which depends
on garply.

Edit config.yaml to look like the example above.

session 1:

git clone [email protected]:amundson/spack.git systemlike
cd systemlike
git checkout develop-chain
. share/spack/setup-env.sh
spack install garply
|zlorfik>spack find
==> 5 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]  [email protected]  [email protected]  [email protected]  [email protected]

session 2:

git clone [email protected]:amundson/spack.git userlike
cd userlike
git checkout develop-chain
. share/spack/setup-env.sh
spack install quux
|zlorfik>spack find
==> In /home/amundson/work/projects/spack-chain/systemlike/opt/spack:
==> 5 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]  [email protected]  [email protected]  [email protected]  [email protected]
==> In /home/amundson/work/projects/spack-chain/userlike/opt/spack:
==> 1 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]

session 3:

git clone [email protected]:amundson/spack.git devlike
cd devlike
git checkout develop-chain
. share/spack/setup-env.sh
spack install corge
|zlorfik>spack find
==> In /home/amundson/work/projects/spack-chain/systemlike/opt/spack:
==> 5 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]  [email protected]  [email protected]  [email protected]  [email protected]
==> In /home/amundson/work/projects/spack-chain/userlike/opt/spack:
==> 1 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]
==> In /home/amundson/work/projects/spack-chain/devlike/opt/spack:
==> 4 installed packages.
-- linux-rhel7-x86_64 / [email protected] -------------------------------
[email protected]  [email protected]  [email protected]  [email protected]

@becker33
Copy link
Copy Markdown
Member

becker33 commented May 3, 2018

@amundson I'm trying to start thinking through the corner cases of this.

I think this will need some special handling for extendable packages. Extendable packages we need to be able to write to their prefix to activate extensions, and we can't guarantee that a spack instance can write to locations in an instance with which it is chained.

The obvious answer is symlinks from the extendable package to its prefix in the local spack instance, but I don't think that will work. Packages like python get their location at compile time and need the extensions to be there.

My current thought is that we will need to add some sort of local flag to database queries, and when local=False only include non-extendable packages in the query. Interestingly enough, I think this won't be a problem for extensions, even if they are non-local and extend a local packages.

@adamjstewart adamjstewart added the feature A feature is missing in Spack label May 3, 2018
@citibeth
Copy link
Copy Markdown
Member

citibeth commented May 3, 2018

@amundson Can you please look at #642 and see if there's anything additional to be gleaned from it?

The Spack Server idea is described at #3156. @becker33 suggests that Shared Spack, which we have today, does mostly the same thing.

@healther
Copy link
Copy Markdown
Contributor

healther commented May 4, 2018

Without having read it in detail, this seems to be similar to spack stack

(EDIT: which can be found at #7081)

@citibeth
Copy link
Copy Markdown
Member

citibeth commented May 5, 2018

Without having read it in detail, this seems to be similar to spack stack

@obreitwi @amundson
Now I'm confused... what's the difference between Spack Stack and Spack Chain?

@obreitwi
Copy link
Copy Markdown
Member

obreitwi commented May 5, 2018

Now I'm confused... what's the difference between Spack Stack and Spack Chain?
Judging from five minutes of investigation spack stack and spack chain seem to be two solutions to essentially the same problem:

  • spack stack symlinks all currently installed packages from another spack installation into the current one, allowing packages to be built against pre-built packages from a system-wide repository. This is helpful if you want to test changes to spack in a local context or need extra packages on top of our rather large system-wide install.
  • spack chain, from what I can tell, seems to achieve the same by actually submitting db.querys to the package databases in several spack repositories instead of symlinking. A package is first checked for in the local repository, then in the next entry in the chain and so on. This should allow newly-installed packages to be found automatically (you need to re-stack for that). I did not check if spack chain works in all cases (e.g., if some parts of the spack codebase still implicitly expect one global database).

@citibeth
Copy link
Copy Markdown
Member

citibeth commented May 5, 2018

It sounds like these two features are quite similar. And that Spack Chain can do some thing sthat Spack Stack cannot. @obreitwi Can you think of use cases that Stack Spack would be good for but not Spack Chain? Or is there a way to combine the functionality of the two features into one? I think we should try to avoid maintaining multiple features that do similar things in slightly different ways.

@becker33
Copy link
Copy Markdown
Member

becker33 commented May 9, 2018

@obreitwi I think that spack chain and spack stack are different implementations of the same feature. I happen to prefer the implementation in this PR, for a couple of reasons. One, this will know when a package "upstream" is uninstalled, rather than leaving broken symlinks. Second, some packages do not behave well when symlinked.

@citibeth
Copy link
Copy Markdown
Member

@obreitwi If spack stack were removed and replaced with spack chain, would it work for you?

@amundson
Copy link
Copy Markdown
Author

I haven't had much to add to this conversation because I see others recognizing the advantages of the chain approach. However, I think there is one advantage over the stack approach that has not yet been discussed. Can you tell which package came from which repository in Spack Stack? In my chain PR the spack find command has been modified to list the packages in each chained repository separately.

@obreitwi
Copy link
Copy Markdown
Member

obreitwi commented May 10, 2018

@obreitwi If spack stack were removed and replaced with spack chain, would it work for you?

Yes, absolutely. spack stack was just a quick and easy fix to built packages on top of another. spack chain seems much better integrated in the given spack workflow.

Plus: In the meantime our approach of stacking spack repositories has shifted from spack stack to building spack in singularity containers onto which each user can add his own overlay if he so desires.

Therefore dropping spack stack is absolutely fine!

@tgamblin
Copy link
Copy Markdown
Member

@amundson, all: I really like this feature. I'll try to do a full review soon. I'd like to get this or something like it integrated.

@obreitwi:

Yes, absolutely. spack stack was just a quick and easy fix to built packages on top of another. spack chain seems much better integrated in the given spack workflow.

Awesome, and thanks for the stack PR, too!

@healther
Copy link
Copy Markdown
Contributor

@amundson FYI with flake8 on your path you can do spack flake8 locally to reproduce Travis' checks. To get flake8 either do a pip install or spack install py-flake8 && spack activate py-flake8

@amundson
Copy link
Copy Markdown
Author

amundson commented May 15, 2018 via email

@luigi-calori
Copy link
Copy Markdown
Contributor

I would be interested in testing this PR, currently there are conflicts.
Would it be possible to rebase onto current dev?
Thanks a lot in advance

@luigi-calori
Copy link
Copy Markdown
Contributor

luigi-calori commented Jun 14, 2018

Ping @amundson @tgamblin @citibeth @alalazo Any hints on when this feature can be tested and which is best approach to overlay spack installations in multiuser environment
Thanks in advance

gartung and others added 3 commits June 21, 2018 12:10
Conflicts:
	lib/spack/spack/cmd/find.py
	lib/spack/spack/modules/common.py
	lib/spack/spack/store.py
	share/spack/setup-env.sh
@paul-chelarescu
Copy link
Copy Markdown
Contributor

My assumption with this feature is that inside userlike, running spack install with a package that already exists inside systemlike should link the installation from there instead of building the package again. I configure systemlike following the above and install a package, then configure userlike to see the packages inside systemlike by adding to chain_prefixes inside etc/spack/defaults/config.yaml. Now running spack find inside userlike lists the package from systemlike as well. Then I run spack install inside userlike with a package that has a dependency on the package that exists already inside systemlike. I expect spack to display a different behavior than when installing from scratch and link the dependency from systemlike. However, spack will download and build the dependency again inside userlike.

Am I misunderstanding the usage of this feature? It should guard against having duplicate packages in different environments like systemlike and userlike, however I have not managed to replicate this behavior. I have used the latest version of this branch and I have also tried to checkout the version from May the 3rd with no success. I am testing using pkgconfig and ncurses, the latter depends on the former.

@scheibelp
Copy link
Copy Markdown
Member

I expect spack to display a different behavior than when installing from scratch and link the dependency from systemlike. However, spack will download and build the dependency again inside userlike.

@paul-chelarescu my understanding from reading through the PR is that it intends to support this. It may be useful to include the paths for all the Spack installations you are testing with, and the contents of your configuration files if possible.

@amundson @gartung I've started looking at this, would you want to chat about it during the Thursday telcon on 6/28?

@gartung
Copy link
Copy Markdown
Member

gartung commented Jun 27, 2018

@paul-chelarescu Try out #8545

@paul-chelarescu
Copy link
Copy Markdown
Contributor

@gartung I am having the same result with that PR as well.

@gartung
Copy link
Copy Markdown
Member

gartung commented Jun 27, 2018

I see the problem. The system-like db is not being linked into the user-like db. When I try linking them I end up with infinite recursions that I am trying to debug.

@gartung
Copy link
Copy Markdown
Member

gartung commented Jun 27, 2018

@scheibelp @tgamblin This PR is broken since commit f202198 was merged. Since then I am unable to find a way to add the parent database without infinite recursion.

@scheibelp
Copy link
Copy Markdown
Member

I wanted to make sure: should we continue conversation in #8545 or here?

@gartung
Copy link
Copy Markdown
Member

gartung commented Jun 27, 2018

We should move the discussion to #8545
I am updating this for Jim while he is away on vacation so I can't merge my branch into his.

@gartung
Copy link
Copy Markdown
Member

gartung commented Jun 27, 2018

@paul-chelarescu Can you try #8545 again

@paul-chelarescu
Copy link
Copy Markdown
Contributor

@gartung I have and I am still getting the same behavior. Spack does not use the dependencies inside systemlike and instead is building them again. I have added both systemlike and userlike paths to chain_prefixes.

@amundson
Copy link
Copy Markdown
Author

amundson commented Nov 1, 2018

The spack chain configuration has been reworked in
#8772
so I am closing this pull request.

@amundson amundson closed this Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature is missing in Spack

Projects

None yet

Development

Successfully merging this pull request may close these issues.