open Core open Bistro open Bistro_engine let with_workflow w ~f = let open Scheduler in let db = Db.init_exn "_bistro" in let loggers = [ Bistro_utils.Console_logger.create () ] in let sched = create ~np:8 ~mem:(`GB 8) ~loggers db in let thread = eval_exn sched w in start sched ; try Lwt_main.run thread |> f with Failure msg -> ( print_endline msg ; failwith "Failed!" ) | exn -> raise exn let eval w = with_workflow w ~f:Fn.id let path w = with_workflow (Workflow.eval_path w) ~f:(fun x -> x) let command fmt = Printf.ksprintf (fun s -> ignore (Sys.command s : int)) fmt let less w = command "less %s" (path w) let firefox w = command "firefox %s" (path w) let seaview w = command "seaview %s" (path w) let evince w = command "evince %s" (path w) let workflow_of_template t = let open Bistro.Shell_dsl in Workflow.shell [ cmd "cp" [ file_dump t ; dest ] ]