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

"self.run_tests" attribute masked by the object wrapper #34518

Closed
3 tasks done
alalazo opened this issue Dec 14, 2022 · 4 comments · Fixed by #34531
Closed
3 tasks done

"self.run_tests" attribute masked by the object wrapper #34518

alalazo opened this issue Dec 14, 2022 · 4 comments · Fixed by #34531
Assignees
Labels
bug Something isn't working impact-medium
Milestone

Comments

@alalazo
Copy link
Member

alalazo commented Dec 14, 2022

Steps to reproduce

Originally reported by @rbberger in https://spackpm.slack.com/archives/C5VL7V81G/p1669578286178559

Classes that try to use self.run_tests to set any custom attribute and are not using builders will see this attribute set to False due to the object wrapper.

Error message

No error message, just unexpected behavior.

Information on your system

  • Spack: 0.20.0.dev0 (e030833)
  • Python: 3.8.10
  • Platform: linux-ubuntu20.04-icelake
  • 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
@alalazo alalazo added bug Something isn't working impact-medium labels Dec 14, 2022
@alalazo alalazo added this to the v0.19.1 milestone Dec 14, 2022
@alalazo alalazo self-assigned this Dec 14, 2022
@tvandera
Copy link
Contributor

I was trying to reproduce this problem on my macbook, and for some reason it seems to work fine on macOS. Shall I try to make a reproducible example?

@tvandera
Copy link
Contributor

tvandera commented Dec 14, 2022

This simple example works on macOS and fails on Linux:

class RunTestsTest(Package):
    """Test Package"""

    homepage = "http://example.com"
    url      = "https://downloads.sourceforge.net/project/bowtie-bio/bowtie/1.2.1.1/bowtie-1.2.1.1-src.zip"
    version('1.2.1.1', 'ec06265730c5f587cd58bcfef6697ddf')

    def install(self, spec, prefix):
        print("run_tests = ", self.run_tests)
        assert False

On Linux:

$ spack -vd install --test=root run-tests-test 2>&1 | grep -A1 run_test
run_tests =  False
==> [2022-12-14-15:11:47.854487] Error: AssertionError:
--
          9        print("run_tests = ", self.run_tests)
  >>     10        assert False
(base) [/scratch/vanderaa]
 $ spack-python --version
Python 3.10.6
$ spack --version
0.20.0.dev0 (eec09f791d320c6ba73be0a71a8f0e0f4355a31c)

On macOS:

 $ spack -vd install --test=root run-tests-test 2>&1 | grep -A1 run_tests
run_tests =  True
==> [2022-12-14-14:37:46.526235] Error: AssertionError:
--
          9        print("run_tests = ", self.run_tests)
  >>     10        assert False
 $ spack-python --version
Python 3.10.8
$ spack --version
0.20.0.dev0 (9fdb36585f083133232686015903c022ea653980)

@alalazo
Copy link
Member Author

alalazo commented Dec 14, 2022

The issue is due to this line:

pkg.run_tests = tests is True or tests and pkg.name in tests

which monkey patches an object that was used, before monkey patching, to create and cache a builder. The wrapping is done here:

self.__dict__.update(wrapped_pkg_object.__dict__)

alalazo added a commit to alalazo/spack that referenced this issue Dec 14, 2022
fixes spack#34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
@alalazo
Copy link
Member Author

alalazo commented Dec 14, 2022

On the difference between macOS and linux, those are likely due to the different strategies used to create the separate process to install a spec. On macOS we use spawn which doesn't create an entire in memory copy of the current process, on linux we use fork.

haampie pushed a commit that referenced this issue Dec 15, 2022
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
benkirk pushed a commit to benkirk/spack that referenced this issue Dec 16, 2022
fixes spack#34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
haampie pushed a commit that referenced this issue Dec 22, 2022
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
haampie pushed a commit that referenced this issue Dec 23, 2022
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
haampie pushed a commit that referenced this issue Jan 18, 2023
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
haampie pushed a commit that referenced this issue Jan 24, 2023
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
haampie pushed a commit that referenced this issue Feb 7, 2023
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
alalazo added a commit that referenced this issue Feb 7, 2023
fixes #34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this issue Feb 16, 2023
fixes spack#34518

Fix an issue due to the MRO chain of the package wrapper
during build. Before this PR we were always returning
False when the builder object was created before the
run_tests method was monkey patched.
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-medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants