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

Add ./pants help subsystems #11088

Merged

Conversation

thamenato
Copy link
Member

@thamenato thamenato commented Oct 30, 2020

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

Problem

As described on #11032:

As a user I would like to see all the available subsystem options that I currently have in order to make changes to them inside my pants.toml file.

Solution

Implement the "category" subsystems inside the help function.

Result

When running the command ./pants help subsystems the user should be able to see what are the subsystems availables.

> ./pants help subsystems

Subsystems
------------

pex                                Lorem ipsum dolor sit amet.

download-pex-bin       Lorem ipsum dolor sit amet.

...

Use `./pants help $subsystem` to get help for a specific subsystem.

# 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]
@coveralls
Copy link

coveralls commented Oct 30, 2020

Coverage Status

Coverage remained the same at 0.0% when pulling 829cacf on thamenato:feature/add-help-subsystems into 4283b13 on pantsbuild:master.

# 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]
@thamenato
Copy link
Member Author

With my latest changes when running ./pants help subsystems it prints the following:


Subsystems
----------

black                   The Black Python code formatter (https://black.readthedocs.io/).

changed                 Tell Pants to detect what files and targets have changed from Git.

coverage-py             Configuration for Python test coverage measurement.

docformatter            The Python docformatter tool (https://github.com/myint/docformatter).

download-pex-bin        The PEX (Python EXecutable) tool (https://github.com/pantsbuild/pex).

flake8                  The Flake8 Python linter (https://flake8.pycqa.org/).

ipython                 The IPython enhanced REPL (https://ipython.org/).

isort                   The Python import sorter tool (https://timothycrosley.github.io/isort/).

mypy                    The MyPy Python type checker (http://mypy-lang.org/).

pants-releases          Options for Pants's release process.

pex                     How Pants uses Pex to run Python subprocesses.

pex-binary-defaults     Default settings for creating PEX executables.

pytest                  The pytest Python test framework (https://docs.pytest.org/).

python-infer            Options controlling which dependencies will be inferred for Python targets.

python-native-code      Options for building native code using Python, e.g. when resolving distributions.

python-repos            External Python code repositories, such as PyPI.

python-setup            A Python environment.

run-tracker             Tracks and times the execution of a pants run.

scc                     The Succinct Code Counter, aka `scc` (https://github.com/boyter/scc).

setup-py-generation     Options to control how setup.py is generated from a `python_distribution` target.

setuptools              The Python setuptools library (https://github.com/pypa/setuptools).

source                  Configuration for roots of source trees.

sourcefile-validation   Configuration for source file validation.

subprocess-environment  Environment settings for forked subprocesses.

Use `./pants help $subsystem_type` to get help for a specific subsystem.

@thamenato thamenato marked this pull request as ready for review November 3, 2020 02:56
@thamenato thamenato changed the title WIP: Pants should return all available subsystems from help command Pants should return all available subsystems from help command Nov 3, 2020
@thamenato
Copy link
Member Author

@Eric-Arellano and @benjyw this is ready for review 😃

@benjyw
Copy link
Sponsor Contributor

benjyw commented Nov 4, 2020

Thanks @thamenato ! Will review tomorrow.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks!

As mentioned over DM, would be good to add 1-2 tests.

src/python/pants/help/help_printer.py Outdated Show resolved Hide resolved
src/python/pants/help/help_printer.py Outdated Show resolved Hide resolved
# 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]
# 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
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Awesome! This looks great.

"pex How Pants uses Pex to run Python subprocesses" in pants_run.stdout
)
assert "to get help for a specific subsystem" in pants_run.stdout
assert "test Run tests." not in pants_run.stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

Negative assertions are generally brittle. If we rewrite the docstring for TestSubsystem to be different than "Run tests.", then this assertion will always pass, even if we break things. https://thepugautomatic.com/2013/04/negative-assertions/ talks a bit about this.

I suspect the best thing here would be to still use a negative assertion, but to use the re module to make it less brittle. Maybe something like ^test\s+. It's plausible we'll change the docstring and/or number of spaces, but very unlikely we'd ever change the line starting with test imo.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was wondering that myself.. it wouldn't fail but putting only the word "test" is also not a good idea. I think what you said is definitely a good solution, using some regex ❤️

Copy link
Contributor

Choose a reason for hiding this comment

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

but putting only the word "test" is also not a good idea

Indeed, and this assertion wouldn't work either. test is part of pytest hehe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, updated it to use regex.

# 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
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Woot! Will merge on green (unless Benjy has more feedback)

Thanks!

Copy link
Sponsor Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

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

LGTM!

@benjyw
Copy link
Sponsor Contributor

benjyw commented Nov 5, 2020

This is a great contribution, thanks for doing it!

@Eric-Arellano Eric-Arellano changed the title Pants should return all available subsystems from help command Add ./pants help subsystems Nov 5, 2020
@Eric-Arellano
Copy link
Contributor

FYI I reworded the PR title to "Add ./pants help subsystems", mostly for the purpose of the changelog. We use PR titles when aggregating the changelog. The original title was great for an issue description, but now that it's implemented, we can replace "should" with "add" to explain to users this is a new feature, and what command to use it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants