Skip to content

Commit

Permalink
utils/Report: build functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pveber committed Nov 20, 2020
1 parent 4671a87 commit 6adf813
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/utils/report.ml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,26 @@ let to_html d =
file_dump (document d) ;
]
]

let build ?np ?mem ?loggers ?allowed_containers ?(bistro_dir = "_bistro") ?collect ~output report =
let open Bistro_engine in
let open Lwt in
let db = Db.init_exn bistro_dir in
let goal = Workflow.path (to_html report) in
let sched = Scheduler.create ?np ?mem ?loggers ?allowed_containers ?collect db in
let report_cache_path = Scheduler.eval sched goal in
Scheduler.start sched ;
report_cache_path >>= fun res ->
Scheduler.stop sched >>= fun () ->
match res with
| Ok path ->
Misc.exec_exn [|"cp" ; path ; output|]
| Error traces -> (
let errors = Execution_trace.gather_failures traces in
prerr_endline (Scheduler.error_report sched errors) ;
Lwt.fail_with "Some workflow failed!"
)

let build_main ?np ?mem ?loggers ?allowed_containers ?bistro_dir ?collect ~output report =
build ?np ?mem ?loggers ?allowed_containers ?bistro_dir ?collect ~output report
|> Lwt_main.run
19 changes: 19 additions & 0 deletions lib/utils/report.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Markdown report *)

open Bistro
open Bistro_engine

type t

Expand All @@ -13,3 +14,21 @@ val svg : svg file -> Template_dsl.template
val png : png file -> Template_dsl.template

val to_html : t -> html file

val build :
?np:int ->
?mem:[`GB of int] ->
?loggers:Logger.t list ->
?allowed_containers:[`Docker | `Singularity] list ->
?bistro_dir:string ->
?collect:bool ->
output:string -> t -> unit Lwt.t

val build_main :
?np:int ->
?mem:[`GB of int] ->
?loggers:Logger.t list ->
?allowed_containers:[`Docker | `Singularity] list ->
?bistro_dir:string ->
?collect:bool ->
output:string -> t -> unit

0 comments on commit 6adf813

Please sign in to comment.