Skip to content

remove activate/deactivate support in favor of environments#29317

Merged
tgamblin merged 1 commit intospack:developfrom
haampie:remove/activate-deactivate-extensions
Nov 11, 2022
Merged

remove activate/deactivate support in favor of environments#29317
tgamblin merged 1 commit intospack:developfrom
haampie:remove/activate-deactivate-extensions

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Mar 3, 2022

Environments and environment views have taken over the role of spack activate/deactivate, and we should deprecate these commands for several reasons:

  • Global activation is a really poor idea:
    • Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
    • Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
  • Environment accomplish the same thing for non-global "activation" i.e. spack view, but better.

Also we write in the docs:

However, Spack global activations have two potential drawbacks:

#. Activated packages that involve compiled C extensions may still
   need their dependencies to be loaded manually.  For example,
   ``spack load openblas`` might be required to make ``py-numpy``
   work.

#. Global activations "break" a core feature of Spack, which is that
   multiple versions of a package can co-exist side-by-side.  For example,
   suppose you wish to run a Python package in two different
   environments but the same basic Python --- one with
   ``[email protected]`` and one with ``[email protected]``.  Spack extensions
   will not support this potential debugging use case.

Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.

@haampie haampie force-pushed the remove/activate-deactivate-extensions branch from acf7d31 to 9f20412 Compare March 3, 2022 15:28
@spackbot-app spackbot-app bot added commands directives documentation Improvements or additions to documentation python tests General test capability(ies) update-package labels Mar 3, 2022
@haampie haampie force-pushed the remove/activate-deactivate-extensions branch from 9f20412 to 55a12b6 Compare March 3, 2022 15:29
@psakievich
Copy link
Copy Markdown
Contributor

I didn't even know this existed. Probably not a good sign. I think the legacy behavior of a global spack database is definitely prone to confusion and error. Environments are a much cleaner interface

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 3, 2022

the legacy behavior of a global spack database

@psakievich: Can you elaboration this? activation actually isn't handled in the DB (bookkeeping is slightly worse than that -- it's in $prefix/.spack), and the DB is used by environments.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 3, 2022

I'm in favor of this. @lee218llnl at LLNL currently uses activation to deploy LLNL python environments, and activation behavior is actually different from linking into an env.

Last I talked to @lee218llnl, the thing we need to remove reliance on this feature is to allow for only extendees (i.e. just the python packages) to be linked into the python env, not their non-extension dependencies. @lee218llnl will have to remind me why they want that, but I believe it makes it easier for consumers of the deployed python installation to avoid conflicts.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 3, 2022

I think all it would take to implement this is a new linking option for views -- we currently have link: all and link: roots - we would want something like link: extensions and maybe allow that to be combined with roots, e.g., link: [roots, extensions]

@psakievich
Copy link
Copy Markdown
Contributor

@tgamblin I was referring to the difference between spack environments which give a constrained version of all the installed packages that reside in the database vs something like activate which is unconstrained and can see the entire database. Akin to the problems with using global variables instead of passing by reference into functions in C++ speak. My original comment was not well stated.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 3, 2022

something like activate which is unconstrained and can see the entire database

I think a better way to say this is that you end up polluting your python package, and it's hard for other things to cleanly depend on it, as the DB (by which I mean the thing in $install_tree_root/.spack-db/index.json) isn't actually affected by this at all.

