Skip to content

Commit

Permalink
Renamed closure workflow to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pveber committed Sep 13, 2018
1 parent 5685ae8 commit 65d7713
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions lib/base/workflow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type u =
sel : string list
}
| Shell of shell
| Closure of (env -> unit) step
| Plugin of (env -> unit) step

and 'a t = u

Expand All @@ -38,7 +38,7 @@ let id = function
| Input { id ; _ }
| Select { id ; _}
| Shell { id ; _ } -> id
| Closure { id ; _ } -> id
| Plugin { id ; _ } -> id

let compare u v =
String.compare (id u) (id v)
Expand All @@ -54,7 +54,7 @@ let select u q =
match u with
| Select { dir ; sel = p ; _ } -> k dir (p @ q)
| Input _
| Closure _
| Plugin _
| Shell _ -> k u q

let input ?(may_change = false) path =
Expand All @@ -70,7 +70,7 @@ let rec digestible_dep = function
`Select ((`Input p), q)
| Select { dir ; sel = p ; _ } ->
`Select (digestible_dep dir, p)
| Closure c -> `Closure c.id
| Plugin c -> `Plugin c.id

let digestible_cmd = Command.map ~f:digestible_dep

Expand All @@ -92,10 +92,10 @@ let closure
?version
id deps f =
let id = digest ("closure", version, id) in
Closure { descr ; task = f ; deps ; np ; mem ; version ; id }
Plugin { descr ; task = f ; deps ; np ; mem ; version ; id }

let deps = function
| Input _ -> []
| Select { dir ; _ } -> [ dir ]
| Shell s -> s.deps
| Closure s -> s.deps
| Plugin s -> s.deps
2 changes: 1 addition & 1 deletion lib/engine/console_logger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let error_short_descr =
| `Missing_output ->
"missing output"
)
| Closure { outcome ; _ } -> (
| Plugin { outcome ; _ } -> (
match outcome with
| `Succeeded -> assert false
| `Failed -> "failed"
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/db.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ let rec path : type s. t -> s Bistro_base.Workflow.t -> string = fun db ->
| Select s ->
Filename.concat (path db s.dir) (Path.to_string s.sel)
| Shell s -> cache db s.id
| Closure s -> cache db s.id
| Plugin s -> cache db s.id
4 changes: 2 additions & 2 deletions lib/engine/execution_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type container_mount = {
let container_mount db =
let open Workflow in
function
| Shell _ | Closure _ as u ->
| Shell _ | Plugin _ as u ->
{
mount_host_location = Db.cache_dir db ;
mount_container_location = docker_cache_dir ;
Expand All @@ -62,7 +62,7 @@ let container_mount db =
file_container_location = container_path ;
}

| Select { dir = (Shell _ | Closure _) as dir ; sel ; _ } ->
| Select { dir = (Shell _ | Plugin _) as dir ; sel ; _ } ->
{
mount_host_location = Db.cache_dir db ;
mount_container_location = docker_cache_dir ;
Expand Down
6 changes: 3 additions & 3 deletions lib/engine/scheduler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ and compute_task = function
Task.select ~dir ~sel
| Shell { task = cmd ; id ; descr ; np ; mem ; _ } ->
Task.shell ~id ~descr ~np ~mem cmd
| Closure { task = f ; id ; descr ; np ; mem; _} ->
| Plugin { task = f ; id ; descr ; np ; mem; _} ->
Task.closure ~id ~descr ~np ~mem f

and submit_for_eval sched w =
Expand Down Expand Up @@ -249,7 +249,7 @@ let eval_expr_main ?np ?mem ?loggers ?use_docker db expr =
* match w with
* | Input _ | Select _ | Shell _ ->
* regular_trace sched (Workflow.Any w)
* | Closure _ -> assert false
* | Plugin _ -> assert false
* )
* | `Some_dep_failed ->
* Lwt.return (Execution_trace.Skipped `Missing_dep)
Expand All @@ -270,7 +270,7 @@ let eval_expr_main ?np ?mem ?loggers ?use_docker db expr =
* Task.perform_select sched.config.db dir path
* | Shell shell ->
* Task.perform_shell sched.config resource shell
* | Closure _ -> assert false
* | Plugin _ -> assert false
* ) >>= fun outcome ->
* let _end_ = Unix.gettimeofday () in
* Allocator.release sched.allocator resource ;
Expand Down
12 changes: 6 additions & 6 deletions lib/engine/task.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type t =
mem : int ;
cmd : Workflow.u Command.t ;
}
| Closure of {
| Plugin of {
id : string ;
descr : string ;
np : int ;
Expand All @@ -31,7 +31,7 @@ type t =
let input ~id ~path = Input { id ; path }
let select ~dir ~sel = Select { dir ; sel }
let shell ~id ~descr ~np ~mem cmd = Shell { id ; cmd ; np ; mem ; descr }
let closure ~id ~descr ~np ~mem f = Closure { id ; f ; np ; mem ; descr }
let closure ~id ~descr ~np ~mem f = Plugin { id ; f ; np ; mem ; descr }

let step_outcome ~exit_code ~dest_exists=
match exit_code, dest_exists with
Expand All @@ -43,7 +43,7 @@ let requirement = function
| Input _
| Select _ ->
Allocator.Request { np = 0 ; mem = 0 }
| Closure { np ; mem ; _ }
| Plugin { np ; mem ; _ }
| Shell { np ; mem ; _ } ->
Allocator.Request { np ; mem }

Expand Down Expand Up @@ -108,7 +108,7 @@ let perform t config (Allocator.Resource { np ; mem }) =
stderr = env.stderr ;
})

| Closure { f ; id ; descr ; _ } ->
| Plugin { f ; id ; descr ; _ } ->
let env =
Execution_env.make
~use_docker:config.use_docker
Expand Down Expand Up @@ -166,7 +166,7 @@ let perform t config (Allocator.Resource { np ; mem }) =
else
Lwt.return ()
) >>= fun () ->
Lwt.return (Task_result.Closure {
Lwt.return (Task_result.Plugin {
id ;
descr ;
outcome ;
Expand Down Expand Up @@ -196,6 +196,6 @@ let is_done : type s. s Workflow.t -> Db.t -> bool Lwt.t = fun t db ->
| Input { id ; _ } -> Db.cache db id
| Select { dir ; sel ; _ } -> select_path db dir sel
| Shell { id ; _ } -> Db.cache db id
| Closure { id ; _ } -> Db.cache db id
| Plugin { id ; _ } -> Db.cache db id
in
Lwt.return (Sys.file_exists path = `Yes)
2 changes: 1 addition & 1 deletion lib/engine/task.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type t = private
mem : int ;
cmd : Workflow.u Command.t ;
}
| Closure of {
| Plugin of {
id : string ;
descr : string ;
np : int ;
Expand Down
8 changes: 4 additions & 4 deletions lib/engine/task_result.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type t =
stdout : string ;
stderr : string ;
}
| Closure of {
| Plugin of {
id : string ;
descr : string ;
outcome : [`Succeeded | `Missing_output | `Failed] ;
Expand All @@ -23,7 +23,7 @@ type t =
let succeeded = function
| Input { pass ; _ }
| Select { pass ; _ } -> pass
| Closure { outcome ; _ }
| Plugin { outcome ; _ }
| Shell { outcome ; _ } -> (
match outcome with
| `Succeeded -> true
Expand All @@ -43,10 +43,10 @@ let error_short_descr = function
let msg = "Task_outcome.error_short_descr: not an error result" in
raise (Invalid_argument msg)
)
| Closure { descr ; _ } -> sprintf "Closure %s failed" descr
| Plugin { descr ; _ } -> sprintf "Plugin %s failed" descr

let error_long_descr x db buf id = match x with
| Input _ | Select _ | Closure _ -> ()
| Input _ | Select _ | Plugin _ -> ()
| Shell x ->
(
bprintf buf "+------------------------------------------------------------------------------+\n" ;
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/task_result.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type t =
stdout : string ;
stderr : string ;
}
| Closure of {
| Plugin of {
id : string ;
descr : string ;
outcome : [`Succeeded | `Missing_output | `Failed] ;
Expand Down
14 changes: 7 additions & 7 deletions lib/utils/html_logger.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let create path = {
let translate_event db _ = function
| Logger.Task_started (
(Task.Shell {id ; descr ; _}
| Closure { id ; descr ; _ }), _) ->
| Plugin { id ; descr ; _ }), _) ->
Some (Step_task_started { id ; descr })

| Task_ended { outcome ; _ } ->
Expand Down Expand Up @@ -197,7 +197,7 @@ module Render = struct
p [ k "missing_output" ]
]
~body:(shell_result_details ~id:id ~cmd ~cache ~stderr ~stdout ~file_dumps)
| Closure { descr ; outcome ; _ } ->
| Plugin { descr ; outcome ; _ } ->
collapsible_panel
~title:[ k descr ]
~header:[
Expand Down Expand Up @@ -227,14 +227,14 @@ module Render = struct
k " in " ;
k input_path ] ]

| Select { dir = (Shell { id ; _ } | Closure { id ; _ }) ; sel ; _ } ->
| Select { dir = (Shell { id ; _ } | Plugin { id ; _ }) ; sel ; _ } ->
[ p [ k "select " ;
k (Path.to_string sel) ;
k " in step " ;
k id ] ]

| Select { dir = Select _ ; _} -> assert false
| Closure { descr ; id ; _ }
| Plugin { descr ; id ; _ }
| Shell { descr ; id ; _ } ->
collapsible_panel
~title:[ k descr ]
Expand All @@ -257,16 +257,16 @@ module Render = struct

| Input { pass = false ; _ }
| Select { pass = false ; _ }
| Closure { outcome = `Failed ; _ }
| Plugin { outcome = `Failed ; _ }
| Shell { outcome = `Failed ; _ } ->
event_label_text `RED "FAILED"

| Closure { outcome = `Missing_output ; _ }
| Plugin { outcome = `Missing_output ; _ }
| Shell { outcome = `Missing_output ; _ } ->
event_label_text `RED "MISSING OUTPUT"

| Shell { outcome = `Succeeded ; _ }
| Closure { outcome = `Succeeded ; _ } ->
| Plugin { outcome = `Succeeded ; _ } ->
event_label_text `GREEN "DONE"


Expand Down

0 comments on commit 65d7713

Please sign in to comment.