-
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.
- Loading branch information
Showing
2 changed files
with
92 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,60 @@ | ||
open Base | ||
open Bistro | ||
open Bistro.Template_dsl | ||
|
||
type t = template | ||
|
||
type expr = t | ||
|
||
type arg = t | ||
|
||
let make xs = Template_dsl.(seq ~sep:"\n" xs) | ||
|
||
let source s = Template_dsl.string s | ||
|
||
let dest = Template_dsl.(quote ~using:'"' dest) | ||
|
||
let tmp = Template_dsl.(quote ~using:'"' tmp) | ||
|
||
let string s = | ||
Template_dsl.(quote ~using:'"' (string s)) | ||
|
||
let int i = Template_dsl.int i | ||
|
||
let float f = Template_dsl.float f | ||
|
||
let dep w = Template_dsl.(quote ~using:'"' (dep w)) | ||
|
||
let call_gen fn arg xs = | ||
let open Template_dsl in | ||
seq ~sep:"" [ | ||
string fn ; | ||
string "(" ; | ||
list ~sep:"," arg xs ; | ||
string ")" ; | ||
] | ||
|
||
let call fn args = call_gen fn Fn.id args | ||
|
||
let vector f xs = call_gen "c" f xs | ||
|
||
let ints xs = vector Template_dsl.int xs | ||
let floats xs = vector Template_dsl.float xs | ||
let strings xs = vector string xs | ||
let deps xs = vector dep xs | ||
|
||
let arg ?l e = | ||
let open Template_dsl in | ||
match l with | ||
| None -> e | ||
| Some label -> | ||
seq ~sep:"" [ string label ; string "=" ; e ] | ||
|
||
let assign var e = | ||
let open Template_dsl in | ||
seq ~sep:" " [ string var ; string "<-" ; e ] | ||
|
||
let workflow ?descr ?np ?mem ?img exprs = | ||
Workflow.shell ?descr ?np ?mem Shell_dsl.[ | ||
cmd "Rscript" ?img [ file_dump (make exprs) ] ; | ||
] |
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,32 @@ | ||
open Bistro | ||
open Bistro.Template_dsl | ||
|
||
type t | ||
type expr | ||
type arg | ||
|
||
|
||
val make : expr list -> template | ||
|
||
val dest : expr | ||
val tmp : expr | ||
val source : string -> expr | ||
val call : string -> arg list -> expr | ||
val string : string -> expr | ||
val int : int -> expr | ||
val float : float -> expr | ||
val dep : _ pworkflow -> expr | ||
val ints : int list -> expr | ||
val floats : float list -> expr | ||
val strings : string list -> expr | ||
val deps : _ pworkflow list -> expr | ||
val arg : ?l:string -> expr -> arg | ||
val assign : string -> expr -> expr | ||
|
||
val workflow : | ||
?descr:string -> | ||
?np:int -> | ||
?mem:int workflow -> | ||
?img:Shell_dsl.container_image list -> | ||
expr list -> | ||
'a pworkflow |