Commit ae60c7ca authored by Fardale's avatar Fardale

Add the possibility to give argument to the script

parent c7fe0147
open Lwt.Infix
open Serialization_t
let cmd cpu ram time iteration port script_file pass addr () =
let cmd cpu ram time iteration port script_file pass addr args () =
let script = CCIO.with_in script_file CCIO.read_all in
let submission = { script; time; iteration; cpu; ram; pass } in
let submission = { script; args; time; iteration; cpu; ram; pass } in
Lwt_io.with_connection
(Lwt_unix.ADDR_INET (Unix.inet_addr_of_string addr, port))
(fun (ic, oc) ->
......
......@@ -131,6 +131,7 @@ let server_handler pass port sockaddr (ic, oc) =
Printf.sprintf "OCLUSTER_TASK_ID=%i" !jobs_id;
];
script = submission.script;
args = submission.args;
time = submission.time;
pass;
port;
......
......@@ -19,7 +19,7 @@ let run_computation (computation : computation) =
Lwt_process.exec ?timeout:computation.time ~stdin:`Close
~env:(Array.of_list computation.env)
~stdout:(`FD_move write_stdout) ~stderr:(`FD_move write_stderr)
(name, [||])
(name, Array.of_list (name :: computation.args))
and stdout = Lwt_io.read (Lwt_io.of_fd ~mode:Lwt_io.input read_stdout)
and stderr = Lwt_io.read (Lwt_io.of_fd ~mode:Lwt_io.input read_stderr) in
Lwt.return
......
......@@ -106,13 +106,17 @@ let client_cmd =
let doc = "Ip of the master" in
Arg.(required & pos 2 (some string) None & info [] ~docv:"IP" ~doc)
in
let args =
let doc = "Arguments passed to the script" in
Arg.(value & pos_right 2 string [] & info [] ~docv:"ARGS" ~doc)
in
let doc = "Client to use the cluster" in
let exits = Term.default_exits in
let man = [ `S Manpage.s_description; `P "Client to use the cluster" ] in
( Term.(
const Lwt_main.run
$ ( const Client.cmd $ cpu $ ram $ time $ iteration $ port $ script $ pass
$ addr $ setup_log )),
$ addr $ args $ setup_log )),
Term.info "client" ~doc ~sdocs:Manpage.s_common_options ~exits ~man )
let default_cmd =
......
......@@ -3,11 +3,11 @@ type node = {addr: string; ~port <ocaml default="4242">: int; cpu: int; ram: int
type master_conf = {pass: string; ~port <ocaml default="4242">: int; nodes: node list}
type node_conf = {pass: string; ~port <ocaml default="4242">: int}
type computation = {id: (int * int); env: string list; script: string; time: float option; pass: string; port: int; cpu: int; ram: int}
type computation = {id: (int * int); env: string list; script: string; args: string list; time: float option; pass: string; port: int; cpu: int; ram: int}
type ret_code = [WEXITED of int | WSIGNALED of int | WSTOPPED of int]
type submission = {script: string; time: float option; iteration: int <ocaml default="1">;
type submission = {script: string; args: string list; time: float option; iteration: int <ocaml default="1">;
cpu: int <ocaml default="1">; ram: int <ocaml default="1024">;
pass: string}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment