Skip to content

Commit 6651465

Browse files
authored
cleanup: Explicitly mark tensorboard/summary:repl.sh as executable. (#5967)
* Motivation for features / changes Building tensorboard/summary:repl in the internal Google repo does not succeed: ``` $ blaze clean $ blaze build third_party/tensorboard/summary:repl <snip> ERROR: /google/src/cloud/bdubois/hgtb/google3/third_party/tensorboard/summary/BUILD:199:8: Symlinking //third_party/tensorboard/summary:repl failed: failed to create symbolic link 'blaze-out/k8-fastbuild/bin/third_party/tensorboard/summary/repl': file 'blaze-out/k8-fastbuild/bin/third_party/tensorboard/summary/repl.sh' is not executable Target //third_party/tensorboard/summary:repl failed to build ``` Notably this means we cannot `blaze build third_party/tensorboard/...` * Technical description of changes Explicitly set repl.sh to executable when creating the file. ctx.actions.write() already has a is_executable argument so we just make sure we pass that information to the call. * Detailed steps to verify changes work correctly (as executed by you) Ensure the public repl target still builds and runs: ``` $ bazel clean $ bazel run tensorboard/summary:repl <snip> INFO: Running command line: bazel-bin/tensorboard/summary/repl tensorboard/summary/replINFO: Build completed successfully, 353 total actions from tensorboard.summary import Writer w = Writer("/tmp/foo") <snip> >>> w <tensorboard.summary._writer.Writer object at 0x7fcb963b36d0> >>> ^D ``` Also: ``` $ bazel run tensorboard:repl <snip> >>> import tensorboard.version >>> tensorboard.version.VERSION '2.11.0a0' >>> ^D ``` Ensure the internal repl target builds and runs (although it doesn't really run very well): ``` $ blaze clean $ blaze run third_party/tensorboard/summary:repl <snip> INFO: Build completed successfully, 10794 total actions from tensorboard.summary import Writer Traceback (most recent call last): File "<embedded module '_launcher'>", line 161, in run_filename_as_main File "<embedded module '_launcher'>", line 34, in _run_code_in_main File "/google/obj/workspace/d158cd457c2f2d42871081a28ab8f0450727dfae657c8d81f94250519e7c2b33/aa8a6db3-9d3c-4311-9b48-2ebb00c7a968/blaze-out/k8-fastbuild/bin/third_party/tensorboard/summary/repl.runfiles/google3/third_party/tensorboard/summary/repl.py", line 2, in <module> exec("from tensorboard.summary import Writer") File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'tensorboard' ```
1 parent e49a86f commit 6651465

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tensorboard/defs/py_repl.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
# Minimal wrapper over ctx.actions.write to write a string to a file.
1818
# Simpler than the genrule equivalent since we don't need to escape.
1919
def _write_file_impl(ctx):
20-
ctx.actions.write(ctx.outputs.out, ctx.attr.content)
20+
ctx.actions.write(ctx.outputs.out, ctx.attr.content, ctx.attr.is_executable)
2121

2222
_write_file = rule(
2323
implementation = _write_file_impl,
2424
attrs = {
2525
"out": attr.output(mandatory = True),
2626
"content": attr.string(),
27+
"is_executable": attr.bool(default = False),
2728
},
2829
)
2930

@@ -93,6 +94,7 @@ def py_repl(name, preamble = None, deps = None, **kwargs):
9394
name = name + "_sh_gen",
9495
out = name + ".sh",
9596
content = "PYTHONINSPECT=1 exec $1",
97+
is_executable = True,
9698
)
9799

98100
# Use `args` to pass the location of the data dep which is shorter

0 commit comments

Comments
 (0)