-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Pants peek
goal
#4861
Comments
the feature itself would be great.. but how would you implement this given the current build file parser? |
Using redbaron probably. You could get pretty far doing it that way. It wouldn't be able to deal with things like macros. I think having a way to do those would be really slick though. |
@15Dkatz just fyi that this can probably be implemented from buildozer |
|
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
I have opened a PR addressing this: |
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found. Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found.Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found.Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found.Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
This adds the ability to peek a BUILD file for a named target, printing the target name if it is found.Additionally, peek allows a line_number flag which will print the starting line of the named target if it is found in the BUILD file. Also, this adds a suppress warnings feature to Buildozer. Example: $ ./pants peek --line_number=true path/to/directory:target_name To Verify: $ ./pants test contrib/buildrefactor/tests/python/pants_test/contrib/buildrefactor:peek_integration This addresses: pantsbuild#4861 Please enter the commit message for your changes. Lines starting
@jriddy is interested in possibly working on this. Two approaches: 1) Show the BUILD file exactly as it is.For each address the user inputs, we will find the corresponding BUILD file, like we do with pants/src/python/pants/backend/project_info/filedeps.py Lines 96 to 98 in 8da1680
We can then use the paths to the BUILD files to say 2) Show the normalized target dataUse the Target API to show every field for a target after normalization, e.g. after applying default values. We would iterate over each field in pants/src/python/pants/engine/target.py Lines 350 to 357 in 8da1680
Possibly, we'd want to filter out any We'd maybe want to recreate something that looks like a BUILD file?
This raises an interesting question, if we should evaluate the -- We need to decide which approach (or both) we want to take. To answer this, we need to take a step back: what is the purpose of a peek goal? Yi's original motivation was:
I don't think that will be an issue very much anymore thanks to dep inference. Most of our BUILD files are no more than 3 lines in both |
It would be pretty easy to handle both of these situations with a The question that would remain for me is output format, especially in the case of multiple targets (and directories). Do we want a machine readable variant? What would that look like? JSON? |
All those ideas sound excellent. I think a --json and --raw flag make sense. Alternatively, an --output={raw,normalized,json} option is probably more scalable. See https://www.pantsbuild.org/docs/rules-api-subsystems#type for using enums as options. |
I was thinking Still not sure how to handle the look of multiple BUILD targets in "python" output mode...like if i have this source tree:
where both
The naïve way would just be... python_library()
python_library() ...but I don't like that. Maybe adding comments for the path part of the address makes sense?: # src/python/a/BUILD:
python_library()
# src/python/b/BUILD:
python_library() Idk, what do you think? |
That could work. Although, the reason I was thinking a single enum is that I don't imagine Table sounds great, but might be non-trivial with formatting (although lots of prior art from tools like Coverage). I recommend first focusing on landing --
I think so. Definitely we need some way to ID the target. Maybe something like this is more distinct?
That is, use the -- Related question, we want to preserve comments in BUILD files, right? That's actually probably easier to do than stripping, as we're going to simply dump the relevant raw lines without normalization. The part where I'm not sure: how should we handle comments right above the target? # IMPORTANT: Use this target in production so that we leverage the GPU.
python_requirement_library(name='req_with_cuda', requirements=['req[cuda]==3.1']) |
…11347) ### Problem It would be convenient to have pants able to export build metadata, either for human consumption or programmatic consumption. This seems to be the essence of issue #4861, which the PR addresses. ### Solution This PR adds a new `peek` goal, which allows us to look at the BUILD files for given targets using either their raw content, or with targets mapped to JSON.
Borrowing @baroquebobcat 's idea, sometimes it is good to have a quick peek on the target declaration, because a BUILD can get large and contain multiple target declarations, so the
peek
goal will just showExample:
In
foo/bar/BUILD
file:Result
The text was updated successfully, but these errors were encountered: