Commit ae60c7ca authored by Fardale's avatar Fardale
Browse files

Add the possibility to give argument to the script

parent c7fe0147
open Lwt.Infix open Lwt.Infix
open Serialization_t 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 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_io.with_connection
(Lwt_unix.ADDR_INET (Unix.inet_addr_of_string addr, port)) (Lwt_unix.ADDR_INET (Unix.inet_addr_of_string addr, port))
(fun (ic, oc) -> (fun (ic, oc) ->
......
...@@ -131,6 +131,7 @@ let server_handler pass port sockaddr (ic, oc) = ...@@ -131,6 +131,7 @@ let server_handler pass port sockaddr (ic, oc) =
Printf.sprintf "OCLUSTER_TASK_ID=%i" !jobs_id; Printf.sprintf "OCLUSTER_TASK_ID=%i" !jobs_id;
]; ];
script = submission.script; script = submission.script;
args = submission.args;
time = submission.time; time = submission.time;
pass; pass;
port; port;
......
...@@ -19,7 +19,7 @@ let run_computation (computation : computation) = ...@@ -19,7 +19,7 @@ let run_computation (computation : computation) =
Lwt_process.exec ?timeout:computation.time ~stdin:`Close Lwt_process.exec ?timeout:computation.time ~stdin:`Close
~env:(Array.of_list computation.env) ~env:(Array.of_list computation.env)
~stdout:(`FD_move write_stdout) ~stderr:(`FD_move write_stderr) ~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 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 and stderr = Lwt_io.read (Lwt_io.of_fd ~mode:Lwt_io.input read_stderr) in
Lwt.return Lwt.return
......
...@@ -106,13 +106,17 @@ let client_cmd = ...@@ -106,13 +106,17 @@ let client_cmd =
let doc = "Ip of the master" in let doc = "Ip of the master" in
Arg.(required & pos 2 (some string) None & info [] ~docv:"IP" ~doc) Arg.(required & pos 2 (some string) None & info [] ~docv:"IP" ~doc)
in 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 doc = "Client to use the cluster" in
let exits = Term.default_exits in let exits = Term.default_exits in
let man = [ `S Manpage.s_description; `P "Client to use the cluster" ] in let man = [ `S Manpage.s_description; `P "Client to use the cluster" ] in
( Term.( ( Term.(
const Lwt_main.run const Lwt_main.run
$ ( const Client.cmd $ cpu $ ram $ time $ iteration $ port $ script $ pass $ ( 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 ) Term.info "client" ~doc ~sdocs:Manpage.s_common_options ~exits ~man )
let default_cmd = let default_cmd =
......
...@@ -3,11 +3,11 @@ type node = {addr: string; ~port <ocaml default="4242">: int; cpu: int; ram: int ...@@ -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 master_conf = {pass: string; ~port <ocaml default="4242">: int; nodes: node list}
type node_conf = {pass: string; ~port <ocaml default="4242">: int} 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 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">; cpu: int <ocaml default="1">; ram: int <ocaml default="1024">;
pass: string} 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