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

Fix performance for generating lockfiles for pytest and setuptools #16591

Merged

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Aug 19, 2022

Follow up to #15531. We didn't apply the optimization for Pytest and setuptools that it is no longer necessary to consult TransitiveTargets to determine interpreter constraints for generate-lockfiles, purely out of oversight.

This also leverages @rule_helper to DRY some of our interpreter constraints code for lockfiles. That results in these slight behavior changes:

  • MyPy and Black are fixed to properly OR distinct interpreter constraints. We always meant to do this.
  • If MyPy does not encounter any MyPy-compatible targets in the repo, we fall back to [python].interpreter_constraints rather than the default [mypy].interpreter_constraints. This situation is unlikely to happen.

In pantsbuild/pants, it now takes us 0.4 seconds rather than 4.7 seconds to calculate the interpreter constraints for ./pants generate-lockfiles --resolve=pytest.

[ci skip-rust]
[ci skip-build-wheels]

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines -199 to -200
# If no Python targets in repo, fall back to MyPy constraints.
assert_lockfile_request("target()", MyPy.default_interpreter_constraints)
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand this change. But if there are no python targets in the repository, then it probably doesn't matter which we use...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because the rule helper says or python_setup.interpreter_constraints when there were no interpreter constraints. Whereas the old bespoke code said or mypy.interpretre_constraints. That's pretty unlikely to happen -- it's only when there are zero MyPy compatible targets in the repo.

@Eric-Arellano Eric-Arellano merged commit a7b2447 into pantsbuild:main Aug 20, 2022
@Eric-Arellano Eric-Arellano deleted the improve-tool-lockfile-perf branch August 20, 2022 00:12
Eric-Arellano added a commit to Eric-Arellano/pants that referenced this pull request Aug 20, 2022
pantsbuild#16591)

Follow up to pantsbuild#15531. We didn't apply the optimization for Pytest and setuptools that it is no longer necessary to consult `TransitiveTargets` to determine interpreter constraints for `generate-lockfiles`, purely out of oversight.

This also leverages `@rule_helper` to DRY some of our interpreter constraints code for lockfiles. That results in these slight behavior changes:

* MyPy and Black are fixed to properly OR distinct interpreter constraints. We always meant to do this.
* If MyPy does not encounter any MyPy-compatible targets in the repo, we fall back to `[python].interpreter_constraints` rather than the default `[mypy].interpreter_constraints`. This situation is unlikely to happen.

In `pantsbuild/pants`, it now takes us 0.4 seconds rather than 4.7 seconds to calculate the interpreter constraints for `./pants generate-lockfiles --resolve=pytest`.

[ci skip-rust]
[ci skip-build-wheels]
Eric-Arellano added a commit that referenced this pull request Aug 22, 2022
…` (Cherry-pick of #16591) (#16596)

Follow up to #15531. We didn't apply the optimization for Pytest and setuptools that it is no longer necessary to consult `TransitiveTargets` to determine interpreter constraints for `generate-lockfiles`, purely out of oversight.

This also leverages `@rule_helper` to DRY some of our interpreter constraints code for lockfiles. That results in these slight behavior changes:

* MyPy and Black are fixed to properly OR distinct interpreter constraints. We always meant to do this.
* If MyPy does not encounter any MyPy-compatible targets in the repo, we fall back to `[python].interpreter_constraints` rather than the default `[mypy].interpreter_constraints`. This situation is unlikely to happen.

In `pantsbuild/pants`, it now takes us 0.4 seconds rather than 4.7 seconds to calculate the interpreter constraints for `./pants generate-lockfiles --resolve=pytest`.

[ci skip-rust]
[ci skip-build-wheels]
cczona pushed a commit to cczona/pants that referenced this pull request Sep 1, 2022
pantsbuild#16591)

Follow up to pantsbuild#15531. We didn't apply the optimization for Pytest and setuptools that it is no longer necessary to consult `TransitiveTargets` to determine interpreter constraints for `generate-lockfiles`, purely out of oversight.

This also leverages `@rule_helper` to DRY some of our interpreter constraints code for lockfiles. That results in these slight behavior changes:

* MyPy and Black are fixed to properly OR distinct interpreter constraints. We always meant to do this.
* If MyPy does not encounter any MyPy-compatible targets in the repo, we fall back to `[python].interpreter_constraints` rather than the default `[mypy].interpreter_constraints`. This situation is unlikely to happen.

In `pantsbuild/pants`, it now takes us 0.4 seconds rather than 4.7 seconds to calculate the interpreter constraints for `./pants generate-lockfiles --resolve=pytest`.

[ci skip-rust]
[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants