-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
Support target based fix rule without file partitioning #21935
Comments
The "workaround", such as it is, is to not use But there are some important design questions to tease out here. For example, how does this interact with change tracking? If you use Could you describe the nature of this fixer in more detail? |
Is it possible for me to attach the rule to the
It would run on the target that has the file as a source. Dotnet is a compiled language and the structure of our plugin is that each target maps to a dotnet project, the output of which is an assembly (which can be referenced by other projects/targets)
Its incorrect to not see all the files that are part of the target. Our plugin works around this by ignoring what pants partitions and locates the full set.
The tool in question is dotnet format I'm not an expert in this, but I can give my rough understanding from the few analyzers I've written. The roslyn analyzers are compiler plugins that run during the compilation process (so full source for the project must be in the sandbox), and the fixers mutate the AST to produce an updated source file. When we're running the fixers with pants, we're running in "batch mode", which is "fix everything that is broken". So the single |
Gotcha. So the fine-grained per-file-oriented idioms of standard Pants aren't a good fit here. I suspect that you'll need to use lower-level plugin concepts, because the FixTargetRequests (which you can think of us just a convenience wrapper around those lower-level concepts) makes use of the assumption that it can look at individual files. What is the target type you're, er, targeting? Is it a standard target type or a custom one in your plugin? Note that something like And yes, you should be able to plug a more raw plugin implementation into the standard |
Yeah our plugin isn't advanced enough yet to do automatic dependency inference at the file level, and certain language features (runtime reflection) make it significantly more challenging to implement correctly. The approach our plugin uses is to wrap invocations to MSBuild (dotnet cli) which is itself a build system and package manager, similar to what https://github.com/tgolsson/pants-cargo-porcelain does with Cargo and Rust
This is a custom target type
Thanks, I'll look more into this. |
Ah, so this should be pretty possible. Maybe start by writing it as a plugin that provides a new goal |
Is your feature request related to a problem? Please describe.
I don't believe its currently possible to write a fix rule (or at least I can't figure it out) that operates on the complete set of files in a target.
FixTargetsRequest
exists, but is subject to file partitioning because of this linepants/src/python/pants/core/goals/fix.py
Line 173 in 0089491
For my plugin's use case, we cannot partition the target by file, the fix rule needs to operate on all files in the target.
Describe the solution you'd like
FixTargetsRequest
should by able to opt out of file based partitioning.Describe alternatives you've considered
We've currently have a work around to operate on all files in the fix rule but only return the subset that was requested for by the request. This means the rule is running more than once (in multiples of
batch_size
) which is inefficient. So an additional workaround of setting a higherbatch_size
is also required, which may or may not be desirableCurrently if you try and write a fix request with a custom
_get_rules
which flips by_file to Falsecls.partitioner_type.default_rules(cls, by_file=False)
, an exception is currently thrown by the fix goal.Additional context
Somewhat related to this pylint issue #21686
Conversation where I was figuring out how to implement FixTargetsRequest https://pantsbuild.slack.com/archives/C01CQHVDMMW/p1718312447982689
The text was updated successfully, but these errors were encountered: