Ejemplo n.º 1
0
 def post_reset(cls, body, headers, content_type):
     """
     Handle a reset config post request
     :param content_type: content_type
     :param body: post body
     :param headers: post headers
     :return: success, status code, message, response_body, content_type
     """
     Config.set_config(Config.create_empty_config())
     Config.load()
     return True, 200, "OK", b"OK", None
Ejemplo n.º 2
0
def main(argv):
    config = Config()
    #config.LR = config.LR/10
    path = 'config.json'

    if len(argv) == 1:
        print(
            "Using default config, specify the config file path to use custom config..."
        )
    elif len(argv) == 2:
        if argv[1] == '-h' or argv[1] == '--help':
            print("Usage: {} [path to config file]".format(argv[0]))
            print(
                "Refer to config.json and util/config.py for further information about the usage"
            )
            exit(0)
        else:
            path = argv[1]
    else:
        print("Illegal number of arguments, use {0} -h or {0} --help for help".
              format(argv[0]))

    config.load(path)

    return print(config)

    # for compatibility when running in a notebook
    os.chdir('..')
    sys.path.append('src')

    if config.MODEL == 1:
        train('edge', config)
    elif config.MODEL == 2:
        train('sr', config)
    elif config.MODEL == 3:
        train('both', config)
Ejemplo n.º 3
0
 def post_config(cls, body, headers, content_type):
     """
     Post the config JSON
     :param content_type: content_type
     :param body: post body
     :param headers: post headers
     :return: success, status code, message, response_body, content_type
     """
     if content_type != "application/json":
         return False, 400, "Bad request", "Invalid content type", None
     if body is None:
         return False, 400, "Bad Request", "Missing JSON body", None
     try:
         body_json = json.loads(body)
         if not Config.verify_config(body_json):
             return False, 400, "Bad Request", "Invalid config format", None
         else:
             Config.set_config(body_json)
             Config.load()
     except ValueError:
         return False, 400, "Bad Request", "Invalid JSON body", None
     if not Config.verify_config(body_json):
         return False, 400, "Bad Request", "Invalid JSON body", None
     return True, 200, "OK", b"OK", None