mirror of
https://github.com/clearml/clearml
synced 2025-03-12 14:48:30 +00:00
Improve trains-init configuration wizard
This commit is contained in:
parent
9f59346c33
commit
7af2d0c9d7
@ -441,7 +441,7 @@ class Session(TokenManager):
|
|||||||
|
|
||||||
# return default
|
# return default
|
||||||
host = cls.get_api_server_host(config)
|
host = cls.get_api_server_host(config)
|
||||||
if host == cls.default_host:
|
if host == cls.default_host and cls.default_web:
|
||||||
return cls.default_web
|
return cls.default_web
|
||||||
|
|
||||||
# compose ourselves
|
# compose ourselves
|
||||||
@ -468,7 +468,7 @@ class Session(TokenManager):
|
|||||||
|
|
||||||
# return default
|
# return default
|
||||||
host = cls.get_api_server_host(config)
|
host = cls.get_api_server_host(config)
|
||||||
if host == cls.default_host:
|
if host == cls.default_host and cls.default_files:
|
||||||
return cls.default_files
|
return cls.default_files
|
||||||
|
|
||||||
# compose ourselves
|
# compose ourselves
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from six.moves import input
|
from six.moves import input
|
||||||
from ...utilities.pyhocon import ConfigFactory
|
|
||||||
from pathlib2 import Path
|
from pathlib2 import Path
|
||||||
from six.moves.urllib.parse import urlparse
|
from six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
|
from trains.utilities.pyhocon import ConfigFactory
|
||||||
from trains.backend_api.session.defs import ENV_HOST
|
from trains.backend_api.session.defs import ENV_HOST
|
||||||
from trains.backend_config.defs import LOCAL_CONFIG_FILES
|
from trains.backend_config.defs import LOCAL_CONFIG_FILES
|
||||||
from trains.config import config_obj
|
from trains.config import config_obj
|
||||||
@ -78,20 +78,24 @@ def main():
|
|||||||
web_host = ''
|
web_host = ''
|
||||||
files_host = ''
|
files_host = ''
|
||||||
if not parsed_host.port:
|
if not parsed_host.port:
|
||||||
print('Host port not detected, do you wish to use the default 8008 port n/[y]? ', end='')
|
print('Host port not detected, do you wish to use the default 8080 port n/[y]? ', end='')
|
||||||
replace_port = input().lower()
|
replace_port = input().lower()
|
||||||
if not replace_port or replace_port == 'y' or replace_port == 'yes':
|
if not replace_port or replace_port == 'y' or replace_port == 'yes':
|
||||||
api_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8008' + parsed_host.path
|
api_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8008' + parsed_host.path
|
||||||
web_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8080' + parsed_host.path
|
web_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8080' + parsed_host.path
|
||||||
files_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8081' + parsed_host.path
|
files_host = parsed_host.scheme + "://" + parsed_host.netloc + ':8081' + parsed_host.path
|
||||||
|
elif not replace_port or replace_port.lower() == 'n' or replace_port.lower() == 'no':
|
||||||
|
web_host = input_host_port("Web", parsed_host)
|
||||||
|
api_host = input_host_port("API", parsed_host)
|
||||||
|
files_host = input_host_port("Files", parsed_host)
|
||||||
if not api_host:
|
if not api_host:
|
||||||
api_host = parsed_host.scheme + "://" + parsed_host.netloc + parsed_host.path
|
api_host = parsed_host.scheme + "://" + parsed_host.netloc + parsed_host.path
|
||||||
|
|
||||||
api_host = input_url('API Host', api_host)
|
api_host = input_url('API Host', api_host)
|
||||||
files_host = input_url('File Store Host', files_host)
|
files_host = input_url('File Store Host', files_host)
|
||||||
|
|
||||||
print('\nTRAINS Hosts configuration:\nAPI: {}\nWeb App: {}\nFile Store: {}\n'.format(
|
print('\nTRAINS Hosts configuration:\nWeb App: {}\nAPI: {}\nFile Store: {}\n'.format(
|
||||||
api_host, web_host, files_host))
|
web_host, api_host, files_host))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print(description.format(web_host), end='')
|
print(description.format(web_host), end='')
|
||||||
@ -167,16 +171,28 @@ def input_url(host_type, host=None):
|
|||||||
parse_input = input()
|
parse_input = input()
|
||||||
if host and (not parse_input or parse_input.lower() == 'yes' or parse_input.lower() == 'y'):
|
if host and (not parse_input or parse_input.lower() == 'yes' or parse_input.lower() == 'y'):
|
||||||
break
|
break
|
||||||
if parse_input and verify_url(parse_input):
|
parsed_host = verify_url(parse_input) if parse_input else None
|
||||||
host = parse_input
|
if parse_input and parsed_host:
|
||||||
|
host = parsed_host.scheme + "://" + parsed_host.netloc + parsed_host.path
|
||||||
break
|
break
|
||||||
return host
|
return host
|
||||||
|
|
||||||
|
|
||||||
|
def input_host_port(host_type, parsed_host):
|
||||||
|
print('Enter port for {} host '.format(host_type), end='')
|
||||||
|
replace_port = input().lower()
|
||||||
|
return parsed_host.scheme + "://" + parsed_host.netloc + (':{}'.format(replace_port) if replace_port else '') + \
|
||||||
|
parsed_host.path
|
||||||
|
|
||||||
|
|
||||||
def verify_url(parse_input):
|
def verify_url(parse_input):
|
||||||
try:
|
try:
|
||||||
if not parse_input.startswith('http://') and not parse_input.startswith('https://'):
|
if not parse_input.startswith('http://') and not parse_input.startswith('https://'):
|
||||||
parse_input = 'http://' + parse_input
|
# if we have a specific port, use http prefix, otherwise assume https
|
||||||
|
if ':' in parse_input:
|
||||||
|
parse_input = 'http://' + parse_input
|
||||||
|
else:
|
||||||
|
parse_input = 'https://' + parse_input
|
||||||
parsed_host = urlparse(parse_input)
|
parsed_host = urlparse(parse_input)
|
||||||
if parsed_host.scheme not in ('http', 'https'):
|
if parsed_host.scheme not in ('http', 'https'):
|
||||||
parsed_host = None
|
parsed_host = None
|
||||||
|
Loading…
Reference in New Issue
Block a user