text stringlengths 0 601k |
|---|
type t = | Tabstop of int option * [ ` Placeholder of t | ` Choice of string list | ` None ] | Variable of Var . t * [ ` Placeholder of t | ` Transform of variable_transform | ` None ] | Text of string | Concat of t * t |
let tabstop index = Tabstop ( Some index , ` None ) |
let placeholder ? index content = Tabstop ( index , ` Placeholder content ) |
let choice ? index values = if List . is_empty values then Code_error . raise " choice must have non empty values " [ ] else Tabstop ( index , ` Choice values ) |
let variable ( ? opt = ` None ) var = Variable ( var , opt ) |
let variable_transform ~ regex ? regex_options ~ format_string ( ) = { regex ; regex_options ; format_string } |
let text str = Text str |
module O = struct let ( ^^ ) lhs rhs = Concat ( lhs , rhs ) let ( @+ ) lhs_str rhs = Concat ( Text lhs_str , rhs ) let ( +@ ) lhs rhs_str = Concat ( lhs , Text rhs_str ) end |
let concat ? sep ts = let rec go = function | [ ] -> text " " | [ x ] -> x | x :: rest -> ( match sep with | None -> Concat ( x , go rest ) | Some s -> Concat ( x , Concat ( s , go rest ) ) ) in go ts |
let escape ( ? in_choice = false ) str = let str = str |> String . replace_all ~ pattern " " :$ ~ with_ " " :\\$ |> String . replace_all ~ pattern " } " : ~ with_ " } " :\\ |> String . replace_all ~ pattern " " :\\ ~ with_ " " :\\\\ in if not in_choice then str else str |> String . replace_all ~ pattern " , " : ~ with_... |
type ctx = int * int Int . Map . t |
let pp_impl add_string ( snippet : t ) : unit = let open Format in let with_ctx ctx i_opt f : ctx = let n , m = ctx in match i_opt with | None -> add_string ( f n ) ; ( n + 1 , m ) | Some i -> ( match Int . Map . find m i with | Some j -> add_string ( f j ) ; ( n , m ) | None -> add_string ( f n ) ; ( n + 1 , Int . Map... |
let to_string t = let buf = Buffer . create 0 in pp_impl ( Buffer . add_string buf ) t ; Buffer . contents buf |
let pp ( chan : Format . formatter ) ( t : t ) : unit = pp_impl ( Format . pp_print_string chan ) t |
type t = { path : string ; name : string ; color : Log . Color . t } |
type determinizer = Percentile of int | Mean |
type regression_method = | Lasso of { positive : bool } | Ridge of { positive : bool } | NNLS |
type tag = | Proto of Protocol . t | Interpreter | Translator | Sapling | Encoding | Io | Misc | Builtin | Gtoc | Cache | Carbonated_map |
type michelson_term_kind = Data | Code |
type list_mode = All | Any | Exactly |
let create ( ? path = Constant . tezos_snoop ) ( ? color = Log . Color . FG . blue ) ( ) = { path ; name = " snoop " ; color } |
let spawn_command snoop command = Process . spawn ~ name : snoop . name ~ color : snoop . color snoop . path @@ command |
let string_of_determinizer = function | Mean -> " mean " | Percentile i -> Printf . sprintf " percentile @% d " i |
let benchmark_command ~ bench_name ~ bench_num ~ save_to ~ nsamples ~ determinizer ? seed ? config_dir ? csv_dump ( ) = let command = [ " benchmark " ; bench_name ; " and " ; " save " ; " to " ; save_to ; " -- determinizer " ; string_of_determinizer determinizer ; " -- bench - num " ; string_of_int bench_num ; " -- nsa... |
let spawn_benchmark ~ bench_name ~ bench_num ~ nsamples ~ determinizer ~ save_to ? seed ? config_dir ? csv_dump snoop = spawn_command snoop ( benchmark_command ~ bench_name ~ bench_num ~ save_to ~ nsamples ~ determinizer ? seed ? config_dir ? csv_dump ( ) ) |
let benchmark ~ bench_name ~ bench_num ~ nsamples ~ determinizer ~ save_to ? seed ? config_dir ? csv_dump snoop = spawn_benchmark ~ bench_name ~ bench_num ~ nsamples ~ determinizer ~ save_to ? seed ? config_dir ? csv_dump snoop |> Process . check |
let infer_command ~ model_name ~ workload_data ~ regression_method ~ dump_csv ~ solution ? report ? graph ( ) = let regression_method = match regression_method with | Lasso { positive } -> if positive then [ " lasso " ; " -- lasso - positive " ] else [ " lasso " ] | Ridge { positive } -> if positive then [ " ridge " ; ... |
let spawn_infer_parameters ~ model_name ~ workload_data ~ regression_method ~ dump_csv ~ solution ? report ? graph snoop = spawn_command snoop ( infer_command ~ model_name ~ workload_data ~ regression_method ~ dump_csv ~ solution ? report ? graph ( ) ) |
let infer_parameters ~ model_name ~ workload_data ~ regression_method ~ dump_csv ~ solution ? report ? graph snoop = spawn_infer_parameters ~ model_name ~ workload_data ~ regression_method ~ dump_csv ~ solution ? report ? graph snoop |> Process . check |
let sapling_generate_command ~ tx_count ~ max_inputs ~ max_outputs ~ file ( ? protocol = Protocol . Alpha ) ? max_nullifiers ? max_additional_commitments ? seed ( ) = let max_nullifiers = match max_nullifiers with | None -> [ ] | Some max_nf -> [ " -- max - nullifiers " ; string_of_int max_nf ] in let max_additional_co... |
let spawn_sapling_generate ? protocol ~ tx_count ~ max_inputs ~ max_outputs ~ file ? max_nullifiers ? max_additional_commitments ? seed snoop = spawn_command snoop ( sapling_generate_command ~ tx_count ~ max_inputs ~ max_outputs ~ file ? protocol ? max_nullifiers ? max_additional_commitments ? seed ( ) ) |
let sapling_generate ? protocol ~ tx_count ~ max_inputs ~ max_outputs ~ file ? max_nullifiers ? max_additional_commitments ? seed snoop = spawn_sapling_generate ~ tx_count ~ max_inputs ~ max_outputs ~ file ? protocol ? max_nullifiers ? max_additional_commitments ? seed snoop |> Process . check |
let string_of_kind kind = match kind with Data -> " data " | Code -> " code " |
let michelson_generate_command ( ? protocol = Protocol . Alpha ) ~ terms_count ~ kind ~ file ? min_size ? max_size ? burn_in ? seed ( ) = let seed = match seed with None -> [ ] | Some seed -> [ " -- seed " ; string_of_int seed ] in let min_size = match min_size with | None -> [ ] | Some sz -> [ " -- min - size " ; stri... |
let spawn_michelson_generate ? protocol ~ terms_count ~ kind ~ file ? min_size ? max_size ? burn_in ? seed snoop = spawn_command snoop ( michelson_generate_command ? protocol ~ terms_count ~ kind ~ file ? min_size ? max_size ? burn_in ? seed ( ) ) |
let michelson_generate ? protocol ~ terms_count ~ kind ~ file ? min_size ? max_size ? burn_in ? seed snoop = spawn_michelson_generate ? protocol ~ terms_count ~ kind ~ file ? min_size ? max_size ? burn_in ? seed snoop |> Process . check |
let michelson_concat_command ( ? protocol = Protocol . Alpha ) ~ file1 ~ file2 ~ target ( ) = let proto_tag = Protocol . tag protocol in [ proto_tag ; " michelson " ; " concat " ; " files " ; file1 ; " and " ; file2 ; " into " ; target ; ] |
let spawn_michelson_concat ? protocol ~ file1 ~ file2 ~ target snoop = spawn_command snoop ( michelson_concat_command ? protocol ~ file1 ~ file2 ~ target ( ) ) |
let michelson_concat ? protocol ~ file1 ~ file2 ~ target snoop = spawn_michelson_concat ? protocol ~ file1 ~ file2 ~ target snoop |> Process . check |
let string_of_tag ( tag : tag ) = match tag with | Proto proto -> Protocol . tag proto | Interpreter -> " interpreter " | Translator -> " translator " | Sapling -> " sapling " | Encoding -> " encoding " | Io -> " io " | Misc -> " misc " | Builtin -> " builtin " | Gtoc -> " global_constants " | Cache -> " cache " | Carb... |
let list_benchmarks_command mode tags = let tags = List . map string_of_tag tags in match mode with | All -> [ " list " ; " benchmarks " ; " with " ; " tags " ; " all " ; " of " ] @ tags | Any -> [ " list " ; " benchmarks " ; " with " ; " tags " ; " any " ; " of " ] @ tags | Exactly -> [ " list " ; " benchmarks " ; " w... |
let spawn_list_benchmarks ~ mode ~ tags snoop = spawn_command snoop ( list_benchmarks_command mode tags ) |
let list_benchmarks ~ mode ~ tags snoop = let process = spawn_list_benchmarks ~ mode ~ tags snoop in let * output = Process . check_and_read_stdout process in let lines = String . split_on_char ' \ n ' output in Lwt_list . filter_map_s ( function | " " -> return None | line -> ( match line =~* rex " ( . ) . " *:* with ... |
let get_snpeff_db_name ~ run_with reference_build = Machine . ( get_reference_genome run_with reference_build ) |> Reference_genome . snpeff_name_exn |
let get_snpeff_data_folder ~ run_with = let snpeff = Machine . Tool . Default . snpeff in let tname , tversion = Machine . Tool . Definition . ( get_name snpeff , get_version snpeff ) in sprintf " { $ CONDA_PREFIX } / share /% s -% s / data " tname ( match tversion with None -> " " * | Some v -> v ) |
let call_snpeff fmt = sprintf ( " % s " ^^ fmt ) ( " snpEff - Xms4g " ) |
let prepare_annotation ( ~ run_with : Machine . t ) ~ reference_build = let open KEDSL in let snpeff = Machine . get_tool run_with Machine . Tool . Default . snpeff in let dbname = get_snpeff_db_name ~ run_with reference_build in let data_path = get_snpeff_data_folder ~ run_with in let genome_data_path = data_path // d... |
type snpeff_product = < host : Ketrew_pure . Host . t ; is_done : Ketrew_pure . Target . Condition . t option ; csv_stats : KEDSL . single_file ; html_stats : KEDSL . single_file ; workdir_path : string ; annotated_vcf : KEDSL . vcf_file ; path : string ; > |
let annotate ( ~ run_with : Machine . t ) ~ reference_build ~ input_vcf ~ out_folder = let open KEDSL in let snpeff = Machine . get_tool run_with Machine . Tool . Default . snpeff in let host = Machine . as_host run_with in let in_vcf_path = input_vcf # product # path in let in_basename = ( Filename . basename in_vcf_p... |
module Make ( P : sig val authenticate : Signature . Public_key_hash . t list -> Bytes . t -> Signature . t tzresult Lwt . t struct open P type request_type = | Sign_request | Deterministic_nonce_request | Deterministic_nonce_hash_request let build_request pkh data signature = function | Sign_request -> Request . Sign ... |
let make_unix_base path = Uri . make ~ scheme : unix_scheme ~ path ( ) |
let make_tcp_base host port = Uri . make ~ scheme : tcp_scheme ~ host ~ port ( ) |
module Transport = struct type transport = | XHR_polling let to_string = function | XHR_polling -> " xhr - polling " type state = | Closed | Closing | Open | Opening type t = { transport : transport ; mutable state : state ; } end |
module Connection = struct type sid = string let make_sid = let ctr = ref 0 in fun ( ) -> incr ctr ; Printf . sprintf " sid % d " ! ctr type state = | Connected | Connecting | Disconnecting | Disconnected let state_to_string = function | Connected -> " connected " | Connecting -> " connecting " | Disconnecting -> " dis... |
let make_server ( ) = Connection . make ( ) |
module Packet = struct type endpoint = string option type id = int option type message = | Disconnect of endpoint | Connect of endpoint | Heartbeat | Message of endpoint * id * string | JSON of endpoint * id * Yojson . Safe . json | Event of endpoint * id * Yojson . Safe . json | Ack of id | Error of endpoint * string ... |
let create ~ conns req = let conn = Connection . add ~ conns ( ) in let body = Connection . string_of_conn conn in Cohttpd . Server . respond ~ body ( ) |
let connection ~ conns ~ conn req = lwt body = Cohttp . Message . string_of_body ( Cohttp . Request . body req ) in let m = Packet . of_string body in match conn . Connection . state with | Connection . Connecting -> let body = Packet . ( to_string ( Connect None ) ) in Cohttpd . Server . respond ~ body ( ) | _ -> Lwt_... |
let callback ( server_t , conns ) id req = let open Cohttp . Request in Printf . printf " % s % s \ n " %! ( Cohttp . Common . string_of_method ( meth req ) ) ( Cohttp . Types . ( path req ) ) ; match meth req , ( Re_str . ( split ( regexp_string " " ) / ( path req ) ) ) with ` | GET , ( [ ] [ " " ] ) | -> Cohttpd . Se... |
let xenstored_socket = ref " / var / run / xenstored / socket " |
type ' a t = ' a Lwt . t |
let return x = return x |
let ( >>= ) m f = m >>= f mutable available : Cstruct . t ; mutable seq : int64 ; } let make fd size = let full_buffer = Cstruct . create size in let available = Cstruct . sub full_buffer 0 0 in let seq = 0L in { fd ; full_buffer ; available ; seq } let next t = if Cstruct . len t . available > 0 then return ( t . seq ... |
let complete op fd buf = let ofs = buf . Cstruct . off in let len = buf . Cstruct . len in let buf = buf . Cstruct . buffer in let rec loop acc fd buf ofs len = op fd buf ofs len >>= fun n -> let len ' = len - n in let acc ' = acc + n in if len ' = 0 || n = 0 then return acc ' else loop acc ' fd buf ( ofs + n ) len ' i... |
type connection = { fd : Lwt_unix . file_descr ; sockaddr : Lwt_unix . sockaddr ; read_buffer : Cstruct . t ; write_buffer : Cstruct . t ; } |
let alloc ( fd , sockaddr ) = let read_buffer = Cstruct . create ( Protocol . Header . sizeof + Protocol . xenstore_payload_max ) in let write_buffer = Cstruct . create ( Protocol . Header . sizeof + Protocol . xenstore_payload_max ) in return { fd ; sockaddr ; read_buffer ; write_buffer } |
let create ( ) = let sockaddr = Lwt_unix . ADDR_UNIX ( ! xenstored_socket ) in let fd = Lwt_unix . socket Lwt_unix . PF_UNIX Lwt_unix . SOCK_STREAM 0 in let start = Unix . gettimeofday ( ) in let rec retry n interval = if n > retry_max then fail ( Failure ( Printf . sprintf " Failed to connect to xenstore after . % 0f ... |
let destroy { fd } = Lwt_unix . close fd |
let read { fd } = complete Lwt_bytes . read fd |
let write { fd } = complete Lwt_bytes . write fd |
let int_of_file_descr fd = let fd = Lwt_unix . unix_file_descr fd in let ( fd : int ) = Obj . magic fd in fd |
let address_of { fd } = let creds = Lwt_unix . get_credentials fd in let pid = creds . Lwt_unix . cred_pid in Lwt . catch ( fun ( ) -> Lwt_io . with_file ~ mode : Lwt_io . input ( Printf . sprintf " / proc /% d / cmdline " pid ) ( fun ic -> Lwt_io . read_line_opt ic >>= fun cmdline -> match cmdline with | Some x -> ret... |
let domain_of _ = 0 |
let _ = Sys . set_signal Sys . sigpipe Sys . Signal_ignore |
let listen ( ) = let sockaddr = Lwt_unix . ADDR_UNIX ( ! xenstored_socket ) in let fd = Lwt_unix . socket Lwt_unix . PF_UNIX Lwt_unix . SOCK_STREAM 0 in Lwt . catch ( fun ( ) -> Lwt_unix . unlink ! xenstored_socket ) ( fun _ -> return ( ) ) >>= fun ( ) -> Lwt_unix . bind fd sockaddr ; Lwt_unix . listen fd 5 ; return fd |
let rec accept_forever fd process = Lwt_unix . accept_n fd 16 >>= fun ( conns , _exn_option ) -> let ( _ : unit Lwt . t list ) = List . map ( fun x -> alloc x >>= process ) conns in accept_forever fd process |
type offset = unit [ @@ deriving sexp ] |
let get_read_offset _ = return ( ) |
let get_write_offset _ = return ( ) |
let flush _ _ = return ( ) |
let enqueue t hdr response = let reply_buf = t . write_buffer in let payload_buf = Cstruct . shift reply_buf Protocol . Header . sizeof in let next = Protocol . Response . marshal response payload_buf in let length = next . Cstruct . off - payload_buf . Cstruct . off in let hdr = Protocol . Header . ( { hdr with len = ... |
let recv t _ = let hdr = Cstruct . sub t . read_buffer 0 Protocol . Header . sizeof in read t hdr >>= fun ( ) -> match Protocol . Header . unmarshal hdr with | ` Error x -> return ( ( ) , ` Error x ) | ` Ok x -> let payload = Cstruct . sub t . read_buffer Protocol . Header . sizeof x . Protocol . Header . len in read t... |
module Introspect = struct let read { fd } = function | [ " readable " ] -> Some ( string_of_bool ( Lwt_unix . readable fd ) ) | [ " writable " ] -> Some ( string_of_bool ( Lwt_unix . writable fd ) ) | _ -> None let ls t = function | [ ] -> [ " readable " ; " writable " ] | _ -> [ ] let write _ _ _ = false end |
let handle_client_step ? magic_bytes ? timeout ~ check_high_watermark ~ require_auth cctxt fd = let open Lwt_result_syntax in let * recved = Tezos_base_unix . Socket . recv ? timeout fd Request . encoding in match recved with | Sign req -> let encoding = result_encoding Sign . Response . encoding in let *! res = Handle... |
let handle_client_loop ? magic_bytes ? timeout ~ check_high_watermark ~ require_auth cctxt fd = let rec loop ( ) = let open Lwt_result_syntax in let * ( ) = handle_client_step ? magic_bytes ? timeout ~ check_high_watermark ~ require_auth cctxt fd in loop ( ) in loop ( ) |
let run ? magic_bytes ? timeout ~ check_high_watermark ~ require_auth ( cctxt : # Client_context . wallet ) path = let open Lwt_result_syntax in let open Tezos_base_unix . Socket in let *! ( ) = match path with | Tcp ( host , service , _opts ) -> Events . ( emit accepting_tcp_requests ) ( host , service ) | Unix path -... |
let wipe str = Sodium_bytes . memzero ( Storage . Bytes . to_ptr str ) str ( Storage . Bytes . len_size_t str ) str |
let memcpy ~ dest ~ src typ = let size = sizeof typ in let cast p = from_voidp ( array size uchar ) uchar ( to_voidp p ) p in cast dest <-@ ( !@ cast src ) src |
let increment_be_bytes ( ? step = 1 ) 1 b = let b = Bytes . copy b in let rec incr_byte step byteno = let res = Char . code ( Bytes . get b byteno ) byteno + step in let lo , hi = res land 0xff , res asr 8 in Bytes . set b byteno ( Char . chr lo ) lo ; if hi = 0 || byteno = 0 then ( ) else incr_byte hi ( byteno - 1 ) 1... |
module Verify = struct module C = C . Verify let equal_fn size = match size with | 16 -> fun a b -> ( C . verify_16 ( Storage . Bytes . to_ptr a ) a ( Storage . Bytes . to_ptr b ) b ) b = 0 | 32 -> fun a b -> ( C . verify_32 ( Storage . Bytes . to_ptr a ) a ( Storage . Bytes . to_ptr b ) b ) b = 0 | 64 -> fun a b -> ( ... |
module Random = struct module C = C . Random let stir = C . stir module type S = sig type storage val generate_into : storage -> unit val generate : int -> storage end module Make ( MakeT : Storage . S ) S = struct module C = C . Make ( MakeT ) MakeT type storage = T . t let generate_into str = C . gen ( T . to_ptr str... |
module Box = struct module C = C . Box let primitive = C . primitive let public_key_size = Size_t . to_int ( C . publickeybytes ( ) ) let secret_key_size = Size_t . to_int ( C . secretkeybytes ( ) ) let channel_key_size = Size_t . to_int ( C . beforenmbytes ( ) ) let nonce_size = Size_t . to_int ( C . noncebytes ( ) ) ... |
module Sign = struct module C = C . Sign let primitive = C . primitive let public_key_size = Size_t . to_int ( C . publickeybytes ( ) ) let secret_key_size = Size_t . to_int ( C . secretkeybytes ( ) ) let reserved_size = Size_t . to_int ( C . bytes ( ) ) let signature_size = Size_t . to_int ( C . bytes ( ) ) let seed_s... |
module Scalar_mult = struct module C = C . Scalar_mult let primitive = C . primitive let group_elt_size = Size_t . to_int ( C . bytes ( ) ) let integer_size = Size_t . to_int ( C . scalarbytes ( ) ) type group_elt = Bytes . t type integer = Bytes . t let equal_group_elt = Verify . equal_fn group_elt_size let equal_inte... |
module Password_hash = struct module Sodium = C module C = C . Password_hash let primitive = C . primitive let salt_size = Size_t . to_int ( C . saltbytes ( ) ) let password_hash_size = Size_t . to_int ( C . strbytes ( ) ) type salt = Bytes . t type password = Bytes . t type difficulty = { mem_limit : int64 ; ops_limit... |
module Secret_box = struct module C = C . Secret_box let primitive = C . primitive let key_size = Size_t . to_int ( C . keybytes ( ) ) let nonce_size = Size_t . to_int ( C . noncebytes ( ) ) let zero_size = Size_t . to_int ( C . zerobytes ( ) ) let box_zero_size = Size_t . to_int ( C . boxzerobytes ( ) ) type ' a key =... |
module Stream = struct module C = C . Stream let primitive = C . primitive let key_size = Size_t . to_int ( C . keybytes ( ) ) let nonce_size = Size_t . to_int ( C . noncebytes ( ) ) type ' a key = Bytes . t type secret_key = secret key type nonce = Bytes . t let random_key ( ) = Random . Bytes . generate key_size let ... |
module Gen_auth ( Gen_authM : sig val scope : string val primitive : string val name : string module C = C . Gen_auth ( Gen_authM ) Gen_authM let primitive = M . primitive let key_size = Size_t . to_int ( C . keybytes ( ) ) let auth_size = Size_t . to_int ( C . bytes ( ) ) type ' a key = Bytes . t type secret_key = sec... |
module Auth = Gen_auth ( Gen_authstruct let scope = " auth " let primitive = " hmacsha512256 " let name = " Auth " end ) end |
module One_time_auth = Gen_auth ( Gen_authstruct let scope = " onetimeauth " let primitive = " poly1305 " let name = " One_time_auth " end ) end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.