hygienic BUILD file modifications (like buildozer) with libCST#9434
Closed
cosmicexplorer wants to merge 1 commit intopantsbuild:mainfrom
Closed
hygienic BUILD file modifications (like buildozer) with libCST#9434cosmicexplorer wants to merge 1 commit intopantsbuild:mainfrom
cosmicexplorer wants to merge 1 commit intopantsbuild:mainfrom
Conversation
…T!!!
save progress
[ci skip-jvm-tests] # No JVM changes made.
add basic @goal_rule!!!
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
make a v2 repl!!!
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
add a HashableDict and remove a ton of code
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
fixes after rebase
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
make it work a lot more
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
make parsing BUILD files for targets work!!!
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
attempt to write down buildozer commands!!!
[ci skip-jvm-tests] # No JVM changes made.
refactor BUILD file object matching
[ci skip-jvm-tests] # No JVM changes made.
refactor object matching again
[ci skip-jvm-tests] # No JVM changes made.
the following command works!! (add to list attr)
rlwrap ./pants -ldebug --v2 --no-v1 --no-v2-ui --query="owner_of('src/python/pants/util/strutil.py')" --query="type_filter('python_library')" --query='minimize()' --query='noop()' buildozer2 --args='add sources "tarutil.py"'
[ci skip-jvm-tests] # No JVM changes made.
getting and modifying data is easy now!!!
this command totally works!!!
rlwrap ./pants --v2 --no-v1 --no-v2-ui --query="owner_of('src/python/pants/util/strutil.py')" --query="type_filter('python_library')" --query='minimize()' --query='noop()' buildozer2 --args='add sources "tarutil.py"' --args='print name'
[ci skip-jvm-tests] # No JVM changes made.
refactor the AddValuesToList part
[ci skip-jvm-tests] # No JVM changes made.
add schema.py!
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
everything appears to be working??? including this command:
./pants binary examples/src/scala/org/pantsbuild/example/build_graph:find-orphaned-targets && ./pants --query="type_filter('python_library')" list --output-format=json src/python/pants/util: | java -jar ./dist/find-orphaned-targets.jar | ./pants --spec-file=/dev/stdin buildozer2 --args="add tags 'orphaned'"
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
additional fixes after rebase
[ci skip-jvm-tests] # No JVM changes made.
[ci skip-jvm-tests] # No JVM changes made.
cosmicexplorer
commented
Mar 31, 2020
| def registered_aliases(self): | ||
| """Returns a copy of the registered build file aliases this build file parser uses.""" | ||
| return self._build_configuration.registered_aliases() | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Note: this is all dead code. It was dead code before this PR, too.
Contributor
There was a problem hiding this comment.
Could you please break this out into a dedicated PR?
This change looks incredible, although the size of the diff makes it a little overwhelming to review. It’d be hugely helpful to break out any possible prework PRs like this so that this PR is smaller.
|
|
||
| @frozen_after_init | ||
| @dataclass(unsafe_hash=True) | ||
| class HashableDict(Generic[_K, _V]): |
Contributor
There was a problem hiding this comment.
See FrozenDict from Pants.util.frozendict. I think it does what you’re after here.
This was referenced Sep 30, 2020
Contributor
|
Closing as stale, which we're doing for all changes that haven't been touched in 1+ years to simplify project management. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODO: add testing!
Problem
buildozer is a fantastic tool that hygeinically rewrites bazel BUILD files. We would like to do the same, but with a couple caveats (I made these up, so feel free to disagree!):
Solution
Addressesfrom BUILD files to the libCST node that represents the named target.@rules which implement about 10% of buildozer commands by interacting with libCST.Result
(describe how your changes affect the end-user behavior of the system. this section is
optional, and should generally be summarized in the title of the pull request.)
Example commands when combined with #7356 and #8450:
rlwrap ./pants -ldebug --v2 --no-v1 --no-v2-ui --query="owner_of('src/python/pants/util/strutil.py')" --query="type_filter('python_library')" --query='minimize()' --query='noop()' buildozer2 --args='add sources "tarutil.py"'rlwrap ./pants --v2 --no-v1 --no-v2-ui --query="owner_of('src/python/pants/util/strutil.py')" --query="type_filter('python_library')" --query='minimize()' --query='noop()' buildozer2 --args='add sources "tarutil.py"' --args='print name'./pants binary examples/src/scala/org/pantsbuild/example/build_graph:find-orphaned-targets && ./pants --query="type_filter('python_library')" list --output-format=json src/python/pants/util: | java -jar ./dist/find-orphaned-targets.jar | ./pants --spec-file=/dev/stdin buildozer2 --args="add tags 'orphaned'"