Users at LLNL run into this problem, e.g. with pre-activated versions of packages that are frequently used by the codes. I think as others have said that it makes a lot of sense to instead have environments (that maybe users can load with named modules if they don't want to use spack directly), as that'll keep the python install clean and also allow people to use facility provided python envs.

@psakievich
Copy link
Copy Markdown
Contributor

@tgamblin thanks for keeping me honest! I always learn something with your clarifications. As a non-user of this feature I'm pretty ignorant of the bugs people experience with it.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 4, 2022

I'm in favor of this.

Happy to hear that!

the thing we need to remove reliance on this feature is to allow for only extendees (i.e. just the python packages) to be linked into the python env, not their non-extension dependencies.

I don't understand this. In my view (lol) it would make sense to replace activate with something like this:

spack:
  view: my_view
  concretization: together
  specs:
  - python@:x.y
  - py-pkg-a
  - py-pkg-b

and then have the option to include just transitive run/link type deps in the environment view. Currently environment view include too much, but putting only some "extendees" in there... seems too little.

(Also, it would not hurt to only include transitive link + run type deps in the environment view only by default, right? Given that spack env activate only sets runtime variables for those packages anyways...)


Also I talked to @becker33 about views, and since environment views have moved away from mutable views (add specs, remove specs from same folder) to a fully new view on every update and an "atomic" symlink change, once we get this change in, a lot of the complexity due to unmerge can be dropped as well. In fact copy_tree(src, dst), install_tree(src, dst) and merge(src, dst) would all no longer need to be reversible. That would also simplify how packages deal with changes to the view (i mean add_files_to_view), since they no longer have to undo their changes in remove_files_from_view. And on top of that, we could optimize view creation quite a bit, by making it a proper single pass over the installed spec prefixes, fastly reducing the number of file system operations (sometimes on lustre fs spack is beyond slow for me...).

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 4, 2022

Currently environment view include too much, but putting only some "extendees" in there... seems too little.

I think this is the point, to only add enough to find the python packages' .py dependencies in site-packages, but rely only on RPATH for the libs they depend on. @lee218llnl should probably comment on why he wants this and what would break if we link only link/run deps.

I think link: extendees should probably imply roots and just be a third option on top of roots and all (as I don't see why you ever don't want to link your roots).

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 4, 2022

Currently environment view include too much

Actually wrong about this, what environments do right now is the sensible thing, they only include transitive run/link time deps by default (when link: all).

to only add enough to find the python packages' .py dependencies in site-packages, but rely only on RPATH for the libs they depend on

Is it too much to ask to just list them all in spack:specs:[py-a, py-b] and use link: roots? That doesn't require new functionality.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 4, 2022

Is it too much to ask to just list them all in spack:specs:[py-a, py-b] and use link: roots? That doesn't require new functionality.

I mean, I think this is the sort of annoying thing that you might submit an issue about in the future. I don't think we should expect the user to know which dependencies are also extendees (esp since that can change on re-concretization).

I think this ends up being a fairly simple change in ViewDescriptor.specs_for_view()

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 4, 2022

I think this ends up being a fairly simple change in ViewDescriptor.specs_for_view()

Sure, I think it can be done in a separate PR though.

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 4, 2022

Sure, I think it can be done in a separate PR though.

Sure, but seeing as how without it, this PR will break functionality, that PR will need to happen first.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 4, 2022

I think it's easier to just do link: run to be honest. It's exactly what's requested (no link type deps cause rpaths are enough). It's more generic and more useful, and accomplishes roughly the same.

In [1]: def filter_extensions(s): 
    ...:     return [x.name for x in s.traverse(deptype=('run', 'link')) if x.package.extends(s['python'])] 

In [2]: s = Spec('py-flake8').concretized()                                                                                                                                                                                                                                              

In [3]: filter_extensions(s)                                                                                                                                                                                                                                                                        
Out[3]: ['py-flake8', 'py-mccabe', 'py-pycodestyle', 'py-setuptools', 'py-pyflakes']

In [4]: [x.name for x in s.traverse(deptype=('run'))]                                                                                                                                                                                                                                    
Out[4]: ['py-flake8', 'py-mccabe', 'python', 'py-pycodestyle', 'py-setuptools', 'py-pyflakes']

@lee218llnl
Copy link
Copy Markdown
Contributor

Sorry to chime in late. I think Todd accurately captured my use case for Python and its extensions at LLNL. The activate feature was designed largely based on the requirements I had for building Python at LLNL. In particular, we want to provide a Python with a set of site-packages that many of our users require. For specifics, you can see what we have installed at https://hpc.llnl.gov/software/development-environment-software/python/python-site-packages.

Spack provides a convenient way for me to build all of this, as I used to manually install everything. However, we don't want users to be bound to this Spack instance and all of the dependent packages that were built to get the desired Python + site-packages. We do not want users to see the dependent packages that were required to build Python when they point their $PATH to wherever the python binary lives. Currently this works as desired, because the only things in the Python bin directory are python itself and all of the bin dirs that were linked upon activation. The problem with a view that includes dependences is that it would include things like HDF5 and we don't want users using that HDF5 instance, as we have separate HDF5 installations that we expect users to use.

Does this all make sense? In short, we want a standalone Python with many site-packages that does not otherwise affect a user's expected build environment. I agree with Todd that we don't want to break functionality, even if a future PR will address this.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 4, 2022

Can you try #29336? I'm reasonably sure it will be equivalent to what you have currently

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Mar 9, 2022

Ok, #29336 is in, but I'm reminded that we need to actually deprecate these things for a version before we remove them. So we need a PR for 0.18 that will deprecate them (print a warning) and then this one can go into 0.19. I personally am a little more excited to get rid fo these than that, but I think the policy is a good one and we should probably stick with it.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 9, 2022

Ok, so basically merge a deprecation warning right now, and then merge this PR as soon as 0.18 is branched off?

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Mar 10, 2022

See #29430

@tgamblin tgamblin force-pushed the remove/activate-deactivate-extensions branch from 55a12b6 to f44fbe0 Compare November 11, 2022 07:28
@spackbot-app spackbot-app bot added the core PR affects Spack core functionality label Nov 11, 2022
@tgamblin tgamblin force-pushed the remove/activate-deactivate-extensions branch from f44fbe0 to f5a5101 Compare November 11, 2022 07:31
@tgamblin tgamblin merged commit 0f54a63 into spack:develop Nov 11, 2022
@haampie haampie deleted the remove/activate-deactivate-extensions branch November 11, 2022 09:51
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this pull request Nov 11, 2022
)

Environments and environment views have taken over the role of `spack activate/deactivate`, and we should deprecate these commands for several reasons:

- Global activation is a really poor idea:
   - Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
   - Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
- Environment accomplish the same thing for non-global "activation" i.e. `spack view`, but better.

Also we write in the docs:

```
However, Spack global activations have two potential drawbacks:

#. Activated packages that involve compiled C extensions may still
   need their dependencies to be loaded manually.  For example,
   ``spack load openblas`` might be required to make ``py-numpy``
   work.

#. Global activations "break" a core feature of Spack, which is that
   multiple versions of a package can co-exist side-by-side.  For example,
   suppose you wish to run a Python package in two different
   environments but the same basic Python --- one with
   ``[email protected]`` and one with ``[email protected]``.  Spack extensions
   will not support this potential debugging use case.
```

Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.
@w8jcik
Copy link
Copy Markdown
Contributor

w8jcik commented Nov 11, 2022

The latest commit from this pull request 0f54a63 leads to following error

==> Installing py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb
==> No binary for py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb found: installing from source
==> Fetching https://files.pythonhosted.org/packages/py3/p/pip/pip-22.1.2-py3-none-any.whl
==> No patches needed for py-pip
==> py-pip: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 3:
    '/home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/python-3.10.8-jvnzph3dkezyy4wuhpkizc2wstsz6ady/bin/python3.10' '/tmp/w8jcik/spack-stage/spack-stage-py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb/spack-src/pip-22.1.2-py3-none-any.whl/pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb' '/tmp/w8jcik/spack-stage/spack-stage-py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb/spack-src/pip-22.1.2-py3-none-any.whl'
See build log for details:
  /tmp/w8jcik/spack-stage/spack-stage-py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb/spack-build-out.txt

==> Warning: Skipping build of py-wheel-0.37.1-ve776ncej6jpdpwo2b7hvrp4yiv3pe32 since py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb failed
==> Warning: Skipping build of py-fypp-2.1.1-rxv5ni2n4nqocwlzjjzvgjfdhoug3ez2 since py-wheel-0.37.1-ve776ncej6jpdpwo2b7hvrp4yiv3pe32 failed
==> Warning: Skipping build of dbcsr-2.3.0-5zbyadjy7zh3ioes5cfmrafsbyytnxlc since py-fypp-2.1.1-rxv5ni2n4nqocwlzjjzvgjfdhoug3ez2 failed
==> Warning: Skipping build of gromacs-2022.3-iq7pdlojjzq2wrw26gqdvkbgw7lu4hsp since dbcsr-2.3.0-5zbyadjy7zh3ioes5cfmrafsbyytnxlc failed
==> Warning: Skipping build of py-setuptools-65.5.0-rtvhiwlr4trdl6qtsmfvwovlle7zm6x3 since py-pip-22.1.2-ujwdlgyszzcq3wjl6ak7grantbvi3qjb failed
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/libxsmm-1.17-j3o4sjbffxsk2wvr7pohdhl74r4nc7yf
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/openssh-9.1p1-i65xda7z7wqi5m4w5x2oyxux6kb7sr26
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/numactl-2.0.14-7msklijudxnnfhh5rbnqw2l7kesq47p5
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/gmp-6.2.1-jjkok4vnnv3qwhykkdbhk6z5aehkumzp
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/openmpi-4.1.4-isaz57vhlpybiqn5lpd6h65smt53xei4
[+] /home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/libint-2.6.0-yxbc3c3psmru7ejk44cd7kciszd6ityr
==> py-pip: Executing phase: 'install'
==> [2022-11-11-16:36:16.441740] '/home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/python-3.10.8-jvnzph3dkezyy4wuhpkizc2wstsz6ady/bin/python3.10' '/tmp/w8jcik/spack-stage/spack-stage-py-pip-22.2.2-w2cxn4k77gqv5yxesbkmp5loey3gz62f/spack-src/pip-22.2.2-py3-none-any.whl/pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/home/global/group-jh/shared-spack/0.18.1/root/opt/spack/linux-arch-zen2/gcc-12.2.0/py-pip-22.2.2-w2cxn4k77gqv5yxesbkmp5loey3gz62f' '/tmp/w8jcik/spack-stage/spack-stage-py-pip-22.2.2-w2cxn4k77gqv5yxesbkmp5loey3gz62f/spack-src/pip-22.2.2-py3-none-any.whl'
ERROR: Could not find an activated virtualenv (required).

