From 0926cbcd76209ea096135422b71edf9ea3f73616 Mon Sep 17 00:00:00 2001 From: "Jean A. Senellart" Date: Tue, 31 Jul 2018 09:46:48 +0200 Subject: [PATCH] Add versioning and prepare for release --- CHANGELOG.md | 9 +++++++++ client/launcher.py | 20 ++++++++++++++++++++ server/app/__init__.py | 7 +++++++ server/app/routes.py | 6 +++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d04fa79..31f27194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ ## [Unreleased] +### Breaking changes + +### New features + +### Fixes and improvements + +## [v0.2.0](https://github.com/OpenNMT/nmt-wizard/releases/tag/v0.2.0) (2018-07-31) + ### Breaking changes * redefine more consistent routes * change `task_id` as positional argument for simpler client commands @@ -8,6 +16,7 @@ ### New features +* versioning information * possibility to launch multi-gpu tasks * launch error now reports error message in task log * define `auto` registry - resolved by launcher checking at `default_for` in registry definition diff --git a/client/launcher.py b/client/launcher.py index 39de7305..07d9e471 100644 --- a/client/launcher.py +++ b/client/launcher.py @@ -10,6 +10,24 @@ from datetime import datetime import math +VERSION = "0.2.0-ce" +def append_version(v): + global VERSION + VERSION += ":" + v +def get_version(): + return VERSION + +class VersionAction(argparse.Action): + def __init__(self, nargs=0, **kw): + super(VersionAction, self).__init__(nargs=nargs, **kw) + def __call__(self, parser, namespace, values, option_string=None): + print("Client version: %s" % VERSION) + r = requests.get(os.path.join(os.getenv('LAUNCHER_URL'), "version")) + if r.status_code != 200: + raise RuntimeError('incorrect result from \'version\' service: %s' % r.text) + print("Server version: %s" % r.text) + sys.exit(1) + reimage = re.compile(r"(([-A-Za-z_.0-9]+):|)([-A-Za-z_.0-9]+/[-A-Za-z_.0-9]+)(:([-A-Za-z_.0-9]+)|)$") logger = None @@ -133,6 +151,8 @@ def confirm(prompt=None, resp=False): help="task identifier") parser_file.add_argument('-f', '--filename', help="filename to retrieve - for instance log", required=True) +parser.add_argument('--version', action=VersionAction, help="Version information") + def process_request(serviceList, cmd, is_json, args, auth=None): res = None diff --git a/server/app/__init__.py b/server/app/__init__.py index bceca3df..2f12e7a2 100644 --- a/server/app/__init__.py +++ b/server/app/__init__.py @@ -7,6 +7,13 @@ import time from redis.exceptions import ConnectionError +VERSION = "0.2.0-ce" +def append_version(v): + global VERSION + VERSION += ":" + v +def get_version(): + return VERSION + app = Flask(__name__) ch = logging.StreamHandler() diff --git a/server/app/routes.py b/server/app/routes.py index fed54ce0..bc1397f9 100644 --- a/server/app/routes.py +++ b/server/app/routes.py @@ -1,4 +1,4 @@ -from app import app, redis, services +from app import app, redis, services, get_version import flask from nmtwizard import common, task from nmtwizard.helper import build_task_id, shallow_command_analysis, change_parent_task @@ -309,3 +309,7 @@ def post_log(task_id): @app.route("/status", methods=["GET"]) def get_status(): return flask.jsonify(200) + +@app.route("/version", methods=["GET"]) +def get_version_request(): + return flask.make_response(get_version()) \ No newline at end of file