-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Provide mechanism to stream action output #7213
Comments
This would be super useful for build rule authors in general, since debugging a hanging tool with no access to stdout/stderr is super difficult. For what it's worth, one approach to debugging a |
A possible workaround is using |
I was so surprised when I realised there's no easy way to stream action build output in Bazel. It seems like a very necessary thing to be able to do. I have a very long build process, and it would be very helpful to be able to stream the output. So definitely a +1 from me to implement this. |
I am here. |
+1 For super long running actions. It's nice to be able to see where they are at progress wise |
This makes it possible to interactively debug a renderer build action. There are a few DX challenges I'm not able to fully address unfortunately: 1. Debugging is a bit wonky from the Bazel cache as I couldn't find a good way to turn it off for a specific action (`no-cache` does _not_ work). I started a thread in [#rules](https://bazelbuild.slack.com/archives/CDCMRLS23/p1678340235374509), so hopefully someone can help me out here. 2. `bazel build` hides output from stderr until the action fails, and there is no equivalent of `--test_output=streamed` for individual build actions. This means the debugged target appears to hang and fails to print that it is waiting for the debugger. I tried to call this out in the README, but I can definitely see users getting tripped up from this. See bazelbuild/bazel#7213. 3. I used a proper flag target (`@rules_prerender//tools/flags:debug_prerender`), though this is quite a lot to type so I recommended an alias in the `.bazelrc` file. Unfortunately it's hard to automatically set that up for users so the best I can do is document it.
This makes it possible to interactively debug a renderer build action. There are a few DX challenges I'm not able to fully address unfortunately: 1. Debugging is a bit wonky from the Bazel cache as I couldn't find a good way to turn it off for a specific action (`no-cache` does _not_ work). I started a thread in [#rules](https://bazelbuild.slack.com/archives/CDCMRLS23/p1678340235374509), so hopefully someone can help me out here. 2. `bazel build` hides output from stderr until the action fails, and there is no equivalent of `--test_output=streamed` for individual build actions. This means the debugged target appears to hang and fails to print that it is waiting for the debugger. I tried to call this out in the README, but I can definitely see users getting tripped up from this. See bazelbuild/bazel#7213. 3. I used a proper flag target (`@rules_prerender//tools/flags:debug_prerender`), though this is quite a lot to type so I recommended an alias in the `.bazelrc` file. Unfortunately it's hard to automatically set that up for users so the best I can do is document it. 4. I added a `debug_target` attribute which allows a target to recognize itself as the target being debugged, based on a _different_ target label. This is nice because the actual target invoking the renderer is typically something like `:site_page_annotated` due to passing through a few macros of indirection. Using `debug_target` allows us to pass through the label users actually author in their `BUILD.bazel` files and would expect to debug like `:site`. It's a fairly nuanced API, but I decided to keep it public since it could be useful for macros outside of those in `@rules_prerender`. 5. I'm fairly sure this doesn't really work for inspecting external targets (`@foo//:site`), but neither does `prerender_pages()` in general right now, so I'm not too worried about it atm.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
@bazelbuild/triage |
+1 on prioritizing this. This is the no.1 blocker for using Bazel extensively to manage slow and complex setups and preprocessing, e.g., for preparing machine learning training data etc. |
Description of the feature request:
We currently cannot stream a build rule output to the terminal. We could replicate the analogous test flag
--test_output=streamed
in the build execution phase.In that case, this would probably mean we would have to run the build actions sequentially in order to prevent any race condition on the terminal output.
Feature requests: what underlying problem are you trying to solve with this feature?
Some building tools [1] are not guaranteed to terminate. For such tools, having access to stdout/stderr is the only way we get to:
[1] Tools such as GHC, the Haskell compiler. See tweag/rules_haskell#603
The text was updated successfully, but these errors were encountered: