-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
useful for interactive use of bistro
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
open Bistro | ||
open Bistro_engine | ||
|
||
module Make(P : sig | ||
val np : int | ||
val mem : int | ||
end)() = | ||
struct | ||
open P | ||
|
||
let with_workflow w ~f = | ||
let open Scheduler in | ||
let db = Db.init_exn "_bistro" in | ||
let loggers = [ Console_logger.create () ] in | ||
let sched = create ~np:np ~mem:(`GB mem) ~loggers db in | ||
let thread = eval_exn sched w in | ||
start sched ; | ||
try | ||
Lwt_main.run thread | ||
|> f | ||
with | ||
| Failure msg as e -> (print_endline msg ; raise e) | ||
|
||
let eval w = with_workflow w ~f:(fun x -> x) | ||
|
||
let with_pworkflow w ~f = with_workflow (Workflow.eval_path w) ~f | ||
|
||
let path w = | ||
with_pworkflow w ~f:(fun x -> x) | ||
|
||
let sh fmt = | ||
Printf.kprintf (fun s -> ignore (Sys.command s)) fmt | ||
|
||
let rm w = with_pworkflow w ~f:(sh "rm %s") | ||
|
||
let file w = | ||
with_pworkflow w ~f:(sh "file %s") | ||
|
||
let less w = | ||
with_pworkflow w ~f:(sh "less %s") | ||
|
||
let wc w = | ||
with_pworkflow w ~f:(sh "wc %s") | ||
|
||
let firefox w = | ||
with_pworkflow w ~f:(sh "firefox --no-remote %s") | ||
|
||
let evince w = | ||
with_pworkflow w ~f:(sh "evince %s") | ||
|
||
let ls w = | ||
with_pworkflow w ~f:(sh "ls %s") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
open Bistro | ||
|
||
module Make(P : sig val np : int val mem : int end)() : sig | ||
val eval : 'a workflow -> 'a | ||
val path : _ pworkflow -> string | ||
val file : _ pworkflow -> unit | ||
val ls : _ pworkflow -> unit | ||
val less : #text_file pworkflow -> unit | ||
val firefox : _ pworkflow -> unit | ||
val evince : pdf pworkflow -> unit | ||
val wc : #text_file pworkflow -> unit | ||
val rm : _ pworkflow -> unit | ||
end |