<#21935 Support target based fix rule without file...
# github-notifications
c
#21935 Support target based fix rule without file partitioning Issue created by chris-smith-zocdoc 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 line pants/src/python/pants/core/goals/fix.py Line 173 in</pantsbuild/pants/commit/00894913fa80ab595f5d30563f7560603f99bd75|0089491> | yield from cls.partitioner_type.default_rules(cls, by_file=True) | | ---------------------------------------------------------------- | 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 higher
batch_size
is also required, which may or may not be desirable Currently if you try and write a fix request with a custom
_get_rules
which flips by_file to False
cls.partitioner_type.default_rules(cls, by_file=False)
, an exception is currently thrown by the fix goal. Traceback (most recent call last): File "pants/core/goals/fix.py", line 381, in fix return await _do_fix( File "pants/core/goals/fix.py", line 305, in _do_fix partitions_by_request_type = await _get_partitions_by_request_type( File "pants/core/goals/lint.py", line 389, in _get_partitions_by_request_type all_partitions = await MultiGet( File "pants/engine/internals/selectors.py", line 376, in MultiGet return await _MultiGet(tuple(__arg0)) File "pants/core/goals/lint.py", line 390, in <genexpr> partition_request_get(request_type) for request_type in filtered_core_request_types File "pants/core/goals/lint.py", line 383, in partition_request_get assert partition_request_type in file_partitioners AssertionError 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 pantsbuild/pants