Skip to content

buildcache push: ensure bool arguments for include_*#35632

Merged
haampie merged 4 commits intospack:developfrom
haampie:fix/bindist-push-make-kwargs-explicit-args-again
Feb 23, 2023
Merged

buildcache push: ensure bool arguments for include_*#35632
haampie merged 4 commits intospack:developfrom
haampie:fix/bindist-push-make-kwargs-explicit-args-again

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Feb 22, 2023

bindist.push(...) args were not correctly forwarded after a small API change
that should've made the arguments more explicit. Instead it caused dependencies
to be pushed too, where just the root node should've been.

The idea was to make arguments explicit, but unfortunately we now passed

```
push(include_root={"include_root": True, "include_dependencies": False})
```
@spackbot-app spackbot-app bot added binary-packages core PR affects Spack core functionality labels Feb 22, 2023
Comment on lines +1349 to +1350
if type(include_root) != bool or type(include_dependencies) != bool:
raise ValueError("Expected include_root/include_dependencies to be True/False")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious if we would have caught this with an annotated function, using mypy.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It doesn't :(

Copy link
Copy Markdown
Member

@tgamblin tgamblin Feb 23, 2023

Choose a reason for hiding this comment

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

is this needed at all now that we have annotations and mypy? Or is this just a belt and suspenders thing after all that CI chaos?

Copy link
Copy Markdown
Member

@tgamblin tgamblin Feb 23, 2023

Choose a reason for hiding this comment

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

One other thought: I'm pretty positive this would've been caught if we checked the whole codebase with mypy. Right now we only check annotated functions. I think we should try to get to checking everything to prevent subtle stuff like this -- the codebase is large enough that it can save us a lot of pain.

Specifically: I think we should get to where we can turn on --check-untyped-defs

Copy link
Copy Markdown
Member

@adamjstewart adamjstewart Feb 23, 2023

Choose a reason for hiding this comment

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

This should prob use isinstance instead of type

@spackbot-app spackbot-app bot added the tests General test capability(ies) label Feb 22, 2023
Copy link
Copy Markdown
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.

Yes, this makes sense, thanks @haampie! What a relief to have sanity restored.

@haampie haampie merged commit 3d41b71 into spack:develop Feb 23, 2023
@haampie haampie deleted the fix/bindist-push-make-kwargs-explicit-args-again branch February 23, 2023 00:44
@tgamblin tgamblin mentioned this pull request Feb 23, 2023
2 tasks
jmcarcell pushed a commit to key4hep/spack that referenced this pull request Apr 13, 2023
Fixes a bug introduced in 44ed0de
where the push method of binary_distribution now takes named args
include_root and include_depedencies, to avoid the **kwarg hole.

But the call site wasn't update and we passed a dict of keys/values instead
of arguments, which resulted in a call like this:

```
push(include_root={"include_root": True, "include_dependencies": False})
```

This commit fixes that, and adds a test to see if we push the correct packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binary-packages core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants