Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install: Add use-buildcache option to install #32537

Merged
merged 10 commits into from
Sep 29, 2022

Conversation

kwryankrattiger
Copy link
Contributor

@kwryankrattiger kwryankrattiger commented Sep 6, 2022

Allow differentiating between top level packages and dependencies when determining whether to install from the cache or not.

@scottwittenburg

Implements this feature request.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality labels Sep 6, 2022
@kwryankrattiger
Copy link
Contributor Author

@spackbot fix style

@spackbot-app
Copy link

spackbot-app bot commented Sep 7, 2022

Let me see if I can fix that for you!

@spackbot-app
Copy link

spackbot-app bot commented Sep 7, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  lib/spack/spack/cmd/install.py
  lib/spack/spack/installer.py
==> Running isort checks
Fixing /tmp/tmpvw9rga1h/spack/lib/spack/spack/cmd/install.py
  isort checks were clean
==> Running mypy checks
Success: no issues found in 558 source files
  mypy checks were clean
==> Running black checks
reformatted lib/spack/spack/cmd/install.py
All done! ✨ 🍰 ✨
1 file reformatted, 1 file left unchanged.
  black checks were clean
==> Running flake8 checks
lib/spack/spack/cmd/install.py:44: [E713] test for membership should be 'not in'
lib/spack/spack/cmd/install.py:47: [E501] line too long (123 > 99 characters)
  flake8 found errors
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

@kwryankrattiger kwryankrattiger force-pushed the install_use_buildcache branch 2 times, most recently from 5599f4d to f096067 Compare September 8, 2022 15:53
@spackbot-app spackbot-app bot added the tests General test capability(ies) label Sep 9, 2022
@scottwittenburg
Copy link
Contributor

scottwittenburg commented Sep 9, 2022

@kwryankrattiger Can you rebase this on the latest develop and force-push? I'm hoping it will then get past the failing checks we're seeing currently.

@alalazo alalazo added this to In progress in Spack v0.19.0 release via automation Sep 12, 2022
@scottwittenburg
Copy link
Contributor

@spackbot fix style

@spackbot-app
Copy link

spackbot-app bot commented Sep 12, 2022

Let me see if I can fix that for you!

@spackbot-app
Copy link

spackbot-app bot commented Sep 12, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  lib/spack/spack/cmd/install.py
  lib/spack/spack/installer.py
  lib/spack/spack/test/cmd/install.py
==> Running isort checks
Fixing /tmp/tmpm_1rhp_4/spack/lib/spack/spack/test/cmd/install.py
  isort checks were clean
==> Running mypy checks
Success: no issues found in 558 source files
  mypy checks were clean
==> Running black checks
reformatted lib/spack/spack/test/cmd/install.py
All done! ✨ 🍰 ✨
1 file reformatted, 2 files left unchanged.
  black checks were clean
==> Running flake8 checks
  flake8 checks were clean
==> spack style checks were clean
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

Copy link
Contributor

@scottwittenburg scottwittenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kwryankrattiger,! This is looking pretty good, but I left a comment or two to to be addressed, along with a question about how the shorthand is intended to work.

Also, could you provide a brief description of the change? Even just a pointer to the issue this addresses could help other reviewers know what they're looking at

lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
Spack v0.19.0 release automation moved this from In progress to Review in progress Sep 12, 2022
@scottwittenburg
Copy link
Contributor

I don't mind running the style fix for you, but you should at least pull the changes and incorporate them before you force push again 😜

@scottwittenburg
Copy link
Contributor

@spackbot fix style

@spackbot-app
Copy link

spackbot-app bot commented Sep 13, 2022

Let me see if I can fix that for you!

@spackbot-app
Copy link

spackbot-app bot commented Sep 13, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  lib/spack/spack/cmd/install.py
  lib/spack/spack/installer.py
  lib/spack/spack/test/cmd/install.py
==> Running isort checks
Fixing /tmp/tmpnyy9ct46/spack/lib/spack/spack/test/cmd/install.py
  isort checks were clean
==> Running mypy checks
Success: no issues found in 558 source files
  mypy checks were clean
==> Running black checks
reformatted lib/spack/spack/test/cmd/install.py
All done! ✨ 🍰 ✨
1 file reformatted, 2 files left unchanged.
  black checks were clean
==> Running flake8 checks
  flake8 checks were clean
==> spack style checks were clean
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

@kwryankrattiger kwryankrattiger force-pushed the install_use_buildcache branch 2 times, most recently from 4ac37c4 to 54634f4 Compare September 14, 2022 21:24
Copy link
Contributor

@scottwittenburg scottwittenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting closer, thanks @kwryankrattiger! It's working for my particular use case (must install deps from buildcache, never install package from buildcache), but I have a couple requests regarding the UI.

Also, it looks like some unit tests failed, which this may or may not have caused. Can you check if those failures are reproducible on your end?

lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
lib/spack/spack/cmd/install.py Outdated Show resolved Hide resolved
@kwryankrattiger kwryankrattiger force-pushed the install_use_buildcache branch 3 times, most recently from ce3d3c7 to eae2b08 Compare September 15, 2022 01:17
@scottwittenburg
Copy link
Contributor

By the way, in my pipelines testing "rebuild everything", this PR is working as expected. @tgamblin was going to provide some insight on a better way, within the installer.py module, to distinguish dependencies from package. But from my perspective, @kwryankrattiger figured that out in a way that seems reasonable to me. So I'd be happy to accept this as-is, once the tests are passing.

@alalazo
Copy link
Member

alalazo commented Sep 22, 2022

We used to split it in two, but it complicated the ci module even more, as we had to make a copy of the spack.yaml before the first install, then use it to replace the version that spack clobbered before the next spack install.

I don't think I get what you're describing above, which might be due to me being unfamiliar with ci.py and cmd/ci.py. Isn't this:

spack/lib/spack/spack/ci.py

Lines 1985 to 2005 in 0ddbb92

def process_command(cmd, cmd_args, repro_dir):
"""
Create a script for and run the command. Copy the script to the
reproducibility directory.
Arguments:
cmd (str): name of the command being processed
cmd_args (list): string arguments to pass to the command
repro_dir (str): Job reproducibility directory
Returns: the exit code from processing the command
"""
tty.debug("spack {0} arguments: {1}".format(cmd, cmd_args))
# Write the command to a shell script
script = "{0}.sh".format(cmd)
with open(script, "w") as fd:
fd.write("#!/bin/bash\n\n")
fd.write("\n# spack {0} command\n".format(cmd))
fd.write(" ".join(['"{0}"'.format(i) for i in cmd_args]))
fd.write("\n")

the only part that eventually need to change? Based on the example above wouldn't it suffice to generate something similar to:

#!/bin/bash


# spack install command
"spack" "-d" "-v" "install" "--cache-only" "--only=dependencies" "--no-add" "-f" "/builds/spack/spack/jobs_scratch_dir/reproduction/unifyfs.json"
"spack" "-d" "-v" "install" "--show-log-on-error" "--no-cache" "--only=package" "--keep-stage" "--no-check-signature" "--cdash-upload-url" "https://cdash.spack.io/submit.php?project=Spack+Testing" "--cdash-build" "unifyfs@1.0%oneapi@2022.1.0 hash=36ftnpast6yvr3zawwnrcgxn5ao3t5zs arch=linux-ubuntu20.04-x86_64 (E4S OneAPI)" "--cdash-site" "Cloud Gitlab Infrastructure (uo-pegasus)" "--cdash-buildstamp" "20220919-0545-E4S OneAPI" "--no-add" "-f" "/builds/spack/spack/jobs_scratch_dir/reproduction/unifyfs.json"

?

@scottwittenburg
Copy link
Contributor

That might work, without having to make a backup copy of the environment and restore it between the installs, now that we have the --no-add option. However, I would need to go back and make sure there wasn't some additional problem with the "two spack installs" approach.

Allow differentiating between top level packages and dependencies when
determining whether to install from the cache or not.
A requested package is not required to be "explicit"ly requested
when specifying --only package or --use-buildcache package:<...>
options in install. Add a task property that returns the former.
Copy link
Contributor

@scottwittenburg scottwittenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with the other proposed changes we need for asking spackbot to rebuild everything, and it's working.

Spack v0.19.0 release automation moved this from Review in progress to Reviewer approved Sep 28, 2022
@kwryankrattiger kwryankrattiger merged commit a01c36d into spack:develop Sep 29, 2022
Spack v0.19.0 release automation moved this from Reviewer approved to Done Sep 29, 2022
Copy link
Member

@haampie haampie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you're missing

diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 7ec31f0267..1ec21be45d 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -2391,7 +2391,7 @@ def get_deptypes(self, pkg):
         """
         deptypes = ["link", "run"]
         include_build_deps = self.install_args.get("include_build_deps")
-        if not self.install_args.get("cache_only") or include_build_deps:
+        if not self.install_args.get("package_cache_only") or include_build_deps:
             deptypes.append("build")
         if self.run_tests(pkg):
             deptypes.append("test")

an old reference to cache_only, which now causes the installer not to prune redundant build deps.

haampie added a commit to haampie/spack that referenced this pull request Oct 17, 2022
Fixing an oversight in spack#32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.
haampie added a commit to haampie/spack that referenced this pull request Oct 17, 2022
Fixing an oversight in spack#32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.
haampie added a commit to haampie/spack that referenced this pull request Oct 17, 2022
Fixing an oversight in spack#32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.
haampie added a commit that referenced this pull request Oct 17, 2022
Fixing an oversight in #32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.
luke-dt added a commit to dantaslab/spack that referenced this pull request Oct 17, 2022
* py-execnet: 1.9.0 (spack#33282)

* py-execnet: 1.9.0

* bounds

* add version 1.12.3 of parallel-netcdf (spack#33286)

* Add checksum for py-psutil 5.9.2 (spack#33139)

* gitlab ci: Print better information about broken specs (spack#33124)

When a pipeline generation job is automatically failed because it
generated jobs for specs known to be broken on develop, print better
information about the broken specs that were encountered.  Include
at a minimum the hash and the url of the job whose failure caused it
to be put on the broken specs list in the first place.

* meson: remove slash in path (spack#33292)

* Add checksum for py-gitpython 3.1.27 (spack#33285)

* Add checksum for py-gitpython 3.1.27

* Update package.py

* Update var/spack/repos/builtin/packages/py-gitpython/package.py

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

* UPC++/GASNet-EX 2022.9.0 update (spack#33277)

* gasnet: Add new release hash
* upcxx: Add new release hash
* gasnet: misc updates
* upcxx: misc updates

* Fix pika@0.9.0 sha (spack#33307)

* hip@5.2.0 onwards: set prefix properly (spack#33257)

* hip-set-prefix-rocm5.2.0-onwards

* Update var/spack/repos/builtin/packages/hip/package.py

Update description

Co-authored-by: Satish Balay <balay@mcs.anl.gov>

* petsc,py-petsc4py,slepc,py-slepc4py: add version 3.18.0 (spack#32938)

* petsc,py-petsc4py,slepc,py-slepc4py: add version 3.18.0

* workaround for dealii build failure [with petsc version check]

* pism: add compatibility fix to for petsc@3.18

* add in hipsolver dependency

* py-libensemble: updating package for v0.9.3 (spack#33298)

* commit updating py-libensemble package for 0.9.3

* removed commented-out lines

* Add checksum for py-oauthlib 3.2.1 (spack#33201)

* Add checksum for py-oauthlib 3.2.1

* Update package.py

* [@spackbot] updating style on behalf of iarspider

* Update package.py

* Update package.py

Co-authored-by: iarspider <iarspider@users.noreply.github.com>

* ninja: New version 1.11.1 (spack#33215)

* seacas: update to latest release (spack#33330)

Add checksum for latest tag/release

* gptl: new version 8.1.1; use the correct mpi fortran compiler (spack#33235)

* gptl: new version 8.1.1; use the correct `mpifc`
* add `F90` and `$F77`

* glib: add 2.74.0 and 2.72.4 (spack#33332)

* depfile: update docs (spack#33279)

* rocksdb: add 7.7.3 (spack#33341)

* Add checksum for py-seaborn 0.12.0 (spack#33145)

* Add checksum for py-seaborn 0.12.0

* Update package.py

* Update package.py

* [@spackbot] updating style on behalf of iarspider

* Update package.py

Co-authored-by: iarspider <iarspider@users.noreply.github.com>

* CI: allow multiple matches to combine tags (spack#32290)

Currently "spack ci generate" chooses the first matching entry in
gitlab-ci:mappings to fill attributes for a generated build-job,
requiring that the entire configuration matrix is listed out
explicitly. This unfortunately causes significant problems in
environments with large configuration spaces, for example the
environment in spack#31598 (spack.yaml) supports 5 operating systems,
3 architectures and 130 packages with explicit size requirements,
resulting in 1300 lines of configuration YAML.

This patch adds a configuraiton option to the gitlab-ci schema called
"match_behavior"; when it is set to "merge", all matching entries
are applied in order to the final build-job, allowing a few entries
to cover an entire matrix of configurations.

The default for "match_behavior" is "first", which behaves as before
this commit (only the runner attributes of the first match are used).

In addition, match entries may now include a "remove-attributes"
configuration, which allows matches to remove tags that have been
aggregated by prior matches. This only makes sense to use with
"match_behavior:merge". You can combine "runner-attributes" with
"remove-attributes" to effectively override prior tags.

* meson: update OneAPI compiler support patch (spack#33293)

* py-tensorflow: fix zlib (spack#33349)

* py-tensorflow: fix zlib

* [@spackbot] updating style on behalf of haampie

Co-authored-by: haampie <haampie@users.noreply.github.com>

* py-meson-python: add new versions (spack#33294)

* tasmanian: disable openmp by default (spack#33345)

* octopus: upgrade to 12.1 (spack#33343)

* py-sphinx: add v5.3 and v5.2 (spack#33356)

* py-setuptools: add v65.5.0 (spack#33353)

* libblastrampoline: Add versions 5.1.1, 5.2.0 (spack#33352)

* nextflow: add v20.10.0 (spack#33354)

* sdl2: add v2.0.22 and v2.24.1 (spack#33351)

* mariadb-c-client: add 3.3.2, 3.2.7, 3.1.18, 3.0.10 (spack#33335)

* py-tensorflow-hub: zlib, again. (spack#33359)

* Add checksum for py-sniffio 1.3.0 (spack#32975)

* py-numpy: add v1.23.4 (spack#33260)

* py-jupyterlab-pygments: install from wheel to avoid cyclic dependency (spack#33278)

* py-jupyterlab-pygments: avoid cyclic dependency

* Fix style

* Update package.py

* Update package.py

* [@spackbot] updating style on behalf of iarspider

* Update package.py

* Flake-8

* fix

Co-authored-by: iarspider <iarspider@users.noreply.github.com>

* installer.py: show timers for binary install (spack#33305)

Print a message of the form
```
Fetch mm:ss.  Build: mm:ss.  Total: mm:ss
```
when installing from buildcache. 

Previously this only happened for source builds.

* Add checksum for py-astroid 2.12.7, py-astroid 2.12.10, py-setuptools 62.6.0, py-wrapt 1.14.1, py-pylint 2.15.0 (spack#32976)

* Add checksum for py-astroid 2.12.7, py-setuptools 62.6.0

* Also add checksum for py-wrapt

* Update package.py

* Update package.py (spack#57)

* Update package.py

* Update package.py

* Update package.py

* gitlab ci: Do not force protected build jobs to run on aws runners (spack#33314)

* installer.py: fix/test get_deptypes (spack#33363)

Fixing an oversight in spack#32537

`get_deptypes` should depend on new `package/dependencies_cache_only`
props.

* Add checksum for py-grpcio-tools 1.48.1 (spack#33358)

* Add checksum for py-prompt-toolkit 3.0.31 (spack#33362)

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Co-authored-by: Jim Edwards <jedwards@ucar.edu>
Co-authored-by: iarspider <iarspider@gmail.com>
Co-authored-by: Scott Wittenburg <scott.wittenburg@kitware.com>
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
Co-authored-by: Auriane R <48684432+aurianer@users.noreply.github.com>
Co-authored-by: eugeneswalker <38933153+eugeneswalker@users.noreply.github.com>
Co-authored-by: Satish Balay <balay@mcs.anl.gov>
Co-authored-by: John-Luke Navarro <33131245+jlnav@users.noreply.github.com>
Co-authored-by: iarspider <iarspider@users.noreply.github.com>
Co-authored-by: Erik Schnetter <schnetter@gmail.com>
Co-authored-by: Greg Sjaardema <gsjaardema@gmail.com>
Co-authored-by: WuK <i@wu-kan.cn>
Co-authored-by: Michael Kuhn <michael.kuhn@ovgu.de>
Co-authored-by: Jonathon Anderson <17242663+blue42u@users.noreply.github.com>
Co-authored-by: haampie <haampie@users.noreply.github.com>
Co-authored-by: Miroslav Stoyanov <30537612+mkstoyanov@users.noreply.github.com>
Co-authored-by: Hans Fangohr <fangohr@users.noreply.github.com>
Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
Co-authored-by: Diego Alvarez <dialvarezs@gmail.com>
Co-authored-by: Wouter Deconinck <wdconinc@gmail.com>
@kwryankrattiger kwryankrattiger deleted the install_use_buildcache branch November 15, 2022 15:52
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 tests General test capability(ies)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants