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] Refactor install.py.in toward testability #16214

Closed
wants to merge 1 commit into from

Conversation

rpoyner-tri
Copy link
Contributor

@rpoyner-tri rpoyner-tri commented Dec 14, 2021

Relevant to: #7331

This patch extracts most of the python code from install.py.in to a new
module install_lib.py, and adjusts bazel rules and targets to work with
the new layout.

No actual new tests are added at this step.

The moved code in the new file is only adjusted so that python lint
checks will pass. The new function execute_installation() is
essentially the old main() function, with an extra callable argument.

At this stage, all of the existing tests should pass and existing
install rules should still work. The next step toward closing #7331
would be to increase test coverage of the install_lib.py code.


This change is Reviewable

Relevant to: RobotLocomotion#7331

This patch extracts most of the python code from install.py.in to a new
module install_lib.py, and adjusts bazel rules and targets to work with
the new layout.

No actual new tests are added at this step.

The moved code in the new file is only adjusted so that python lint
checks will pass. The new function `execute_installation()` is
essentially the old `main()` function, with an extra callable argument.

At this stage, all of the existing tests should pass and existing
install rules should still work. The next step toward closing RobotLocomotion#7331
would be to increase test coverage of the install_lib.py code.
Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

+@jwnimmer-tri for feature review.

FYI @BetsyMcPhail -- if we should get some more Kitware reviewers in, please add them.

Reviewable status: LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @jwnimmer-tri)

a discussion (no related file):
For a better diff-reading experience, trying pulling the code locally and using git show -C. This will extract only the changed lines in install_lib.py.


@jwnimmer-tri
Copy link
Collaborator

a discussion (no related file):
Is it important / relevant to still have an .in file with pattern substitutions?

My mental model of this ticket was that we'd have a program install.py that takes a required command-line argument --actions=my_actions.py, with no magic text substitutions anywhere.


Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @jwnimmer-tri)

a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

Is it important / relevant to still have an .in file with pattern substitutions?

My mental model of this ticket was that we'd have a program install.py that takes a required command-line argument --actions=my_actions.py, with no magic text substitutions anywhere.

That's possible, but it's also a deeper cut into the .bzl code than I was willing to attempt on the first swing. My reading of the issue was that the bulk of the python code was unavailable for unit test, so opening up that access was what i concentrated on.

If forbidding any calls to ctx.actions.expand_template() is also a goal, we can go around again.


Copy link
Contributor

@BetsyMcPhail BetsyMcPhail left a comment

Choose a reason for hiding this comment

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

Thanks for the heads up, no additional Kitware reviewers needed.

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, missing label for release notes (waiting on @jwnimmer-tri)

@jwnimmer-tri jwnimmer-tri added the release notes: none This pull request should not be mentioned in the release notes label Dec 14, 2021
Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers (waiting on @jwnimmer-tri and @rpoyner-tri)

a discussion (no related file):

Previously, rpoyner-tri (Rick Poyner (rico)) wrote…

That's possible, but it's also a deeper cut into the .bzl code than I was willing to attempt on the first swing. My reading of the issue was that the bulk of the python code was unavailable for unit test, so opening up that access was what i concentrated on.

If forbidding any calls to ctx.actions.expand_template() is also a goal, we can go around again.

OK Makes sense. I'll review in that context.


Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers (waiting on @jwnimmer-tri)

a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

OK Makes sense. I'll review in that context.

I've filed #16252 to do the bazel reworking first, to lose the template substitution. I'd like to get that merged first, and then revisit this PR. One major test-ability objection is the global variables, and I don't think the actions-library split here will be able to address that on its own. Having the installer be a standalone program should be able to do it.


Copy link
Contributor Author

@rpoyner-tri rpoyner-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers (waiting on @jwnimmer-tri)

a discussion (no related file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I've filed #16252 to do the bazel reworking first, to lose the template substitution. I'd like to get that merged first, and then revisit this PR. One major test-ability objection is the global variables, and I don't think the actions-library split here will be able to address that on its own. Having the installer be a standalone program should be able to do it.

I don't see that the two problems (globals and module structure) are necessarily related, and I'm not a huge fan of exec(), but I'm not particularly a fan of all the __init__.py fiddling in this patch either. By all means, play through.


@rpoyner-tri
Copy link
Contributor Author

rpoyner-tri commented Dec 20, 2021

Closing -- supplanted by #16252.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: none This pull request should not be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants