Module Ketrew.EDSL

module EDSL: sig .. end


Easy interface to the library for end users.

This is a more stable EDSL/API for end-users to make workflows and deal with the system.

Many functions may raise exceptions when called improperly, but this should happen while building the workflow, not after it starts running.

Hosts


module Host: sig .. end

Build Programs


module Program: sig .. end
Build “things to run”, i.e.

Conditions


module Condition: sig .. end

Build Processes


module Build_process: sig .. end
val daemonize : ?starting_timeout:float ->
?call_script:(string -> string list) ->
?using:[ `Nohup_setsid | `Python_daemon ] ->
?host:Host.t ->
?no_log_is_ok:bool -> Program.t -> Build_process.t
Create a “daemonize” build process:


val lsf : ?host:Host.t ->
?queue:string ->
?name:string ->
?wall_limit:string ->
?processors:[ `Min of int | `Min_max of int * int ] ->
?project:string ->
?request_memory:[ `GB of int | `MB of int ] ->
?raw_options:string list ->
Program.t -> Build_process.t
Create an “LSF” build process.
val pbs : ?host:Host.t ->
?queue:string ->
?name:string ->
?wall_limit:[ `Hours of float ] ->
?processors:int ->
?email_user:[ `Always of string | `Never ] ->
?shell:string -> Program.t -> Build_process.t
Create a “PSB” build process.
val yarn_application : ?host:Host.t ->
?daemonize_using:[ `Nohup_setsid | `Python_daemon ] ->
?daemon_start_timeout:float ->
Program.t -> Build_process.t
Create a build process that requests resources from Yarn, the command must be an application in the Yarn sense (i.e. a program that is going to contact Yarn by itself to request containers):


val yarn_distributed_shell : ?host:Host.t ->
?daemonize_using:[ `Nohup_setsid | `Python_daemon ] ->
?daemon_start_timeout:float ->
?hadoop_bin:string ->
?distributed_shell_shell_jar:string ->
?container_vcores:int ->
container_memory:[ `GB of int | `MB of int | `Raw of string ] ->
timeout:[ `Raw of string | `Seconds of int ] ->
application_name:string ->
Program.t -> Build_process.t
Create a build process that will use Hadoop's `DistributedShell` class to request a container to run the given arbitrary program.



Workflow Nodes and Edges


