def set(verbose, host, http_port, ws_port, use_https): # pylint:disable=redefined-builtin """Set the global config values. Example: \b ```bash $ polyaxon config set --hots=localhost http_port=80 ``` """ _config = GlobalConfigManager.get_config_or_default() if verbose is not None: _config.verbose = verbose if host is not None: _config.host = host if http_port is not None: _config.http_port = http_port if ws_port is not None: _config.ws_port = ws_port if use_https is not None: _config.use_https = use_https GlobalConfigManager.set_config(_config) Printer.print_success('Config was update.') # Reset cli config CliConfigManager.purge()
def set(**kwargs): # pylint:disable=redefined-builtin """Set the global config values. Example: \b ```bash $ polyaxon config set --host=localhost --port=80 ``` """ try: _config = GlobalConfigManager.get_config_or_default() except Exception as e: Printer.print_error('Polyaxon load configuration.') Printer.print_error('Error message `{}`.'.format(e)) Printer.print_header( 'You can reset your config by running: polyaxon config purge') sys.exit(1) for key, value in kwargs.items(): if value is not None: setattr(_config, key, value) GlobalConfigManager.set_config(_config) Printer.print_success('Config was updated.') # Reset cli config CliConfigManager.purge()
def set(verbose, host, http_port, ws_port, use_https): """Set global config values. Example: ``` polyaxon config set --hots=localhost http_port=80 ``` """ config = GlobalConfigManager.get_config() or GlobalConfigManager.CONFIG() if verbose is not None: config.verbose = verbose if host is not None: config.host = host if http_port is not None: config.http_port = http_port if ws_port is not None: config.ws_port = ws_port if use_https is not None: config.use_https = use_https GlobalConfigManager.set_config(config) Printer.print_success('Config was update.')
def cli(context, verbose, offline): """ Polyaxon CLI tool to: * Parse, Validate, and Check Polyaxonfiles. * Interact with Polyaxon server. * Run and Monitor experiments. Check the help available for each command listed below. """ try: configure_logger(verbose or GlobalConfigManager.get_value('verbose')) except ValidationError: GlobalConfigManager.purge() non_check_cmds = [ 'completion', 'config', 'version', 'login', 'logout', 'deploy', 'admin', 'teardown' ] context.obj = context.obj or {} context.obj["offline"] = offline if offline: os.environ['POLYAXON_IS_OFFLINE'] = 'true' settings.IS_OFFLINE = True if not (context.invoked_subcommand in non_check_cmds or offline): check_cli_version()
def config(list, get): """Command for setting and getting global configurations.""" if list: config = GlobalConfigManager.get_config() click.echo(config.to_dict()) if get: v = GlobalConfigManager.get_value(get) click.echo(v)
def __init__(self): self.host = GlobalConfigManager.get_value('host') self.http_port = GlobalConfigManager.get_value('http_port') self.ws_port = GlobalConfigManager.get_value('ws_port') self.use_https = GlobalConfigManager.get_value('use_https') self.token = AuthConfigManager.get_value('token') self.params = dict(host=self.host, http_port=self.http_port, ws_port=self.ws_port, token=self.token, use_https=self.use_https, reraise=True)
def login(token): """Log into Polyaxon via Auth0.""" if not token: cli_info_url = "{}/settings/security".format( GlobalConfigManager.get_value('host')) click.confirm( 'Authentication token page will now open in your browser. Continue?', abort=True, default=True) webbrowser.open(cli_info_url) logger.info("Please copy and paste the authentication token.") access_code = click.prompt( 'This is an invisible field. Paste token and press ENTER', type=str, hide_input=True) if not access_code: logger.info( "Empty token received. " "Make sure your shell is handling the token appropriately.") logger.info( "See docs for help: http://docs.polyaxon.com/faqs/authentication/") return access_code = access_code.strip(" ") user = AuthClient().get_user(access_code) access_token = AccessTokenConfig(username=user.username, token=access_code) AuthConfigManager.set_config(access_token) logger.info("Login Successful")
def cli(verbose): """ Polyaxon CLI tool for * parsing Polyaxonfiles, * interacting with hub.Polyaxon server * executing commands. Check the help available for each command listed below. """ configure_logger(verbose or GlobalConfigManager.get_value('verbose'))
def set(verbose, host, working_directory): """ :param verbose: :param host: :param working_directory: :return: """ config = GlobalConfigManager.get_config() or GlobalConfigManager.CONFIG() if verbose is not None: config.verbose = verbose if host is not None: config.host = host if working_directory is not None: config.working_directory = working_directory GlobalConfigManager.set_config(config)
def set(**kwargs): # pylint:disable=redefined-builtin """Set the global config values. Example: \b ```bash $ polyaxon config set --hots=localhost http_port=80 ``` """ _config = GlobalConfigManager.get_config_or_default() for key, value in kwargs.items(): if value is not None: setattr(_config, key, value) GlobalConfigManager.set_config(_config) Printer.print_success('Config was updated.') # Reset cli config CliConfigManager.purge()
def __init__(self): host = GlobalConfigManager.get_value('host') if not host: Printer.print_error( 'Received an invalid config, you need to provide a valid host.' ) sys.exit(1) port = GlobalConfigManager.get_value('port') use_https = GlobalConfigManager.get_value('use_https') verify_ssl = GlobalConfigManager.get_value('verify_ssl') token = AuthConfigManager.get_value('token') super(PolyaxonClient, self).__init__( host=host, http_port=port, ws_port=port, use_https=use_https, verify_ssl=verify_ssl, token=token, schema_response=True, reraise=True, )
def cli(context, verbose): """ Polyaxon CLI tool to: * Parse, Validate, and Check Polyaxonfiles. * Interact with Polyaxon server. * Run and Monitor experiments. Check the help available for each command listed below. """ try: configure_logger(verbose or GlobalConfigManager.get_value('verbose')) except ValidationError: GlobalConfigManager.purge() non_check_cmds = [ 'completion', 'config', 'version', 'login', 'logout', 'deploy', 'admin', 'teardown' ] if context.invoked_subcommand not in non_check_cmds: check_cli_version()
def get(keys): """Get global config values by keys. Example: ``` polyaxon config get host http_port ``` """ config = GlobalConfigManager.get_config() or GlobalConfigManager.CONFIG() if len(keys) == 0: return print_values = {} for key in keys: if hasattr(config, key): print_values[key] = getattr(config, key) else: click.echo('Key `{}` is not recognised.'.format(key)) dict_tabulate(print_values, )
def cli(context, verbose): """ Polyaxon CLI tool to: * parse Polyaxonfiles * interact with Polyaxon server * execute commands. Check the help available for each command listed below. """ configure_logger(verbose or GlobalConfigManager.get_value('verbose')) if context.invoked_subcommand not in ['config', 'version']: check_cli_version()
def cli(context, verbose): """ Polyaxon CLI tool to: * Parse, Validate, and Check Polyaxonfiles. * Interact with Polyaxon server. * Run and Monitor experiments. Check the help available for each command listed below. """ configure_logger(verbose or GlobalConfigManager.get_value('verbose')) if context.invoked_subcommand not in [ 'config', 'version', 'login', 'logout' ]: check_cli_version()
def get(keys): """Get the global config values by keys. Example: \b ```bash $ polyaxon config get host port ``` """ _config = GlobalConfigManager.get_config_or_default() if not keys: return print_values = {} for key in keys: if hasattr(_config, key): print_values[key] = getattr(_config, key) else: click.echo('Key `{}` is not recognised.'.format(key)) dict_tabulate(print_values, )
def config(list): # pylint:disable=redefined-builtin """Set and get the global configurations.""" if list: _config = GlobalConfigManager.get_config_or_default() Printer.print_header('Current config:') dict_tabulate(_config.to_dict())
def purge(**kwargs): # pylint:disable=redefined-builtin """Purge the global config values.""" GlobalConfigManager.purge() Printer.print_success('Config was removed.') # Reset cli config CliConfigManager.purge()
def __init__(self): self.base_url = "{}/api/v1/".format( GlobalConfigManager.get_value('host')) self.auth_config = AuthConfigManager.get_config()
def config(list): """Set and get global configurations.""" if list: config = GlobalConfigManager.get_config() Printer.print_header('Current config:') dict_tabulate(config.to_dict())