If I go one commit back, it is fine. Something might be wrong with my setup of course, but it is fresh Spack installation.

@w8jcik
Copy link
Copy Markdown
Contributor

w8jcik commented Nov 11, 2022

Actually, forget it. The issue is there, but it is not coming from this pull request. Sorry for bothering you.

charmoniumQ pushed a commit to charmoniumQ/spack that referenced this pull request Nov 19, 2022
)

Environments and environment views have taken over the role of `spack activate/deactivate`, and we should deprecate these commands for several reasons:

- Global activation is a really poor idea:
   - Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
   - Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
- Environment accomplish the same thing for non-global "activation" i.e. `spack view`, but better.

Also we write in the docs:

```
However, Spack global activations have two potential drawbacks:

#. Activated packages that involve compiled C extensions may still
   need their dependencies to be loaded manually.  For example,
   ``spack load openblas`` might be required to make ``py-numpy``
   work.

#. Global activations "break" a core feature of Spack, which is that
   multiple versions of a package can co-exist side-by-side.  For example,
   suppose you wish to run a Python package in two different
   environments but the same basic Python --- one with
   ``[email protected]`` and one with ``[email protected]``.  Spack extensions
   will not support this potential debugging use case.
```

Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this pull request Feb 16, 2023
)

Environments and environment views have taken over the role of `spack activate/deactivate`, and we should deprecate these commands for several reasons:

- Global activation is a really poor idea:
   - Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
   - Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
- Environment accomplish the same thing for non-global "activation" i.e. `spack view`, but better.

Also we write in the docs:

```
However, Spack global activations have two potential drawbacks:

#. Activated packages that involve compiled C extensions may still
   need their dependencies to be loaded manually.  For example,
   ``spack load openblas`` might be required to make ``py-numpy``
   work.

#. Global activations "break" a core feature of Spack, which is that
   multiple versions of a package can co-exist side-by-side.  For example,
   suppose you wish to run a Python package in two different
   environments but the same basic Python --- one with
   ``[email protected]`` and one with ``[email protected]``.  Spack extensions
   will not support this potential debugging use case.
```

Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.
tgamblin pushed a commit that referenced this pull request Mar 20, 2023
The `ignore` parameter was only used for `spack activate/deactivate`, and it isn't used
by Spack Environments which have their own handling of file conflicts. We should remove it.

Everything that handles `ignore=` was removed in #29317 and included in 0.19, when we
removed `spack activate` and `spack deactivate` in favor of environments.  So all of these
usages removed here were already being ignored by Spack.
tgamblin added a commit that referenced this pull request Oct 2, 2023
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
tgamblin added a commit that referenced this pull request Oct 30, 2023
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
tgamblin added a commit that referenced this pull request Nov 10, 2023
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
tgamblin added a commit that referenced this pull request Jan 2, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
tgamblin added a commit that referenced this pull request Jan 3, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
tgamblin added a commit that referenced this pull request Jan 3, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
alalazo pushed a commit that referenced this pull request Jan 4, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in #29317 and #35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 25, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in spack#29317 and spack#35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 31, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in spack#29317 and spack#35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
kwryankrattiger pushed a commit to kwryankrattiger/spack that referenced this pull request Jul 9, 2024
This method is vestigial; the only arg we ever used was `ignore=`, and that was
eliminated in spack#29317 and spack#35588.

The `kwargs` field of the extensions dictionary is actually completely unused now. Add a
note for future removal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality directives documentation Improvements or additions to documentation python tests General test capability(ies) update-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants