Esempio n. 1
0
 def do_action_set(self, args):
     import re
     if not args.contents:
         return get_defaults(False, True, False) if args.is_global else get_defaults(True, True, False)
     kv_pairs = []
     for content in args.contents:
         m = re.match("^([^=]+?)([\+|\-]*=)([^=]*)$", content)
         if m:
             kv_pairs.append(m.groups())
         else:
             kv_pairs.append((content, '', ''))
     for kv_pair in kv_pairs:
         assert kv_pair[0] and kv_pair[1] in ["=", "+=", "-="] and kv_pair[2], \
             f"must specify a key=value pair ({kv_pair[0]}, {kv_pair[2]})"
         update_default(kv_pair[0], kv_pair[2], is_global=args.is_global)
Esempio n. 2
0
    def define_arguments_upload(self, parser: argparse.ArgumentParser):
        cli_add_arguments(parser, [
            '--cluster-alias', '--storage-alias', '--overwrite', 'local_path',
            'remote_path'
        ])

    def do_action_upload(self, args):
        return self.__clusters__.get_client(args.cluster_alias).get_storage(
            args.storage_alias).upload(remote_path=args.remote_path,
                                       local_path=args.local_path,
                                       overwrite=getattr(
                                           args, "overwrite", False))


cluster_cfg_file = __flags__.get_cluster_cfg_file(
    get_defaults()["clusters-in-local"])


def generate_cli_structure(is_beta: bool):
    cli_s = {
        "cluster": {
            "help": "cluster management",
            "factory": ActionFactoryForCluster,
            "actions": {
                "list": "list clusters in config file %s" % cluster_cfg_file,
                "resources":
                "report the (available, used, total) resources of the cluster",
                "update":
                "check the healthness of clusters and update the information",
                "edit":
                "edit the config file in your editor %s" % cluster_cfg_file,
Esempio n. 3
0
    def define_arguments_download(self, parser: argparse.ArgumentParser):
        cli_add_arguments(
            parser, ['--cluster-alias', '--storage-alias', 'remote_path', 'local_path'])

    def do_action_download(self, args):
        return self.__clusters__.get_client(args.cluster_alias).get_storage(args.storage_alias).download(remote_path=args.remote_path, local_path=args.local_path)

    def define_arguments_upload(self, parser: argparse.ArgumentParser):
        cli_add_arguments(parser, [
                          '--cluster-alias', '--storage-alias', '--overwrite', 'local_path', 'remote_path'])

    def do_action_upload(self, args):
        return self.__clusters__.get_client(args.cluster_alias).get_storage(args.storage_alias).upload(remote_path=args.remote_path, local_path=args.local_path, overwrite=getattr(args, "overwrite", False))


cluster_cfg_file = __flags__.get_cluster_cfg_file(get_defaults()["clusters-in-local"])


def generate_cli_structure(is_beta: bool):
    cli_s = {
        "cluster": {
            "help": "cluster management",
            "factory": ActionFactoryForCluster,
            "actions": {
                "list": "list clusters in config file %s" % cluster_cfg_file,
                "resources": "report the (available, used, total) resources of the cluster",
                "update": "check the healthness of clusters and update the information",
                "edit": "edit the config file in your editor %s" % cluster_cfg_file,
                "add": "add a cluster to config file %s" % cluster_cfg_file,
                "delete": "delete a cluster from config file %s" % cluster_cfg_file,
                "select": "select a cluster as default",
Esempio n. 4
0
 def default_config_file(self):
     from openpaisdk.flags import __flags__
     from openpaisdk.defaults import get_defaults
     return __flags__.get_cluster_cfg_file(
         get_defaults()["clusters-in-local"])