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

Missing spec variant in upstream installation leads to KeyError #28188

Open
3 tasks done
nilsvu opened this issue Dec 30, 2021 · 9 comments
Open
3 tasks done

Missing spec variant in upstream installation leads to KeyError #28188

nilsvu opened this issue Dec 30, 2021 · 9 comments
Labels
bug Something isn't working impact-low

Comments

@nilsvu
Copy link
Contributor

nilsvu commented Dec 30, 2021

Steps to reproduce

  • Install openblas in a Spack tree from before OpenBLAS: Add a symbol suffix option #27500
  • Clone a new Spack and set the old Spack install tree as upstream.
  • Install any package that depends on openblas, e.g. py-scipy. Use --reuse or another means to make sure the existing openblas installation is used. I encountered this issue when installing from an environment lockfile, which was created with the new Spack clone but uses the upstream openblas installation. The lockfile doesn't list the new 'symbol_suffix' parameter, which leads to the KeyError below.

Error message

==> Error: KeyError: 'symbol_suffix'

spack/var/spack/repos/builtin/packages/openblas/package.py:353, in libs:
        350        # Look for openblas{symbol_suffix}
        351        name = 'libopenblas'
        352        search_shared = bool(spec.variants['shared'].value)
  >>    353        suffix = spec.variants['symbol_suffix'].value
        354        if suffix != 'none':
        355            name += suffix
        356

Information on your system

  • Spack: 0.17.1-677-c2e1a12cdf
  • Python: 3.8.7
  • Platform: linux-centos7-haswell
  • Concretizer: clingo

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output
@nilsvu nilsvu added bug Something isn't working triage The issue needs to be prioritized labels Dec 30, 2021
@alalazo
Copy link
Member

alalazo commented Mar 16, 2022

This is an issue with the implementation of Openblas.libs, which doesn't handle that case. It should be fixed in openblas.

@alalazo alalazo added this to To do in Spack v0.18.0 release via automation Mar 16, 2022
@alalazo alalazo self-assigned this Mar 16, 2022
@haampie
Copy link
Member

haampie commented Mar 16, 2022

Hm, @alalazo I think in general most packages are written in a way where they assume the variants defined above are usable in methods below. We'd have to communicate/review better that that's not a safe assumption?

@alalazo
Copy link
Member

alalazo commented Mar 16, 2022

The issue is using:

spec.variants['symbol_suffix'].value

directly. In those cases it's better to use get and provide a default.

@haampie
Copy link
Member

haampie commented Mar 16, 2022

Hm, but then we're repeating defaults everywhere.

@alalazo
Copy link
Member

alalazo commented Mar 16, 2022

Hm, but then we're repeating defaults everywhere.

Not variant defaults. I mean something like:

variant = spec.variants.get('symbol_suffix')
if variant is None:
   # Handle the case of the variant being missing.

I actually have an idea for this kind of issues. What if we can run a post-install hook to record the results of the possible calls to libs in a JSON file to be stored under <prefix>/.spack? We can change our protocol to prefer what is hard-coded in the JSON file if it exists.

@alalazo
Copy link
Member

alalazo commented Mar 21, 2022

We discussed this issue last Wed. at the community telco. The outcome is, for the time being, to treat these kind of issues as style issues for packages. See here for the minutes.

@tgamblin tgamblin removed this from To do in Spack v0.18.0 release Jul 7, 2022
@tgamblin tgamblin added this to To do in Spack v0.19.0 release via automation Jul 7, 2022
@anselmic
Copy link

Hello,

I have a similar problem with version 0.19.0.dev0 when installing py-numpy:

==> Installing py-numpy-1.23.4-qnrciem6i4vxx5sayxzuv2zjvfigw7ko
==> No binary for py-numpy-1.23.4-qnrciem6i4vxx5sayxzuv2zjvfigw7ko found: installing from source
==> Error: KeyError: 'symbol_suffix'

/cm/shared/apps/spack/current/var/spack/repos/builtin/packages/openblas/package.py:420, in libs:
        417        # Look for openblas{symbol_suffix}
        418        name = "libopenblas"
        419        search_shared = bool(spec.variants["shared"].value)
  >>    420        suffix = spec.variants["symbol_suffix"].value
        421        if suffix != "none":
        422            name += suffix
        423


It is not clear from the previous discussion if there is a workaround.
Thanks

@alalazo
Copy link
Member

alalazo commented Oct 27, 2022

It is not clear from the previous discussion if there is a workaround.

You can install a new openblas that has the variant. Also, the fix to this is to use get instead of direct access if we want backward compatibility of recipes for spec['openblas'].libs

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 7, 2022
@tgamblin tgamblin removed this from To do in Spack v0.19.0 release Nov 7, 2022
@NessieCanCode
Copy link
Contributor

Hello,

I have a similar problem with version 0.19.0.dev0 when installing py-numpy:

==> Installing py-numpy-1.23.4-qnrciem6i4vxx5sayxzuv2zjvfigw7ko
==> No binary for py-numpy-1.23.4-qnrciem6i4vxx5sayxzuv2zjvfigw7ko found: installing from source
==> Error: KeyError: 'symbol_suffix'

/cm/shared/apps/spack/current/var/spack/repos/builtin/packages/openblas/package.py:420, in libs:
        417        # Look for openblas{symbol_suffix}
        418        name = "libopenblas"
        419        search_shared = bool(spec.variants["shared"].value)
  >>    420        suffix = spec.variants["symbol_suffix"].value
        421        if suffix != "none":
        422            name += suffix
        423

It is not clear from the previous discussion if there is a workaround. Thanks

a quick workaround is: spack install <package_name> ^openblas symbol_suffix=none

@alalazo alalazo removed this from the v0.20.0 milestone May 2, 2023
@alalazo alalazo added the revisit label May 2, 2023
@alalazo alalazo removed their assignment May 30, 2023
@alalazo alalazo added impact-low and removed revisit triage The issue needs to be prioritized labels Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working impact-low
Projects
Status: Todo
Development

No branches or pull requests

6 participants