Add default_output_uri in trains.conf configuration

Fix Task.set_credentials support for different web/api/files hosts
This commit is contained in:
allegroai 2019-11-23 01:27:45 +02:00
parent 8ab982cbc9
commit 8aa86225e2
3 changed files with 31 additions and 9 deletions

View File

@ -31,6 +31,11 @@ sdk {
# X files are stored in the upload destination for each metric/variant combination. # X files are stored in the upload destination for each metric/variant combination.
file_history_size: 100 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 # Settings for generated debug images
images { images {
format: JPEG 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 an experiment in case it was externally stopped, status was changed or task was reset
support_stopping: True 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 # Development mode worker
worker { worker {
# Status report period in seconds # Status report period in seconds

View File

@ -135,6 +135,9 @@
# Support stopping an experiment in case it was externally stopped, status was changed or task was reset # Support stopping an experiment in case it was externally stopped, status was changed or task was reset
support_stopping: True 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 # Development mode worker
worker { worker {
# Status report period in seconds # Status report period in seconds

View File

@ -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)) __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) __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) __detect_repo_async = config.get('development.vcs_repo_detect_async', False)
__default_output_uri = config.get('development.default_output_uri', None)
class _ConnectedParametersType(object): class _ConnectedParametersType(object):
argparse = "argument_parser" argparse = "argument_parser"
@ -253,6 +254,8 @@ class Task(_Task):
) )
if output_uri: if output_uri:
task.output_uri = output_uri task.output_uri = output_uri
elif cls.__default_output_uri:
task.output_uri = cls.__default_output_uri
else: else:
task = cls( task = cls(
private=cls.__create_protection, private=cls.__create_protection,
@ -847,26 +850,34 @@ class Task(_Task):
return scalar_metrics return scalar_metrics
@classmethod @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 Set new default TRAINS-server host and credentials
These configurations will be overridden by wither OS environment variables or trains.conf configuration file 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 Notice! credentials needs to be set *prior* to Task initialization
:param host: host url, example: host='http://localhost:8008' :param str api_host: Trains API server url, example: host='http://localhost:8008'
:type host: str :param str web_host: Trains WEB server url, example: host='http://localhost:8080'
:param key: user key/secret pair, example: key='thisisakey123' :param str files_host: Trains Files server url, example: host='http://localhost:8081'
:type key: str :param str key: user key/secret pair, example: key='thisisakey123'
:param secret: user key/secret pair, example: secret='thisisseceret123' :param str secret: user key/secret pair, example: secret='thisisseceret123'
:type secret: str :param str host: host url, example: host='http://localhost:8008' (deprecated)
""" """
if host: if api_host:
Session.default_host = host Session.default_host = api_host
if web_host:
Session.default_web = web_host
if files_host:
Session.default_files = files_host
if key: if key:
Session.default_key = key Session.default_key = key
if secret: if secret:
Session.default_secret = secret Session.default_secret = secret
if host:
Session.default_host = host
Session.default_web = web_host or ''
Session.default_files = files_host or ''
@classmethod @classmethod
def _reset_current_task_obj(cls): def _reset_current_task_obj(cls):