From 535a94702657dcd3231f26f315fc2e5775cd4d92 Mon Sep 17 00:00:00 2001 From: Marko Budiselic <marko.budiselic@memgraph.io> Date: Fri, 17 Mar 2017 11:58:11 +0100 Subject: [PATCH] KPI service docker file. Summary: KPI service docker file. Reviewers: matej.gradicek Reviewed By: matej.gradicek Subscribers: matej.gradicek Differential Revision: https://phabricator.memgraph.io/D140 --- docker/kpi_service.docker | 16 ++++++++++++++++ kpi_service/kpi_service.py | 14 ++++++++------ run | 3 ++- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 docker/kpi_service.docker diff --git a/docker/kpi_service.docker b/docker/kpi_service.docker new file mode 100644 index 000000000..a947e9d57 --- /dev/null +++ b/docker/kpi_service.docker @@ -0,0 +1,16 @@ +FROM ubuntu:16.04 + +RUN apt-get update \ + && apt-get install -y python3 python3-pip \ + && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +COPY kpi_service /kpi_service +COPY requirements.txt /kpi_service/requirements.txt + +WORKDIR /kpi_service +RUN pip3 install --upgrade pip +RUN pip3 install -r requirements.txt + +EXPOSE 5000 +CMD python3 kpi_service.py --results /results + diff --git a/kpi_service/kpi_service.py b/kpi_service/kpi_service.py index f3801301b..6e3641bce 100644 --- a/kpi_service/kpi_service.py +++ b/kpi_service/kpi_service.py @@ -12,12 +12,11 @@ Default host is 127.0.0.1, and default port is 5000. Host and port can be passed as arguments of a script. """ -path = "../tck_engine/results" - def parse_args(): argp = ArgumentParser(description=__doc__) - argp.add_argument("--host", default="127.0.0.1", help="Application host ip, default is 127.0.0.1.") + argp.add_argument("--host", default="0.0.0.0", help="Application host ip, default is 127.0.0.1.") argp.add_argument("--port", default="5000", help="Application host ip, default is 5000.") + argp.add_argument("--results", default="../tck_engine/results", help="Path where the results are stored.") return argp.parse_args() @@ -34,7 +33,7 @@ def results(): string of file names separated by whitespace """ tail = request.args.get("tail") - return list_to_str(os.listdir(path), tail) + return list_to_str(os.listdir(app.config["RESULTS_PATH"]), tail) @app.route("/results/<dbname>") def results_for_db(dbname): @@ -52,7 +51,7 @@ def results_for_db(dbname): string of file names separated by whitespace """ tail = request.args.get("tail") - return list_to_str(([f for f in os.listdir(path) if f.startswith(dbname)]), tail) + return list_to_str(([f for f in os.listdir(app.config["RESULTS_PATH"]) if f.startswith(dbname)]), tail) @app.route("/results/<dbname>/<timestamp>") def result(dbname, timestamp): @@ -69,7 +68,7 @@ def result(dbname, timestamp): json of a file. """ fname = dbname + "_" + timestamp + ".json" - with open(path + "/" + fname) as f: + with open(app.config["RESULTS_PATH"] + "/" + fname) as f: json_data = json.load(f) return jsonify(json_data) @@ -95,6 +94,9 @@ def list_to_str(l, tail): def main(): args = parse_args() + app.config.update(dict( + RESULTS_PATH=args.results + )) app.run( host = args.host, port = int(args.port) diff --git a/run b/run index 98b8f1f24..34c508570 100755 --- a/run +++ b/run @@ -40,9 +40,10 @@ cd ${script_dir} # setup ve if [ ! -d "ve3" ]; then virtualenv -p python3 ve3 - pip3 install -r requirements.txt fi source ve3/bin/activate +pip3 install --upgrade pip3 +pip3 install -r requirements.txt # binary is available after the build binary_name=$(find ${memgraph_build_dir}/ -maxdepth 1 -executable -name "memgraph*")