module Internal_representation: sig .. end
type < is_done : Condition.t option; .. > product = < is_done : Condition.t option; .. > as 'a 
The type of the things produced by workflow nodes. A product is an object that has at least one method giving its Ketrew.EDSL.Condition.t.
type < is_done : Condition.t option; .. > workflow_node = <
   product : (< is_done : Condition.t option; .. > as 'a) product;
   render : Internal_representation.t;
>
The main building bloc of the worfklow graph is workflow node, it carries a “product” accessible with the #product method.

The #render method is used internally by Ketrew.Client.submit_workflow.

type workflow_edge 
The edges of the graph (?edges argument of the Ketrew.EDSL.workflow_node function).
val depends_on : < is_done : Condition.t option; .. > workflow_node ->
workflow_edge
Create a “dependency” edge, in other words, the node using the edges “depends on” the node given as argument.
val on_success_activate : < is_done : Condition.t option; .. > workflow_node ->
workflow_edge
Create an edge to a node that will be activated after a node succeeds.
val on_failure_activate : < is_done : Condition.t option; .. > workflow_node ->
workflow_edge
Create an edge to a node that will be activated after a node fails.
type ensures_option = [ `Is_verified of Condition.t | `Nothing | `Product_is_done ] 
The specification of when a workflow-node is considered “ensured”; cf. the ?ensures argument of Ketrew.EDSL.workflow_node.
val workflow_node : ?name:string ->
?active:bool ->
?make:Build_process.t ->
?ensures:ensures_option ->
?metadata:[ `String of string ] ->
?equivalence:Ketrew_pure.Target.Equivalence.t ->
?tags:string list ->
?edges:workflow_edge list ->
(< is_done : Condition.t option; .. > as 'a) product ->
'a workflow_node
Create a workflow node:


type not_already_done = <
   is_done : Condition.t option;
>
The type of “empty” products.
val without_product : not_already_done
Create an “empty” product, it won't require checking any condition, so the node carrying it (unless forced with the ?is_done argument) will always run.

This can be understood as a ".PHONY" target in make.

type single_file = <
   exists : Ketrew_pure.Target.Condition.t;
   host : Host.t;
   is_bigger_than : int -> Ketrew_pure.Target.Condition.t;
   is_done : Ketrew_pure.Target.Condition.t option;
   path : string;
>
The type of products that carry a simple file (on a given Host.t).
val single_file : ?host:Host.t ->
string -> single_file product
Create a single_file product.

The path argument should be absolute since the notion of “current directory” is very ill-defined when it comes to this kind of distributed application.

The condition returned by the #is_done method (used by default in any worfklow-node that uses the single_file product) is to check the existence of the file.

type list_of_files = <
   is_done : Ketrew_pure.Target.Condition.t option;
   paths : string list;
>
The type of products that carry a list of files (on a same Host.t).
val list_of_files : ?host:Host.t ->
string list -> list_of_files product
Create a list_of_files product (#is_done checks the existence of all these files).
type unknown_product = <
   is_done : Condition.t option;
>
The type of the products that have been “hidden” or “forgotten,” see Ketrew.EDSL.forget_product.
val forget_product : < is_done : Condition.t option; .. > workflow_node ->
unknown_product workflow_node
“Cast” a node to the unknown_product workflow_node type, this is useful to make some programs that generate workflows type check (putting nodes into lists, or in different branches of a match .. with).

Utilities For Workflow Nodes


val workflow_to_string : ?ansi_colors:bool ->
?indentation:int ->
< is_done : Condition.t option; .. > workflow_node ->
string
Build a display-friendly string summarizing the workflow.
val add_tags : ?recursive:bool ->
< is_done : Condition.t option; .. > workflow_node ->
string list -> unit
Add tags imperatively to a node, if recursive is true, follow the edges recursively to add tags.
val node_id : < is_done : Condition.t option; .. > workflow_node ->
string
Get the unique ID of the workdlow node.
val node_name : < is_done : Condition.t option; .. > workflow_node ->
string
Get the name of the workdlow node.

Legacy Deprecated API: Artifacts and Targets

This is the old and deprecated API to build workflows (deprecated since Ketrew 2.1.0).

Using functions like Ketrew.EDSL.target is still possible but they will trigger a compilation warning e.g. "Warning 3: deprecated: Ketrew.EDSL.target".

class type user_artifact = object .. end
Artifacts
val file : ?host:Host.t -> string -> user_artifact
Create a volume containing one file.
val unit : user_artifact
The artifact that is “never done” (i.e. the target associated will always be (re-)run if activated).

Targets


class type user_target = object .. end
Targets are the nodes in the workflow arborescence (see also Target.t).
val target : ?active:bool ->
?depends_on:user_target list ->
?make:Build_process.t ->
?done_when:Ketrew_pure.Target.Condition.t ->
?metadata:[ `String of string ] ->
?product:user_artifact ->
?equivalence:Ketrew_pure.Target.Equivalence.t ->
?on_failure_activate:user_target list ->
?on_success_activate:user_target list ->
?tags:string list -> string -> user_target
Construct a new target, the node of a workflow graph. The main argument (the string) is its name, then all optional arguments mean:


val file_target : ?depends_on:user_target list ->
?make:Build_process.t ->
?metadata:[ `String of string ] ->
?name:string ->
?host:Host.t ->
?equivalence:Ketrew_pure.Target.Equivalence.t ->
?on_failure_activate:user_target list ->
?on_success_activate:user_target list ->
?tags:string list -> string -> user_target
Create a file Ketrew.EDSL.user_artifact and the Ketrew.EDSL.user_target that produces it.

The ?product of the target will be the file given as argument on the host given by the ?host option (default: localhost using "/tmp").

The ?done_when condition will be the existence of that file.

This can be seen as a classical make-like file-producing target, but on any arbitrary host.


Utilities


val to_display_string : ?ansi_colors:bool -> ?indentation:int -> user_target -> string
Build a display-friendly string summarizing the workflow.