From 8aa86225e28faf13d4753a2a02f5c34c207b51b9 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sat, 23 Nov 2019 01:27:45 +0200 Subject: [PATCH] Add `default_output_uri` in trains.conf configuration Fix Task.set_credentials support for different web/api/files hosts --- docs/trains.conf | 8 ++++++++ trains/config/default/sdk.conf | 3 +++ trains/task.py | 29 ++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/docs/trains.conf b/docs/trains.conf index 1d93fe57..d45211cb 100644 --- a/docs/trains.conf +++ b/docs/trains.conf @@ -31,6 +31,11 @@ sdk { # X files are stored in the upload destination for each metric/variant combination. file_history_size: 100 + # Max history size for matplotlib imshow files per plot title. + # File names for the uploaded images will be recycled in such a way that no more than + # X images are stored in the upload destination for each matplotlib plot title. + matplotlib_untitled_history_size: 100 + # Settings for generated debug images images { format: JPEG @@ -140,6 +145,9 @@ sdk { # Support stopping an experiment in case it was externally stopped, status was changed or task was reset support_stopping: True + # Default Task output_uri. if output_uri is not provided to Task.init, default_output_uri will be used instead. + default_output_uri: "" + # Development mode worker worker { # Status report period in seconds diff --git a/trains/config/default/sdk.conf b/trains/config/default/sdk.conf index d181c4e3..efcbbf54 100644 --- a/trains/config/default/sdk.conf +++ b/trains/config/default/sdk.conf @@ -135,6 +135,9 @@ # Support stopping an experiment in case it was externally stopped, status was changed or task was reset support_stopping: True + # Default Task output_uri. if output_uri is not provided to Task.init, default_output_uri will be used instead. + default_output_uri: "" + # Development mode worker worker { # Status report period in seconds diff --git a/trains/task.py b/trains/task.py index 6c8bd569..046fb0d8 100644 --- a/trains/task.py +++ b/trains/task.py @@ -79,6 +79,7 @@ class Task(_Task): __task_id_reuse_time_window_in_hours = float(config.get('development.task_reuse_time_window_in_hours', 24.0)) __store_diff_on_train = config.get('development.store_uncommitted_code_diff_on_train', False) __detect_repo_async = config.get('development.vcs_repo_detect_async', False) + __default_output_uri = config.get('development.default_output_uri', None) class _ConnectedParametersType(object): argparse = "argument_parser" @@ -253,6 +254,8 @@ class Task(_Task): ) if output_uri: task.output_uri = output_uri + elif cls.__default_output_uri: + task.output_uri = cls.__default_output_uri else: task = cls( private=cls.__create_protection, @@ -847,26 +850,34 @@ class Task(_Task): return scalar_metrics @classmethod - def set_credentials(cls, host=None, key=None, secret=None): + def set_credentials(cls, api_host=None, web_host=None, files_host=None, key=None, secret=None, host=None): """ Set new default TRAINS-server host and credentials These configurations will be overridden by wither OS environment variables or trains.conf configuration file Notice! credentials needs to be set *prior* to Task initialization - :param host: host url, example: host='http://localhost:8008' - :type host: str - :param key: user key/secret pair, example: key='thisisakey123' - :type key: str - :param secret: user key/secret pair, example: secret='thisisseceret123' - :type secret: str + :param str api_host: Trains API server url, example: host='http://localhost:8008' + :param str web_host: Trains WEB server url, example: host='http://localhost:8080' + :param str files_host: Trains Files server url, example: host='http://localhost:8081' + :param str key: user key/secret pair, example: key='thisisakey123' + :param str secret: user key/secret pair, example: secret='thisisseceret123' + :param str host: host url, example: host='http://localhost:8008' (deprecated) """ - if host: - Session.default_host = host + if api_host: + Session.default_host = api_host + if web_host: + Session.default_web = web_host + if files_host: + Session.default_files = files_host if key: Session.default_key = key if secret: Session.default_secret = secret + if host: + Session.default_host = host + Session.default_web = web_host or '' + Session.default_files = files_host or '' @classmethod def _reset_current_task_obj(cls):