text
stringlengths
12
786k
module Make ( Event : Worker_intf . EVENT ) ( Request : Worker_intf . VIEW ) ( Static : STATIC ) : Worker_intf . LOGGER with module Event = Event and module Request = Request = struct module Event = Event module Request = Request type status = | WorkerEvent of ( Event . t * Internal_event . level ) | Request of ( Request . view * Worker_types . request_status * error list option ) | Terminated | Timeout | Crashed of error list | Started of string option | Triggering_shutdown | Duplicate of string type t = status Time . System . stamped let status_encoding = let open Data_encoding in Time . System . stamped_encoding @@ union [ case ( Tag 0 ) ~ title " : Event " ( obj2 ( req " event " @@ dynamic_size Event . encoding ) ( req " level " Internal_event . Level . encoding ) ) ( function WorkerEvent ( e , l ) -> Some ( e , l ) | _ -> None ) ( fun ( e , l ) -> WorkerEvent ( e , l ) ) ; case ( Tag 1 ) ~ title " : Request " ( obj3 ( req " request_view " @@ dynamic_size Request . encoding ) ( req " request_status " Worker_types . request_status_encoding ) ( req " errors " ( option ( list error_encoding ) ) ) ) ( function Request ( v , s , e ) -> Some ( v , s , e ) | _ -> None ) ( fun ( v , s , e ) -> Request ( v , s , e ) ) ; case ( Tag 2 ) ~ title " : Terminated " Data_encoding . empty ( function Terminated -> Some ( ) | _ -> None ) ( fun ( ) -> Terminated ) ; case ( Tag 3 ) ~ title " : Timeout " Data_encoding . empty ( function Timeout -> Some ( ) | _ -> None ) ( fun ( ) -> Timeout ) ; case ( Tag 4 ) ~ title " : Crashed " ( list error_encoding ) ( function Crashed errs -> Some errs | _ -> None ) ( fun errs -> Crashed errs ) ; case ( Tag 5 ) ~ title " : Started " ( option string ) ( function Started n -> Some n | _ -> None ) ( fun n -> Started n ) ; case ( Tag 6 ) ~ title " : Triggering_shutdown " Data_encoding . empty ( function Triggering_shutdown -> Some ( ) | _ -> None ) ( fun ( ) -> Triggering_shutdown ) ; case ( Tag 7 ) ~ title " : Duplicate " string ( function Duplicate n -> Some n | _ -> None ) ( fun n -> Duplicate n ) ; ] let pp base_name ppf = function | WorkerEvent ( evt , _ ) -> Format . fprintf ppf " % a " Event . pp evt | Request ( view , { pushed ; treated ; completed } , None ) -> Format . fprintf ppf " [ @< v 0 >% a , @ % a ] " @ Request . pp view Worker_types . pp_status { pushed ; treated ; completed } | Request ( view , { pushed ; treated ; completed } , Some errors ) -> Format . fprintf ppf " [ @< v 0 >% a , @ % a , % a ] " @ Request . pp view Worker_types . pp_status { pushed ; treated ; completed } ( Format . pp_print_list Error_monad . pp ) errors | Terminated -> Format . fprintf ppf " [ @ Worker terminated [ % s ] ] " @ base_name | Timeout -> Format . fprintf ppf " [ @ Worker terminated with timeout [ % s ] ] " @ base_name | Crashed errs -> Format . fprintf ppf " [ @< v 0 > Worker crashed [ % s ] , :@% a ] " @ base_name ( Format . pp_print_list Error_monad . pp ) errs | Started None -> Format . fprintf ppf " Worker started " | Started ( Some n ) -> Format . fprintf ppf " Worker started for % s " n | Triggering_shutdown -> Format . fprintf ppf " Triggering shutdown " | Duplicate name -> let full_name = if name = " " then base_name else Format . asprintf " % s_ % s " base_name name in Format . fprintf ppf " Worker . launch : duplicate worker % s " full_name module Definition : Internal_event . EVENT_DEFINITION with type t = t = struct let section = None let name = Static . worker_name type nonrec t = t let encoding = let open Data_encoding in let v0_encoding = status_encoding in With_version . ( encoding ~ name ( first_version v0_encoding ) ) let pp ~ short : _ ppf ( status : t ) = Format . fprintf ppf " % a " ( pp Static . worker_name ) status . data let doc = " Worker status . " let level ( status : t ) = match status . data with | WorkerEvent ( _ , level ) -> level | Request _ -> Internal_event . Debug | Timeout -> Internal_event . Notice | Terminated | Started _ -> Internal_event . Info | Crashed _ -> Internal_event . Error | Triggering_shutdown -> Internal_event . Debug | Duplicate _ -> Internal_event . Error end module LogEvent : Internal_event . EVENT with type t = t = Internal_event . Make ( Definition ) end
type context = { worker : Worker . t ; timeout : int ; timeout_fn : unit -> unit ; waiting : ( ( Jv . t , exn ) exn Result . t Lwt_mvar . t * int ) int Queue . t ; }
let demux context msg = Lwt . async ( fun ( ) -> match Queue . take_opt context . waiting with | None -> Lwt . return ( ) | Some ( mv , outstanding_execution ) outstanding_execution -> Brr . G . stop_timer outstanding_execution ; let msg : Jv . t = Message . Ev . data ( Brr . Ev . as_type msg ) msg in Lwt_mvar . put mv ( Ok msg ) msg ) msg
let start worker timeout timeout_fn = let context = { worker ; timeout ; timeout_fn ; waiting = Queue . create ( ) } in let ( ) = Brr . Ev . listen Message . Ev . message ( demux context ) context ( Worker . as_target worker ) worker in context
let rpc context call = let open Lwt in let jv = Conv . jv_of_rpc_call call in let mv = Lwt_mvar . create_empty ( ) in let outstanding_execution = Brr . G . set_timeout ~ ms : 10000 ( fun ( ) -> Lwt . async ( fun ( ) -> Lwt_mvar . put mv ( Error Timeout ) Timeout ) Timeout ; context . timeout_fn ( ) ) in Queue . push ( mv , outstanding_execution ) outstanding_execution context . waiting ; Worker . post context . worker jv ; Lwt_mvar . take mv >>= fun r -> match r with | Ok jv -> let response = Conv . rpc_response_of_jv jv in Lwt . return response | Error exn -> Lwt . fail exn
module Prevalidators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the Prevalidator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " chain_id " Chain_id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_error . encoding ) ) ( req " information " ( Worker_types . worker_information_encoding RPC_error . encoding ) ) ( req " pipelines " int16 ) ) ) RPC_path . ( root / " workers " / " prevalidators " ) let state = RPC_service . get_service ~ description " : Introspect the state of prevalidator workers . " ~ query : RPC_query . empty ~ output : ( Worker_types . full_status_encoding Prevalidator_worker_state . Request . encoding RPC_error . encoding ) RPC_path . ( root / " workers " / " prevalidators " /: Chain_services . chain_arg ) end open RPC_context let list ctxt = make_call S . list ctxt ( ) ( ) ( ) let state ctxt h = make_call1 S . state ctxt h ( ) ( ) end
module Block_validator = struct module S = struct let state = RPC_service . get_service ~ description " : Introspect the state of the block_validator worker . " ~ query : RPC_query . empty ~ output : ( Worker_types . full_status_encoding Block_validator_worker_state . Request . encoding RPC_error . encoding ) RPC_path . ( root / " workers " / " block_validator " ) end open RPC_context let state ctxt = make_call S . state ctxt ( ) ( ) ( ) end
module Peer_validators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the peer validator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " peer_id " P2p_peer . Id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_error . encoding ) ) ( req " information " ( Worker_types . worker_information_encoding RPC_error . encoding ) ) ( req " pipelines " Peer_validator_worker_state . pipeline_length_encoding ) ) ) RPC_path . ( root / " workers " / " chain_validators " /: Chain_services . chain_arg / " peers_validators " ) let state = RPC_service . get_service ~ description " : Introspect the state of a peer validator worker . " ~ query : RPC_query . empty ~ output : ( Worker_types . full_status_encoding Peer_validator_worker_state . Request . encoding RPC_error . encoding ) RPC_path . ( root / " workers " / " chain_validators " /: Chain_services . chain_arg / " peers_validators " /: P2p_peer . Id . rpc_arg ) end open RPC_context let list ctxt n = make_call1 S . list ctxt n ( ) ( ) let state ctxt n h = make_call2 S . state ctxt n h ( ) ( ) end
module Chain_validators = struct module S = struct let list = RPC_service . get_service ~ description " : Lists the chain validator workers and their status . " ~ query : RPC_query . empty ~ output : ( list ( obj4 ( req " chain_id " Chain_id . encoding ) ( req " status " ( Worker_types . worker_status_encoding RPC_error . encoding ) ) ( req " information " ( Worker_types . worker_information_encoding RPC_error . encoding ) ) ( req " pipelines " int16 ) ) ) RPC_path . ( root / " workers " / " chain_validators " ) let state = RPC_service . get_service ~ description " : Introspect the state of a chain validator worker . " ~ query : RPC_query . empty ~ output : ( Worker_types . full_status_encoding Chain_validator_worker_state . Request . encoding RPC_error . encoding ) RPC_path . ( root / " workers " / " chain_validators " /: Chain_services . chain_arg ) let ddb_state = RPC_service . get_service ~ description : " Introspect the state of the DDB attached to a chain validator \ worker . " ~ query : RPC_query . empty ~ output : Chain_validator_worker_state . Distributed_db_state . encoding RPC_path . ( root / " workers " / " chain_validators " /: Chain_services . chain_arg / " ddb " ) end open RPC_context let list ctxt = make_call S . list ctxt ( ) ( ) ( ) let state ctxt h = make_call1 S . state ctxt h ( ) ( ) let ddb_state ctxt h = make_call1 S . ddb_state ctxt h ( ) ( ) end
module type Base_intf = sig type t type create_args type input type output val create : create_args -> t val close : t -> unit Deferred . t end
module type Worker_intf = sig include Base_intf val perform : t -> input -> output Deferred . t end
module type S = sig include Base_intf val is_working : t -> bool val dispatch : t -> input -> output Deferred . t end
module Make ( Worker : Worker_intf ) Worker_intf : S with type create_args := Worker . create_args and type input := Worker . input and type output := Worker . output = struct type t = { mutable thread : Worker . output Deferred . t option ; worker : Worker . t } let create args = { thread = None ; worker = Worker . create args } let is_working t = Option . value_map t . thread ~ default : false ~ f : Deferred . is_determined let assert_not_working t = if is_working t then failwith " cannot dispatch to busy worker " let dispatch t work = assert_not_working t ; let thread = Worker . perform t . worker work in t . thread <- Some thread ; let % map x = thread in t . thread <- None ; x let close t = assert_not_working t ; Worker . close t . worker end
type worker_status = | Launching of Time . System . t | Running of Time . System . t | Closing of Time . System . t * Time . System . t | Closed of Time . System . t * Time . System . t * error list option
let worker_status_encoding error_encoding = let open Data_encoding in union [ case ( Tag 0 ) ~ title " : Launching " ( obj2 ( req " phase " ( constant " launching " ) ) ( req " since " Time . System . encoding ) ) ( function Launching t -> Some ( ( ) , t ) | _ -> None ) ( fun ( ( ) , t ) -> Launching t ) ; case ( Tag 1 ) ~ title " : Running " ( obj2 ( req " phase " ( constant " running " ) ) ( req " since " Time . System . encoding ) ) ( function Running t -> Some ( ( ) , t ) | _ -> None ) ( fun ( ( ) , t ) -> Running t ) ; case ( Tag 2 ) ~ title " : Closing " ( obj3 ( req " phase " ( constant " closing " ) ) ( req " birth " Time . System . encoding ) ( req " since " Time . System . encoding ) ) ( function Closing ( t0 , t ) -> Some ( ( ) , t0 , t ) | _ -> None ) ( fun ( ( ) , t0 , t ) -> Closing ( t0 , t ) ) ; case ( Tag 3 ) ~ title " : Closed " ( obj3 ( req " phase " ( constant " closed " ) ) ( req " birth " Time . System . encoding ) ( req " since " Time . System . encoding ) ) ( function Closed ( t0 , t , None ) -> Some ( ( ) , t0 , t ) | _ -> None ) ( fun ( ( ) , t0 , t ) -> Closed ( t0 , t , None ) ) ; case ( Tag 4 ) ~ title " : Crashed " ( obj4 ( req " phase " ( constant " crashed " ) ) ( req " birth " Time . System . encoding ) ( req " since " Time . System . encoding ) ( req " errors " error_encoding ) ) ( function | Closed ( t0 , t , Some errs ) -> Some ( ( ) , t0 , t , errs ) | _ -> None ) ( fun ( ( ) , t0 , t , errs ) -> Closed ( t0 , t , Some errs ) ) ; ]
type worker_information = { instances_number : int ; wstatus : worker_status ; queue_length : int ; }
let worker_information_encoding error_encoding = Data_encoding . ( conv ( fun { instances_number ; wstatus ; queue_length } -> ( instances_number , wstatus , queue_length ) ) ( fun ( instances_number , wstatus , queue_length ) -> { instances_number ; wstatus ; queue_length } ) ( obj3 ( req " instances " int31 ) ( req " status " ( worker_status_encoding error_encoding ) ) ( req " queue_length " int31 ) ) )
type request_status = { pushed : Time . System . t ; treated : Time . System . Span . t ; completed : Time . System . Span . t ; }
let request_status_encoding = let open Data_encoding in conv ( fun { pushed ; treated ; completed } -> ( pushed , treated , completed ) ) ( fun ( pushed , treated , completed ) -> { pushed ; treated ; completed } ) ( obj3 ( req " pushed " Time . System . encoding ) ( req " treated " Time . System . Span . encoding ) ( req " completed " Time . System . Span . encoding ) )
type ' req full_status = { status : worker_status ; pending_requests : ( Time . System . t * ' req ) list ; current_request : ( Time . System . t * Time . System . t * ' req ) option ; }
let full_status_encoding req_encoding error_encoding = let open Data_encoding in let requests_encoding = list ( obj2 ( req " pushed " Time . System . encoding ) ( req " request " ( dynamic_size req_encoding ) ) ) in let current_request_encoding = obj3 ( req " pushed " Time . System . encoding ) ( req " treated " Time . System . encoding ) ( req " request " req_encoding ) in conv ( fun { status ; pending_requests ; current_request } -> ( status , pending_requests , current_request ) ) ( fun ( status , pending_requests , current_request ) -> { status ; pending_requests ; current_request } ) ( obj3 ( req " status " ( worker_status_encoding error_encoding ) ) ( req " pending_requests " requests_encoding ) ( opt " current_request " current_request_encoding ) )
let pp_status ppf { pushed ; treated ; completed } = Format . fprintf ppf " Request pushed on % a , treated in % a , completed in % a " Time . System . pp_hum pushed Ptime . Span . pp treated Ptime . Span . pp completed
type path = | FS_path of string | Cache_id of string | Cd of path * string list
let cd dir sel = match dir with | Cd ( indir , insel ) -> Cd ( indir , insel @ sel ) | FS_path _ | Cache_id _ -> Cd ( dir , sel )
module Docker_image = struct type t = { account : string ; name : string ; tag : string option ; registry : string option ; } end
module Singularity_image = struct type t = { account : string ; name : string ; tag : string option ; registry : string option ; } end
type container_image = | Docker_image of Docker_image . t | Singularity_image of Singularity_image . t
let docker_image ? tag ? registry ~ account ~ name ( ) = Docker_image { account = account ; name = name ; tag = tag ; registry = registry ; }
type _ t = | Pure : { id : string ; value : ' a } -> ' a t | App : { id : string ; f : ( ' a -> ' b ) t ; x : ' a t ; } -> ' b t | Both : { id : string ; fst : ' a t ; snd : ' b t ; } -> ( ' a ' * b ) t | List : { id : string ; elts : ' a t list ; } -> ' a list t | Eval_path : { id : string ; workflow : path t } -> string t | Spawn : { id : string ; elts : ' a list t ; f : ' a t -> ' b t ; deps : any list ; } -> ' b list t | List_nth : { id : string ; elts : ' a list t ; index : int ; } -> ' a t | Input : { id : string ; path : string ; version : int option } -> path t | Select : { id : string ; dir : path t ; sel : string list ; } -> path t | Plugin : ( ' a plugin , any ) step -> ' a t | Shell : ( shell_command , any ) step -> path t | Glob : { id : string ; pattern : string option ; type_selection : [ ` File | ` Directory ] option ; dir : path t ; } -> path list t | Trywith : { id : string ; w : ' a t ; failsafe : ' a t ; } -> ' a t | Ifelse : { id : string ; cond : bool t ; _then_ : ' a t ; _else_ : ' a t ; } -> ' a t id : string ; descr : string ; task : ' a ; np : int ; mem : int t option ; version : int option ; deps : ' b list ; } | Value_plugin : ( unit -> ' a ) t -> ' a plugin | Path_plugin : ( string -> unit ) t -> path plugin cmd : token Command . t ; images : container_image list ; } | Path_token of path t | Path_list_token of { elts : path list t ; sep : string ; quote : char option ; } | String_token of string t
let digest x = Digest . to_hex ( Digest . string ( Marshal . ( to_string x [ No_sharing ] ) ) )
let id : type s . s t -> string = function | Input { id ; _ } -> id | Select { id ; _ } -> id | Plugin { id ; _ } -> id | Pure { id ; _ } -> id | App { id ; _ } -> id | Spawn { id ; _ } -> id | Both { id ; _ } -> id | Eval_path { id ; _ } -> id | Shell { id ; _ } -> id | List { id ; _ } -> id | List_nth { id ; _ } -> id | Glob { id ; _ } -> id | Trywith { id ; _ } -> id | Ifelse { id ; _ } -> id
let any x = Any x
let compare_token x y = match x , y with | Path_token wx , Path_token wy -> String . compare ( id wx ) ( id wy ) | Path_token _ , _ -> - 1 | Path_list_token x , Path_list_token y -> ( match String . compare ( id x . elts ) ( id y . elts ) with | 0 -> compare ( x . sep , x . quote ) ( y . sep , y . quote ) | i -> i ) | Path_list_token _ , _ -> - 1 | String_token wx , String_token wy -> String . compare ( id wx ) ( id wy ) | String_token _ , _ -> 1
module Any = struct module T = struct type t = any let id ( Any w ) = id w let compare x y = String . compare ( id x ) ( id y ) let equal x y = String . equal ( id x ) ( id y ) let hash x = Hashtbl . hash ( id x ) end module Set = Set . Make ( T ) module Table = Hashtbl . Make ( T ) module Map = Map . Make ( T ) include T let deps ( Any w ) = match w with | Pure _ -> [ ] | App app -> [ Any app . f ; Any app . x ] | Both p -> [ Any p . fst ; Any p . snd ] | List l -> List . map any l . elts | Eval_path { workflow ; _ } -> [ Any workflow ] | Spawn s -> s . deps | List_nth l -> [ Any l . elts ] | Input _ -> [ ] | Select sel -> [ any sel . dir ] | Plugin v -> v . deps | Shell s -> s . deps | Glob g -> [ Any g . dir ] | Trywith tw -> [ Any tw . w ; Any tw . failsafe ] | Ifelse ie -> [ Any ie . cond ; Any ie . _then_ ; Any ie . _else_ ] let descr ( Any w ) = match w with | Shell s -> Some s . descr | Plugin s -> Some s . descr | Input i -> Some i . path | Select s -> Some ( List . fold_left Filename . concat " " s . sel ) | _ -> None let rec fold_aux w ~ seen ~ init ~ f = if Set . mem w seen then init , seen else let acc , seen = List . fold_left ( fun ( acc , seen ) w -> fold_aux w ~ seen ~ init : acc ~ f ) ( init , seen ) ( deps w ) in f acc w , Set . add w seen let fold w ~ init ~ f = fold_aux w ~ seen : Set . empty ~ init ~ f |> fst end
let input ? version path = let id = digest ( ` Input , path , version ) in Input { id ; path ; version }
let select dir sel = let dir , sel = match dir with | Select { dir ; sel = root ; _ } -> dir , root @ sel | Input _ | Plugin _ | Shell _ -> dir , sel | _ -> assert false in let id = digest ( " select " , id dir , sel ) in Select { id ; dir ; sel }
let pure ~ id value = Pure { id ; value }
let data value = pure ~ id ( : digest value ) value
let app f x = let id = digest ( ` App , id f , id x ) in App { id ; f ; x }
let ( $ ) = app
let both fst snd = let id = digest ( ` Both , id fst , id snd ) in Both { id ; fst ; snd }
let add_mem_dep mem deps = match mem with | None -> deps | Some mem -> any mem :: deps
let plugin ( ? descr = " " ) ( ? np = 1 ) ? mem ? version workflow = let id = digest ( ` Value , id workflow , version ) in Plugin { id ; descr ; np ; mem ; version ; task = Value_plugin workflow ; deps = add_mem_dep mem [ any workflow ] }
let path_plugin ( ? descr = " " ) ( ? np = 1 ) ? mem ? version workflow = let id = digest ( ` Value , id workflow , version ) in Plugin { id ; descr ; np ; mem ; version ; task = Path_plugin workflow ; deps = add_mem_dep mem [ any workflow ] }
let path w = Eval_path { id = digest ( ` Eval_path , id w ) ; workflow = w }
let digestible_cmd = Command . map ~ f ( : function | Path_token w -> id w | Path_list_token { elts ; sep ; quote } -> digest ( id elts , sep , quote ) | String_token w -> id w )
let shell ( ? descr = " " ) ? mem ( ? np = 1 ) ? version ( ? img = [ ] ) cmds = let cmd = Command . And_list cmds in let shell_cmd = { cmd ; images = img ; } in let id = digest ( " shell " , version , digestible_cmd cmd ) in let deps = add_mem_dep mem ( Command . deps cmd ~ compare : compare_token |> List . map ( function | Path_token w -> any w | Path_list_token { elts ; _ } -> any elts | String_token s -> any s ) ) in Shell { descr ; task = shell_cmd ; np ; mem ; version ; id ; deps }
let list elts = let id = digest ( " list " , List . map id elts ) in List { id ; elts }
let rec independent_workflows_aux cache w ~ from : u = if Any . equal w u then Any . Map . add w ( true , Any . Set . empty ) cache else if Any . Map . mem w cache then cache else ( let deps = Any . deps w in let f acc w = independent_workflows_aux acc w ~ from : u in let cache = List . fold_left f cache deps in let children = List . map ( fun k -> Any . Map . find k cache ) deps in if List . exists fst children then let union = List . fold_left ( fun acc ( _ , s ) -> Any . Set . union acc s ) Any . Set . empty children in Any . Map . add w ( true , union ) cache else Any . Map . add w ( false , Any . Set . singleton w ) cache )
let independent_workflows w ~ from : u = let cache = independent_workflows_aux Any . Map . empty w ~ from : u in Any . Map . find w cache |> snd |> Any . Set . elements
let spawn elts ~ f = let hd = pure ~ id " : __should_never_be_executed__ " List . hd in let u = app hd elts in let f_u = f u in let id = digest ( ` Spawn , id elts , id f_u ) in let deps = any elts :: independent_workflows ( any f_u ) ~ from ( : any u ) in Spawn { id ; elts ; f ; deps }
let list_nth w i = let id = digest ( ` List_nth , id w , i ) in List_nth { id ; elts = w ; index = i }
let glob ? pattern ? type_selection dir = let id = digest ( ` Glob , id dir , pattern , type_selection ) in Glob { id ; dir ; pattern ; type_selection }
let trywith w failsafe = let id = digest ( ` Trywith , id w , id failsafe ) in Trywith { id ; w ; failsafe }
let ifelse cond _then_ _else_ = let id = digest ( ` Ifelse , id cond , id _then_ , id _else_ ) in Ifelse { id ; cond ; _then_ ; _else_ }
module Remove = struct let file ~ run_with path = let open KEDSL in workflow_node nothing ~ name ( : sprintf " rm -% s " ( Filename . basename path ) ) ~ ensures ( ` : Is_verified ( ` Command_returns ( Command . shell ~ host : Machine . ( as_host run_with ) ( sprintf " ls % s " path ) , 2 ) ) ) ~ make ( : Machine . quick_run_program run_with Program . ( exec [ " rm " ; " - f " ; path ] ) ) ~ tags [ : Target_tags . clean_up ] let directory ~ run_with path = let open KEDSL in workflow_node nothing ~ name ( : sprintf " rmdir -% s " ( Filename . basename path ) ) ~ ensures ( ` : Is_verified ( ` Command_returns ( Command . shell ~ host : Machine . ( as_host run_with ) ( sprintf " ls % s " path ) , 2 ) ) ) ~ make ( : Machine . quick_run_program run_with Program . ( exec [ " rm " ; " - rf " ; path ] ) ) ~ tags [ : Target_tags . clean_up ] let path_on_host ~ host path = let open KEDSL in workflow_node nothing ~ name ( : sprintf " rm -% s " ( Filename . basename path ) ) ~ make ( : daemonize ~ using ` : Python_daemon ~ host Program . ( exec [ " rm " ; " - rf " ; path ] ) ) end
module Gunzip = struct let concat ( ~ run_with : Machine . t ) bunch_of_dot_gzs ~ result_path = let open KEDSL in let program = Program . ( exec [ " mkdir " ; " - p " ; Filename . dirname result_path ] && shf " gunzip - c % s > % s " ( List . map bunch_of_dot_gzs ~ f ( : fun o -> Filename . quote o # product # path ) |> String . concat ~ sep " : " ) result_path ) in let name = sprintf " gunzipcat -% s " ( Filename . basename result_path ) in workflow_node ( single_file result_path ~ host : Machine . ( as_host run_with ) ) ~ name ~ make ( : Machine . run_stream_processor ~ name run_with program ) ~ edges ( : on_failure_activate Remove . ( file ~ run_with result_path ) :: List . map ~ f : depends_on bunch_of_dot_gzs ) end
module Cat = struct let concat ( ~ run_with : Machine . t ) bunch_of_files ~ result_path = let open KEDSL in let program = Program . ( exec [ " mkdir " ; " - p " ; Filename . dirname result_path ] && shf " cat % s > % s " ( List . map bunch_of_files ~ f ( : fun o -> Filename . quote o # product # path ) |> String . concat ~ sep " : " ) result_path ) in let name = sprintf " concat - all -% s " ( Filename . basename result_path ) in workflow_node ( single_file result_path ~ host : Machine . ( as_host run_with ) ) ~ name ~ edges ( : on_failure_activate Remove . ( file ~ run_with result_path ) :: List . map ~ f : depends_on bunch_of_files ) ~ make ( : Machine . run_stream_processor run_with ~ name program ) let cat_folder ~ host ( ~ run_program : Machine . Make_fun . t ) ( ? depends_on [ ] ) = ~ files_gzipped ~ folder ~ destination = let deps = depends_on in let open KEDSL in let name = " cat - folder " - ^ Filename . quote folder in let edges = on_failure_activate ( Remove . path_on_host ~ host destination ) :: List . map ~ f : depends_on deps in if files_gzipped then ( workflow_node ( single_file destination ~ host ) ~ edges ~ name ~ make ( : run_program ~ name Program . ( shf " gunzip - c % s /* > % s " ( Filename . quote folder ) ( Filename . quote destination ) ) ) ) else ( workflow_node ( single_file destination ~ host ) ~ edges ~ name ~ make ( : run_program ~ name Program . ( shf " cat % s /* > % s " ( Filename . quote folder ) ( Filename . quote destination ) ) ) ) end
module Download = struct let wget_program ? output_filename url = KEDSL . Program . exec [ " wget " ; " - O " ; Option . value output_filename ~ default : Filename . ( basename url ) ; url ] let wget_to_folder ~ host ( ~ run_program : Machine . Make_fun . t ) ~ test_file ~ destination url = let open KEDSL in let name = " wget " - ^ Filename . basename destination in let test_target = destination // test_file in workflow_node ( single_file test_target ~ host ) ~ name ~ make ( : run_program ~ name ~ requirements ( : Machine . Make_fun . downloading [ ] ) Program . ( exec [ " mkdir " ; " - p " ; destination ] && shf " wget % s - P % s " ( Filename . quote url ) ( Filename . quote destination ) ) ) ~ edges [ : on_failure_activate ( Remove . path_on_host ~ host destination ) ; ] let wget ~ host ( ~ run_program : Machine . Make_fun . t ) url destination = let open KEDSL in let name = " wget " - ^ Filename . basename destination in workflow_node ( single_file destination ~ host ) ~ name ~ make ( : run_program ~ name ~ requirements ( : Machine . Make_fun . downloading [ ] ) Program . ( exec [ " mkdir " ; " - p " ; Filename . dirname destination ] && shf " wget % s - O % s " ( Filename . quote url ) ( Filename . quote destination ) ) ) ~ edges [ : on_failure_activate ( Remove . path_on_host ~ host destination ) ; ] let wget_gunzip ~ host ( ~ run_program : Machine . Make_fun . t ) ~ destination url = let open KEDSL in let is_gz = Filename . check_suffix url " . gz " in if is_gz then ( let name = " gunzip " - ^ Filename . basename ( destination ^ " . gz " ) in let wgot = wget ~ host ~ run_program url ( destination ^ " . gz " ) in workflow_node ( single_file destination ~ host ) ~ edges [ : depends_on ( wgot ) ; on_failure_activate ( Remove . path_on_host ~ host destination ) ; ] ~ name ~ make ( : run_program ~ name ~ requirements ( : Machine . Make_fun . stream_processor [ ] ) Program . ( shf " gunzip - c % s > % s " ( Filename . quote wgot # product # path ) ( Filename . quote destination ) ) ) ) else ( wget ~ host ~ run_program url destination ) let wget_bunzip2 ~ host ( ~ run_program : Machine . Make_fun . t ) ~ destination url = let open KEDSL in let is_bz2 = Filename . check_suffix url " . bz2 " in if is_bz2 then ( let name = " bunzip2 " - ^ Filename . basename ( destination ^ " . bz2 " ) in let wgot = wget ~ host ~ run_program url ( destination ^ " . bz2 " ) in workflow_node ( single_file destination ~ host ) ~ edges [ : depends_on ( wgot ) ; on_failure_activate ( Remove . path_on_host ~ host destination ) ; ] ~ name ~ make ( : run_program ~ name ~ requirements ( : Machine . Make_fun . stream_processor [ ] ) Program . ( shf " bunzip2 - c % s > % s " ( Filename . quote wgot # product # path ) ( Filename . quote destination ) ) ) ) else ( wget ~ host ~ run_program url destination ) let wget_untar ~ host ( ~ run_program : Machine . Make_fun . t ) ~ destination_folder ~ tar_contains url = let open KEDSL in let zip_flags = let is_gz = Filename . check_suffix url " . gz " in let is_bzip = Filename . check_suffix url " . bz2 " in if is_gz then " z " else if is_bzip then " j " else " " in let tar_filename = ( destination_folder // " archive . tar " ) in let name = " untar " - ^ tar_filename in let wgot = wget ~ host ~ run_program url tar_filename in let file_in_tar = ( destination_folder // tar_contains ) in workflow_node ( single_file file_in_tar ~ host ) ~ edges [ : depends_on ( wgot ) ; on_failure_activate ( Remove . path_on_host ~ host destination_folder ) ; ] ~ name ~ make ( : run_program ~ name ~ requirements ( : Machine . Make_fun . stream_processor [ ] ) Program . ( exec [ " mkdir " ; " - p " ; destination_folder ] && shf " tar - x % s - f % s - C % s " zip_flags ( Filename . quote wgot # product # path ) ( Filename . quote destination_folder ) ) ) type tool_file_location = [ | ` Scp of string | ` Wget of string | ` Fail of string ] let get_tool_file ~ identifier ( ~ run_program : Machine . Make_fun . t ) ~ host ~ install_path loc = let open KEDSL in let rm_path = Remove . path_on_host in let jar_name = match loc with | ` Fail s -> sprintf " cannot - get -% s . file " identifier | ` Scp s -> Filename . basename s | ` Wget s -> Filename . basename s in let local_box_path = install_path // jar_name in workflow_node ( single_file local_box_path ~ host ) ~ name ( : sprintf " get -% s " jar_name ) ~ edges [ : on_failure_activate ( rm_path ~ host local_box_path ) ] ~ make ( : run_program ~ requirements [ : ` Internet_access ; ` Self_identification [ identifier ^ " - instalation " ; jar_name ] ; ] Program . ( shf " mkdir - p % s " install_path && begin match loc with | ` Fail msg -> shf " echo ' Cannot download file for % s : % s ' " identifier msg && sh " exit 4 " | ` Scp s -> shf " scp % s % s " ( Filename . quote s ) ( Filename . quote local_box_path ) | ` Wget s -> shf " wget % s - O % s " ( Filename . quote s ) ( Filename . quote local_box_path ) end ) ) let gsutil_cp ( ~ run_program : Machine . Make_fun . t ) ~ host ~ url ~ local_path = let open KEDSL in workflow_node ( single_file ~ host local_path ) ~ name ( : sprintf " GSUtil - CP : % s " ( Filename . basename local_path ) ) ~ edges [ : on_failure_activate ( Remove . path_on_host ~ host local_path ) ] ~ make ( : run_program ~ requirements [ : ` Internet_access ; ` Self_identification [ " gsutil - cp " ; url ] ; ] Program . ( shf " mkdir - p % s " ( Filename . dirname local_path ) && exec [ " gsutil " ; " cp " ; url ; local_path ] ) ) end
module Vcftools = struct let vcf_process_n_to_1_no_machine ~ host ~ vcftools ( ~ run_program : Machine . Make_fun . t ) ( ? more_edges = [ ] ) ~ vcfs ~ make_product ~ final_vcf command_prefix = let open KEDSL in let name = sprintf " % s -% s " command_prefix ( Filename . basename final_vcf ) in let make = run_program ~ name Program . ( Machine . Tool . ( init vcftools ) && shf " % s % s > % s " command_prefix ( String . concat ~ sep " : " ( List . map vcfs ~ f ( : fun t -> Filename . quote t # product # path ) ) ) final_vcf ) in workflow_node ~ name ( make_product final_vcf ) ~ make ~ edges ( : on_failure_activate ( Remove . path_on_host ~ host final_vcf ) :: depends_on Machine . Tool . ( ensure vcftools ) :: List . map ~ f : depends_on vcfs @ more_edges ) let vcf_concat_no_machine ~ host ~ vcftools ( ~ run_program : Machine . Make_fun . t ) ? more_edges ~ make_product vcfs ~ final_vcf = vcf_process_n_to_1_no_machine ~ make_product ~ host ~ vcftools ~ run_program ? more_edges ~ vcfs ~ final_vcf " vcf - concat " let vcf_sort_no_machine ~ host ~ vcftools ( ~ run_program : Machine . Make_fun . t ) ? more_edges ~ make_product ~ src ~ dest ( ) = let run_program = Machine . Make_fun . with_requirements run_program [ ` Memory ` Big ] in vcf_process_n_to_1_no_machine ~ make_product ~ host ~ vcftools ~ run_program ? more_edges ~ vcfs [ : src ] ~ final_vcf : dest " vcf - sort - c " end
module Variable_tool_paths = struct let single_file ~ run_with ~ tool path = let open KEDSL in let condition = let init = Machine . Tool . init tool in let host = Machine . as_host ~ with_shell " : bash " run_with in let condition_cmd = Ketrew_pure . Program . to_single_shell_command Program . ( init && shf " test - e % s " path ) in KEDSL . Command . shell ~ host condition_cmd in object method is_done = Some ( ` Command_returns ( condition , 0 ) ) end end
module type Work_list = sig type elt type t val empty : t val is_empty : t -> bool val push : Remanent_parameters_sig . parameters -> Exception . method_handler -> elt -> t -> Exception . method_handler * t val pop : Remanent_parameters_sig . parameters -> Exception . method_handler -> t -> Exception . method_handler * ( elt option * t ) val fold_left : ( ' a -> elt -> ' a ) -> ' a -> t -> ' a val print_wl : Remanent_parameters_sig . parameters -> t -> unit end
module WlMake ( Ord : OrderedType with type t = int ) = ( struct module WSetMap = Map_wrapper . Make ( SetMap . Make ( Ord ) ) module WSet = WSetMap . Set type elt = Ord . t type t = elt list * elt list * WSet . t let empty = [ ] , [ ] , WSet . empty let is_empty x = let _ , _ , pool = x in WSet . is_empty pool let push parameter error e x = let in_list , out_list , pool = x in if WSet . mem e pool then error , x else let error ' , add_elt = WSet . add parameter error e pool in let error = Exception . check_point Exception . warn parameter error error ' __POS__ Exit in error , ( ( e :: in_list ) , out_list , add_elt ) let fold_left f acc x = let in_list , out_list , _ = x in List . fold_left f ( List . fold_left f acc out_list ) ( List . rev in_list ) let print_wl parameters wl = let _ = print_newline ( ) in ) * let _ , _ , set = wl in WSet . iter ( fun i -> Loggers . fprintf ( Remanent_parameters . get_logger parameters ) " % i " i ) set ; Loggers . fprintf ( Remanent_parameters . get_logger parameters ) " \ n " let rec pop parameter error x = let in_list , out_list , pool = x in if is_empty x then error , ( None , x ) else begin match out_list with | [ ] -> pop parameter error ( [ ] , ( List . rev in_list ) , pool ) | h :: tl -> let error , remove_elt = WSet . remove parameter error h pool in error , ( ( Some h ) , ( in_list , tl , remove_elt ) ) end end )
type ' a working_list = { indice : int ; clean : unit -> unit ; pop : unit ' -> a option ; push : ' a -> unit ; list : unit -> ' a list ; exists : ( ' a -> bool ) -> bool ; member : ' a -> bool ; not_empty : unit -> bool ; copy : unit ' -> a working_list }
let rec make n = let h = Hashtbl . create n in let l = Queue . create ( ) in let push a = try ( Hashtbl . find h a ) with _ -> ( Queue . add a l ; let pop ( ) = try ( let k = Queue . take l in Hashtbl . remove h k ; Some k ) with _ -> None in let not_empty ( ) = match pop ( ) with | Some a -> let ( ) = push a in true | None -> false in let clean ( ) = try ( while true do let _ = pop ( ) in ( ) done ) with _ -> ( ) in let list ( ) = let rep = ref [ ] in iter ( fun x -> rep := x ( ::! rep ) ) l ; ! rep in let copy ( ) = let rep = make n in iter ( fun x -> rep . push x ) l ; rep in let member x = try ( Hashtbl . find h x ; true ) with _ -> false in let exists p = try ( iter ( fun x -> if p x then raise Exit else ( ) ) l ; false ) { indice = n ; clean = clean ; list = list ; pop = pop ; push = push ; exists = exists ; member = member ; not_empty = not_empty ; copy = copy } ; ;
let _wmap parameters _error f l = let rep = make ( Remanent_parameters . get_empty_hashtbl_size parameters ) in List . map ( fun x -> rep . push ( f x ) ) ( l . list ( ) )
let indice wl = wl . indice
let clean wl = wl . clean ( )
let list wl = wl . list ( )
let pop wl = wl . pop ( )
let push a wl = wl . push a
let exists p wl = wl . exists p
let not_empty wl = wl . not_empty ( )
let copy wl = wl . copy ( )
let member a wl = wl . member a
module Make = functor ( S : EqConstrSys ) -> functor ( HM : Hashtbl . S with type key = S . v ) -> struct include Generic . SolverStats ( S ) ( HM ) module VS = Set . Make ( S . Var ) open S . Dom let eq x get set = match S . system x with | None -> bot ( ) | Some f -> eval_rhs_event x ; f get set let solve _ st vs = let infl = HM . create 10 in let rho = HM . create 10 in let vs = ref ( VS . of_enum ( List . enum vs ) ) in let init x = new_var_event x ; HM . replace rho x ( bot ( ) ) ; HM . replace infl x VS . empty ; in let eval x y = get_var_event y ; HM . replace infl y ( VS . add x ( try HM . find infl y with Not_found -> VS . empty ) ) ; try HM . find rho y with Not_found -> new_var_event y ; HM . replace rho y ( bot ( ) ) ; vs := VS . add y ! vs ; bot ( ) in let set x d = let old = try HM . find rho x with Not_found -> init x ; bot ( ) in if not ( leq d old ) then begin update_var_event x old d ; HM . replace rho x ( join old d ) ; let q = try HM . find infl x with Not_found -> VS . empty in HM . replace infl x VS . empty ; vs := ( VS . fold VS . add q ! vs ) end in start_event ( ) ; let _ = List . iter ( fun ( x , d ) -> HM . add rho x d ) st in while not ( VS . is_empty ! vs ) do let x , vs ' = VS . pop ! vs in let _ = vs := vs ' in set x ( eq x ( eval x ) set ) done ; stop_event ( ) ; rho end
let _ = Selector . add_solver ( " WL " , ( module EqIncrSolverFromEqSolver ( Make ) ) ) ;
module Cell = struct module Type = struct type t = | Boolean | Error | Inline_string | Number | Shared_string | Formula_string [ @@ deriving sexp_of ] let of_string = function | " b " -> Boolean | " e " -> Error | " inlineStr " -> Inline_string | " n " -> Number | " s " -> Shared_string | " str " -> Formula_string | str -> failwithf " Expected ST_CellType but got ' % s ' " str ( ) end module Value = struct type t = | Inline of string | Rich_inline of Shared_string_table . String_item . t | Shared of uint32 [ @@ deriving sexp_of ] let to_string ~ shared_strings = function | Inline v -> v | Rich_inline v -> Shared_string_table . String_item . to_string v | Shared n -> let n = Uint32 . to_int n in shared_strings . ( n ) |> Shared_string_table . String_item . to_string let of_xml ~ data_type el = let open Xml in match data_type , el with | _ , Element ( " is " , _ , children ) -> let value = List . filter_map children ~ f : Shared_string_table . Rich_text . of_xml in Some ( Rich_inline value ) | Type . Shared_string , Element ( " v " , _ , children ) -> Some ( Shared ( Uint32 . of_string ( expect_pcdata children ) ) ) | _ , Element ( " v " , _ , children ) -> Some ( Inline ( expect_pcdata children ) ) | _ -> None end type t = { reference : string option ; formula : string option ; value : Value . t option ; cell_metadata_index : uint32 ; show_phonetic : bool ; style_index : uint32 ; data_type : Type . t ; value_metadata_index : uint32 } [ @@ deriving fields , sexp_of ] let column { reference ; _ } = ( Option . value_exn reference ~ here [ :% here ] |> String . to_list |> List . take_while ~ f : Char . is_alpha |> List . map ~ f : Char . uppercase |> List . map ~ f ( : fun c -> Char . to_int c - Char . to_int ' A ' + 1 ) |> List . fold ~ init : 0 ~ f ( : fun acc n -> acc * 26 + n ) ) - 1 let to_string ~ shared_strings { value ; _ } = Option . map value ~ f ( : Value . to_string ~ shared_strings ) |> Option . value ~ default " " : let default = { reference = None ; formula = None ; value = None ; cell_metadata_index = Uint32 . zero ; show_phonetic = false ; style_index = Uint32 . zero ; data_type = Type . Number ; value_metadata_index = Uint32 . zero } let of_xml = let open Xml in function | Element ( " c " , attrs , children ) -> let with_attrs = List . fold attrs ~ init : default ~ f ( : fun acc -> function | " r " , v -> { acc with reference = Some v } | " s " , v -> { acc with style_index = Uint32 . of_string v } | " t " , v -> { acc with data_type = Type . of_string v } | " cm " , v -> { acc with cell_metadata_index = Uint32 . of_string v } | " vm " , v -> { acc with value_metadata_index = Uint32 . of_string v } | " ph " , v -> { acc with show_phonetic = bool_of_xsd_boolean v } | _ -> acc ) in List . fold children ~ init : with_attrs ~ f ( : fun acc -> function | Element ( " f " , _ , children ) -> { acc with formula = Some ( expect_pcdata children ) } | el -> let value = Value . of_xml ~ data_type : with_attrs . data_type el in { acc with value = Option . first_some value acc . value } ) |> Option . some | _ -> None end
module Row = struct type t = { cells : Cell . t list ; collapsed : bool ; custom_format : bool ; custom_height : bool ; hidden : bool ; height : float option ; outline_level : uint8 ; show_phonetic : bool ; row_index : uint32 option ; style_index : uint32 ; thick_bottom_border : bool ; thick_top_border : bool } [ @@ deriving fields , sexp_of ] let default = { cells = [ ] ; collapsed = false ; custom_format = false ; custom_height = false ; hidden = false ; height = None ; outline_level = Uint8 . zero ; show_phonetic = false ; row_index = None ; style_index = Uint32 . zero ; thick_bottom_border = false ; thick_top_border = false } let of_xml = function | Xml . Element ( " row " , attrs , children ) -> let cells = List . filter_map children ~ f : Cell . of_xml in List . fold attrs ~ init { : default with cells } ~ f ( : fun acc -> function | " collapsed " , v -> { acc with collapsed = bool_of_xsd_boolean v } | " customFormat " , v -> { acc with custom_format = bool_of_xsd_boolean v } | " customHeight " , v -> { acc with custom_height = bool_of_xsd_boolean v } | " hidden " , v -> { acc with hidden = bool_of_xsd_boolean v } | " ht " , v -> { acc with height = Some ( Float . of_string v ) } | " outlineLevel " , v -> { acc with outline_level = Uint8 . of_string v } | " ph " , v -> { acc with show_phonetic = bool_of_xsd_boolean v } | " r " , v -> { acc with row_index = Some ( Uint32 . of_string v ) } | " s " , v -> { acc with style_index = Uint32 . of_string v } | " thickBot " , v -> { acc with thick_bottom_border = bool_of_xsd_boolean v } | " thickTop " , v -> { acc with thick_top_border = bool_of_xsd_boolean v } | _ -> acc ) |> Option . some | _ -> None end
module Column = struct type t = { best_fit : bool ; collapsed : bool ; custom_width : bool ; hidden : bool ; max : uint32 ; min : uint32 ; outline_level : uint8 ; show_phonetic : bool ; default_style : uint32 ; width : float option } [ @@ deriving fields , sexp_of ] let of_xml = function | Xml . Element ( " col " , attrs , _ ) -> let best_fit = ref false in let collapsed = ref false in let custom_width = ref false in let hidden = ref false in let max = ref None in let min = ref None in let outline_level = ref Uint8 . zero in let show_phonetic = ref false in let default_style = ref Uint32 . zero in let width = ref None in List . iter attrs ~ f ( : function | " bestFit " , v -> best_fit := bool_of_xsd_boolean v | " collapsed " , v -> collapsed := bool_of_xsd_boolean v | " customWidth " , v -> custom_width := bool_of_xsd_boolean v | " hidden " , v -> hidden := bool_of_xsd_boolean v | " max " , v -> max := Some ( Uint32 . of_string v ) | " min " , v -> min := Some ( Uint32 . of_string v ) | " outlineLevel " , v -> outline_level := Uint8 . of_string v | " phonetic " , v -> show_phonetic := bool_of_xsd_boolean v | " style " , v -> default_style := Uint32 . of_string v | " width " , v -> width := Some ( Float . of_string v ) | _ -> ( ) ) ; let max = require_attribute " col " " max " ! max in let min = require_attribute " col " " min " ! min in Some { best_fit = ! best_fit ; collapsed = ! collapsed ; custom_width = ! custom_width ; hidden = ! hidden ; max ; min ; outline_level = ! outline_level ; show_phonetic = ! show_phonetic ; default_style = ! default_style ; width = ! width } | _ -> None end
type t = { columns : Column . t list ; rows : Row . t list } [ @@ deriving fields , sexp_of ]
let default = { columns = [ ] ; rows = [ ] }
let of_xml = expect_element " worksheet " ( fun _ -> let open Xml in List . fold ~ init : default ~ f ( : fun acc -> function | Element ( " cols " , _ , children ) -> { acc with columns = List . filter_map children ~ f : Column . of_xml } | Element ( " sheetData " , _ , children ) -> { acc with rows = List . filter_map children ~ f : Row . of_xml } | _ -> acc ) )
type role = [ ` Chair | ` Co_chair ]
let role_to_string = function ` Chair -> " chair " | ` Co_chair -> " co - chair "
let role_of_string = function | " chair " -> Ok ` Chair | " co - chair " -> Ok ` Co_chair | _ -> Error ( ` Msg " Unknown role type ) "
let role_of_yaml = function | ` String s -> Result . bind ( role_of_string s ) s ( fun t -> Ok t ) t | _ -> Error ( ` Msg " Expected a string for a role type ) "
let role_to_yaml t = ` String ( role_to_string t ) t
type important_date = { date : string ; info : string } [ @@ deriving yaml ] yaml
type committee_member = { name : string ; role : role option ; affiliation : string option ; picture : string option ; }
type presentation = { title : string ; authors : string list ; link : string option ; video : string option ; slides : string option ; poster : bool option ; additional_links : string list option ; }
type metadata = { title : string ; location : string ; date : string ; important_dates : important_date list ; presentations : presentation list ; program_committee : committee_member list ; organising_committee : committee_member list ; }
let path = Fpath . v " data / workshops "
let parse content = let metadata , _ = Utils . extract_metadata_body content in metadata_of_yaml metadata
type t = { title : string ; slug : string ; location : string ; date : string ; important_dates : important_date list ; presentations : presentation list ; program_committee : committee_member list ; organising_committee : committee_member list ; toc_html : string ; body_md : string ; body_html : string ; }
let all ( ) = Utils . map_files ( fun content -> let metadata , body = Utils . extract_metadata_body content in let metadata = Utils . decode_or_raise metadata_of_yaml metadata in let omd = Omd . of_string body in { title = metadata . title ; slug = Utils . slugify metadata . title ; location = metadata . location ; date = metadata . date ; important_dates = metadata . important_dates ; presentations = metadata . presentations ; program_committee = metadata . program_committee ; organising_committee = metadata . organising_committee ; toc_html = Omd . to_html ( Omd . toc ~ depth : 4 omd ) omd ; body_md = body ; body_html = Omd . to_html omd ; } ) " workshops . /* md " |> List . sort ( fun w1 w2 -> String . compare w1 . date w2 . date ) date |> List . rev
let pp_role ppf = function | ` Chair -> Fmt . string ppf " ` Chair " | ` Co_chair -> Fmt . string ppf " ` Co_chair "
let pp_important_date ppf ( v : important_date ) important_date = Fmt . pf ppf { | { date = % a ; info = % a ; } } | Pp . string v . date Pp . string v . info
let pp_committee_member ppf ( v : committee_member ) committee_member = Fmt . pf ppf { | { name = % a ; role = % a ; affiliation = % a ; picture = % a ; } } | Pp . string v . name Pp ( . option pp_role ) pp_role v . role Pp ( . option string ) string v . affiliation Pp ( . option string ) string v . picture
let pp_presentation ppf ( v : presentation ) presentation = Fmt . pf ppf { | { title = % a ; authors = % a ; link = % a ; video = % a ; slides = % a ; poster = % a ; additional_links = % a ; } } | Pp . string v . title Pp . string_list v . authors Pp ( . option string ) string v . link Pp ( . option string ) string v . video Pp ( . option string ) string v . slides Pp ( . option Fmt . bool ) bool v . poster Pp ( . option string_list ) string_list v . additional_links