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
Make Docker.run return its stdout as a string #120
Conversation
This looks good, but I think it should be a new function (e.g. |
Thanks 🙂 Some thoughts:
edit: I accidentally posted it before finishing... 🤦♂️ |
@craigfe I think this use is quite separate to log analysis. For example, Kate wants to read structured data (revdeps) from the command. This should not be mixed in with warning messages from stderr. It's also quite likely that the output being captured would be binary data, in which case it's important that we don't log it. |
@talex5 : The use-cases I can think of would all want the data to be logged as well as captured. This includes the application to benchmarking (cc @gs0510, @MagnusS), who have been waiting for a feature like this for a while. Is it an issue if the rev-deps, in this case, are not logged to the interface? I think as a new user of OCurrent I would expect them to be. If we have a use-case for extracting binary data from a Docker container, I suggest doing that by some other mechanism than overloading 'logs'. For instance by using |
4aa7b80
to
4e07941
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, once the id is changed.
@@ -16,5 +16,5 @@ | |||
ppx_deriving_yojson.runtime | |||
result) | |||
(preprocess (per_module | |||
((pps ppx_deriving.std ppx_deriving_yojson) pull build run tag push service) | |||
((pps ppx_deriving.std ppx_deriving_yojson) pull build run pread tag push service) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we could probably get rid of this per-module thing now - it was a hack for before 4.08, which we no longer support)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change this in this PR or in a separate PR?
4e07941
to
d07e2d8
Compare
If the change in |
Thanks - I'll take a look at cleaning up the preprocessing separately... |
I don't think this should have been merged.
Are we in a rush to merge this feature as is? |
The behaviour of pread (returning the output instead of sending it to stdout) is pretty standard, e.g. compare lwt's version: utop # #require "lwt.unix";;
utop # open Lwt_process;;
utop # let cmd = "", [| "echo"; "hello" |];;
utop # exec cmd;;
hello
- : Unix.process_status = Unix.WEXITED 0
utop # pread cmd;;
- : string = "hello\n" But I do think we should make it easier to make user-defined pipeline stages using Docker, so the built-in ones don't have to cover every case. (if you want to add an option to log the output too, or clean up the code, feel free) |
…urrent_git, current_slack, current_ansi, current_rpc, current_incr and current_examples (0.2) CHANGES: The main new feature is that OCurrent now evaluates pipelines incrementally. This means that services with large pipelines (such as ocaml-ci, with around 10,000 stages) can decide what they need to do without using an excessive amount of CPU time. - Replace changed promises with `Engine.update` (@talex5, ocurrent/ocurrent#135) - Evaluate pipelines incrementally (@talex5, ocurrent/ocurrent#144) - Avoid unnecessary re-evaluations in `Current.list_map` (@talex5, ocurrent/ocurrent#148) - Change the representation of terms to support incremental evaluation (@talex5, ocurrent/ocurrent#150) Documentation: - Added [Internals](https://github.com/ocurrent/ocurrent/wiki/Internals) wiki page explaining how OCurrent works. - Update README.md to link the [API Docs](https://ocurrent.github.io/ocurrent/index.html) (@shonfeder, ocurrent/ocurrent#145) - Fix typo in README ("about" -> "above") (@smolck, ocurrent/ocurrent#100) Docker plugin: - Add support for run-arguments in docker plugin (@MagnusS, ocurrent/ocurrent#96) - Add `?build_args` parameter to `Current_docker` build (@SquidDev, ocurrent/ocurrent#102) - Allow alternative Dockerfile filenames in `Docker.build` (@talex5, ocurrent/ocurrent#111) - Add `Docker.pread` to get container stdout as a string (@kit-ty-kate, ocurrent/ocurrent#120) - Make it easier to add custom Docker commands (@talex5, ocurrent/ocurrent#130) Git plugin: - Git.fetch: don't take repository lock until the job starts (@talex5, ocurrent/ocurrent#116) GitHub plugin: - Add `Github.Api.head_of` to track individual branches (@talex5, ocurrent/ocurrent#114) - Expose the low-level `refs` function to get access to branch names and PR numbers (@talex5, ocurrent/ocurrent#123) - Add `Commit.uri` to make links back to GitHub (@talex5, ocurrent/ocurrent#131) - Better error if setting a GitHub commit status fails (@talex5, ocurrent/ocurrent#151) - Only refresh the repository that generated the webhook event, not all of them (@talex5, ocurrent/ocurrent#156) Web UI: - Use routes library to simplify routing (@talex5, ocurrent/ocurrent#160) - Add "/jobs" page with information about active jobs (@talex5, ocurrent/ocurrent#125) - Mark HTML pages as UTF-8 (@talex5, ocurrent/ocurrent#128) Dependencies: - Update to new Alcotest API (@talex5, ocurrent/ocurrent#121) - Use mirage-crypto instead of nocrypto (@hannesm, ocurrent/ocurrent#161) Bug fixes: - Fix analysis with hidden `catch`/`state` nodes (@talex5, ocurrent/ocurrent#134) - Allow cancelling a job while waiting for confirmation (@talex5 ocurrent/ocurrent#137) - Fix merging of error states for pairs (@talex5, ocurrent/ocurrent#147) Metrics: - Report Prometheus metrics for pipeline stage states (@talex5, ocurrent/ocurrent#115) - Report metric for cache evaluations (@talex5, ocurrent/ocurrent#143) Build improvements: - Make dune transitive dependencies explicit (@craigfe, ocurrent/ocurrent#97) - Add OCaml-CI status badge to the README (@craigfe, ocurrent/ocurrent#107) Other: - Explicitly enumerate accepted `--confirm` values (@craigfe, ocurrent/ocurrent#108) - Rename `Input` to `Primitive` and simplify the API (@talex5, ocurrent/ocurrent#154) - Call `Lwt_main.yield` while testing log patterns (@talex5, ocurrent/ocurrent#155) - Add `Current.collapse` to allow collapsing parts of diagrams (@talex5, ocurrent/ocurrent#152) - Add `Current.with_context` to help with diagram layout (@talex5, ocurrent/ocurrent#159)
…urrent_git, current_slack, current_ansi, current_rpc, current_incr and current_examples (0.2) CHANGES: The main new feature is that OCurrent now evaluates pipelines incrementally. This means that services with large pipelines (such as ocaml-ci, with around 10,000 stages) can decide what they need to do without using an excessive amount of CPU time. - Replace changed promises with `Engine.update` (@talex5, ocurrent/ocurrent#135) - Evaluate pipelines incrementally (@talex5, ocurrent/ocurrent#144) - Avoid unnecessary re-evaluations in `Current.list_map` (@talex5, ocurrent/ocurrent#148) - Change the representation of terms to support incremental evaluation (@talex5, ocurrent/ocurrent#150) Documentation: - Added [Internals](https://github.com/ocurrent/ocurrent/wiki/Internals) wiki page explaining how OCurrent works. - Update README.md to link the [API Docs](https://ocurrent.github.io/ocurrent/index.html) (@shonfeder, ocurrent/ocurrent#145) - Fix typo in README ("about" -> "above") (@smolck, ocurrent/ocurrent#100) Docker plugin: - Add support for run-arguments in docker plugin (@MagnusS, ocurrent/ocurrent#96) - Add `?build_args` parameter to `Current_docker` build (@SquidDev, ocurrent/ocurrent#102) - Allow alternative Dockerfile filenames in `Docker.build` (@talex5, ocurrent/ocurrent#111) - Add `Docker.pread` to get container stdout as a string (@kit-ty-kate, ocurrent/ocurrent#120) - Make it easier to add custom Docker commands (@talex5, ocurrent/ocurrent#130) Git plugin: - Git.fetch: don't take repository lock until the job starts (@talex5, ocurrent/ocurrent#116) GitHub plugin: - Add `Github.Api.head_of` to track individual branches (@talex5, ocurrent/ocurrent#114) - Expose the low-level `refs` function to get access to branch names and PR numbers (@talex5, ocurrent/ocurrent#123) - Add `Commit.uri` to make links back to GitHub (@talex5, ocurrent/ocurrent#131) - Better error if setting a GitHub commit status fails (@talex5, ocurrent/ocurrent#151) - Only refresh the repository that generated the webhook event, not all of them (@talex5, ocurrent/ocurrent#156) Web UI: - Use routes library to simplify routing (@talex5, ocurrent/ocurrent#160) - Add "/jobs" page with information about active jobs (@talex5, ocurrent/ocurrent#125) - Mark HTML pages as UTF-8 (@talex5, ocurrent/ocurrent#128) Dependencies: - Update to new Alcotest API (@talex5, ocurrent/ocurrent#121) - Use mirage-crypto instead of nocrypto (@hannesm, ocurrent/ocurrent#161) Bug fixes: - Fix analysis with hidden `catch`/`state` nodes (@talex5, ocurrent/ocurrent#134) - Allow cancelling a job while waiting for confirmation (@talex5 ocurrent/ocurrent#137) - Fix merging of error states for pairs (@talex5, ocurrent/ocurrent#147) Metrics: - Report Prometheus metrics for pipeline stage states (@talex5, ocurrent/ocurrent#115) - Report metric for cache evaluations (@talex5, ocurrent/ocurrent#143) Build improvements: - Make dune transitive dependencies explicit (@craigfe, ocurrent/ocurrent#97) - Add OCaml-CI status badge to the README (@craigfe, ocurrent/ocurrent#107) Other: - Explicitly enumerate accepted `--confirm` values (@craigfe, ocurrent/ocurrent#108) - Rename `Input` to `Primitive` and simplify the API (@talex5, ocurrent/ocurrent#154) - Call `Lwt_main.yield` while testing log patterns (@talex5, ocurrent/ocurrent#155) - Add `Current.collapse` to allow collapsing parts of diagrams (@talex5, ocurrent/ocurrent#152) - Add `Current.with_context` to help with diagram layout (@talex5, ocurrent/ocurrent#159)
After commenting on #99 (comment) I realized it was relatively easy to change
Current_docker.run
to do what i want and return its result as a string.This is the current design I'm using in opam-ci where it successfully gets the list of reverse dependencies for each packages: