def subcmd_actions(command_data):
    client_name = command_data["subcmd_args"][0] if len(
        command_data["subcmd_args"]) > 0 else None
    if client_name == None:
        print "Need client name to add model for"
        return

    data_file_fpath = command_data["subcmd_args"][1] if len(
        command_data["subcmd_args"]) > 1 else None
    if data_file_fpath == None:
        print "Need data file path to import"
        return

    zkroot = command_data["conf_data"]["zkroot"]
    if not is_existing_client(zkroot, client_name):
        print "Invalid client[{client_name}]".format(**locals())
        return

    if not os.path.isfile(data_file_fpath):
        print "Invalid file[{data_file_fpath}]".format(**locals())
        return

    db_settings = get_db_settings(zkroot, client_name)

    out_file_dir = command_data["conf_data"][
        "seldon_models"] + "/" + client_name + "/actions/1"
    out_file_fpath = out_file_dir + "/actions.json"

    seldon_utils.mkdir_p(out_file_dir)

    import_actions_utils.import_actions(client_name, db_settings,
                                        data_file_fpath, out_file_fpath)
Ejemplo n.º 2
0
def subcmd_actions(command_data):
    client_name = command_data["subcmd_args"][0] if len(command_data["subcmd_args"])>0 else None
    if client_name == None:
        print "Need client name to add model for"
        return

    data_file_fpath = command_data["subcmd_args"][1] if len(command_data["subcmd_args"])>1 else None
    if data_file_fpath == None:
        print "Need data file path to import"
        return

    zkroot = command_data["conf_data"]["zkroot"]
    if not is_existing_client(zkroot, client_name):
        print "Invalid client[{client_name}]".format(**locals())
        return

    if not os.path.isfile(data_file_fpath):
        print "Invalid file[{data_file_fpath}]".format(**locals())
        return

    db_settings = get_db_settings(zkroot, client_name)

    out_file_dir = command_data["conf_data"]["seldon_models"] + "/" + client_name + "/actions/1"
    out_file_fpath = out_file_dir + "/actions.json"

    seldon_utils.mkdir_p(out_file_dir)

    import_actions_utils.import_actions(client_name, db_settings, data_file_fpath, out_file_fpath)
Ejemplo n.º 3
0
def write_data_to_file(data_fpath, data):
    json = seldon_utils.dict_to_json(data, True) if isinstance(data,dict) else str(data)
    seldon_utils.mkdir_p(os.path.dirname(data_fpath))
    f = open(data_fpath,'w')
    f.write(json)
    f.write('\n')
    f.close()
    print "Writing data to file[{data_fpath}]".format(**locals())
Ejemplo n.º 4
0
def write_data_to_file(data_fpath, data):
    json = seldon_utils.dict_to_json(data, True) if isinstance(data,dict) else str(data)
    seldon_utils.mkdir_p(os.path.dirname(data_fpath))
    f = open(data_fpath,'w')
    f.write(json)
    f.write('\n')
    f.close()
    print "Writing data to file[{data_fpath}]".format(**locals())
Ejemplo n.º 5
0
def action_actions(command_data, opts):
    client_name = opts.client_name
    data_file_fpath = opts.file_path

    zkroot = command_data["conf_data"]["zkroot"]
    if not is_existing_client(zkroot, client_name):
        print "Invalid client[{client_name}]".format(**locals())
        sys.exit(1)

    if not os.path.isfile(data_file_fpath):
        print "Invalid file[{data_file_fpath}]".format(**locals())
        sys.exit(1)

    db_settings = get_db_settings(zkroot, client_name)

    out_file_dir = command_data["conf_data"]["seldon_models"] + "/" + client_name + "/actions/1"
    out_file_fpath = out_file_dir + "/actions.json"

    seldon_utils.mkdir_p(out_file_dir)

    import_actions_utils.import_actions(client_name, db_settings, data_file_fpath, out_file_fpath)
Ejemplo n.º 6
0
def action_actions(command_data, opts):
    client_name = opts.client_name
    data_file_fpath = opts.file_path

    zkroot = command_data["conf_data"]["zkroot"]
    if not is_existing_client(zkroot, client_name):
        print "Invalid client[{client_name}]".format(**locals())
        sys.exit(1)

    if not os.path.isfile(data_file_fpath):
        print "Invalid file[{data_file_fpath}]".format(**locals())
        sys.exit(1)

    db_settings = get_db_settings(zkroot, client_name)

    out_file_dir = command_data["conf_data"][
        "seldon_models"] + "/" + client_name + "/actions/1"
    out_file_fpath = out_file_dir + "/actions.json"

    seldon_utils.mkdir_p(out_file_dir)

    import_actions_utils.import_actions(client_name, db_settings,
                                        data_file_fpath, out_file_fpath)