Skip to content

Commit 2590cee

Browse files
authored
Avoid excessive BES event size (#79)
The files in requested output groups are announced as events on the Build Event Stream (BES), with declared directories expanded into the list of files they contain. Since mypy caches contain information about all transitive dependencies, including the cache directory in the `mypy` output group thus resulted in a very large number of (duplicated) files announced in build events when the aspect is applied to an entire repo, causing excessive upload times and BES sizes in the GBs. This is fixed by dropping the cache directory from the `mypy` output group. It is still accessible via the `MypyCacheInfo` provider.
1 parent 73ebdff commit 2590cee

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

mypy/private/mypy.bzl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,15 @@ def _mypy_impl(target, ctx):
151151
args = ctx.actions.args()
152152
args.add("--output", output_file)
153153

154+
result_info = [OutputGroupInfo(mypy = depset([output_file]))]
154155
if ctx.attr.cache:
155156
cache_directory = ctx.actions.declare_directory(ctx.rule.attr.name + ".mypy_cache")
156157
args.add("--cache-dir", cache_directory.path)
157158

158159
outputs = [output_file, cache_directory]
159-
result_info = [
160-
MypyCacheInfo(directory = cache_directory),
161-
OutputGroupInfo(mypy = depset(outputs)),
162-
]
160+
result_info.append(MypyCacheInfo(directory = cache_directory))
163161
else:
164162
outputs = [output_file]
165-
result_info = [OutputGroupInfo(mypy = depset(outputs))]
166163

167164
args.add_all([c.path for c in upstream_caches], before_each = "--upstream-cache")
168165
args.add_all([s for s in ctx.rule.files.srcs if "/_virtual_imports/" not in s.short_path])

0 commit comments

Comments
 (0)