From b8c02ccc93f74ac9f3f5774836783696187533c8 Mon Sep 17 00:00:00 2001 From: Bruno Guillaume <Bruno.Guillaume@loria.fr> Date: Mon, 3 Oct 2022 21:42:52 +0200 Subject: [PATCH] version 1.9.1 (ocaml) --- VERSION | 2 +- src_ocaml/grewpy.ml | 20 ++++++++++++++++++-- src_ocaml/grewpy_utils.ml | 4 +++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index f8e233b..9ab8337 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9.0 +1.9.1 diff --git a/src_ocaml/grewpy.ml b/src_ocaml/grewpy.ml index eed93c1..1c9fadb 100644 --- a/src_ocaml/grewpy.ml +++ b/src_ocaml/grewpy.ml @@ -24,13 +24,29 @@ let json_error msg = (* ==================================================================================================== *) let run_command request = + let config = !Global.config in let _ = Debug.log "run request >>>>%s<<<<" request in try let json = Yojson.Basic.from_string request in match json |> member "command" |> to_string_option with | None -> failwith "no 'command' in request" - (* ======================= load_graph ======================= *) + (* ======================= set_config ======================= *) + | Some "set_config" -> + begin + match json |> member "config" |> to_string_option with + | Some c -> + begin + try + Global.config := Conllx_config.build c; + Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", `Null)]) + with Conllx_error js -> + Yojson.Basic.to_string (`Assoc [("status", `String "ERROR"); ("message", js)]) + end + | None -> json_error "no 'config' in 'set_config' command" + end + + (* ======================= load_graph ======================= *) | Some "load_graph" -> begin match json |> member "filename" |> to_string_option with @@ -38,7 +54,7 @@ let run_command request = let graph = Graph.load ~config filename in let data = Graph.to_json_python ~config graph in Yojson.Basic.to_string (`Assoc [("status", `String "OK"); ("data", data)]) - | None -> json_error "no 'filename' in 'load_grs' command" + | None -> json_error "no 'filename' in 'load_graph' command" end (* ======================= save_graph ======================= *) diff --git a/src_ocaml/grewpy_utils.ml b/src_ocaml/grewpy_utils.ml index 407d442..f62562b 100644 --- a/src_ocaml/grewpy_utils.ml +++ b/src_ocaml/grewpy_utils.ml @@ -5,7 +5,6 @@ open Libgrew module Int_map = Map.Make (struct type t=int let compare=Stdlib.compare end) -let config = Conllx_config.build "ud" exception Error of string @@ -38,6 +37,9 @@ end (* ==================================================================================================== *) module Global = struct + + let config = ref (Conllx_config.build "ud") + let debug = ref false let (caller_pid: string option ref) = ref None -- GitLab