예제 #1
0
async def load_video(item: Item):
    # Insert all the video under the file path to Milvus/MySQL
    try:
        total_num = do_load(item.Table, item.File, MODEL, FRAME, MILVUS_CLI,
                            MYSQL_CLI)
        LOGGER.info(
            "Successfully loaded data, total count: {}".format(total_num))
        return {'status': True, 'msg': "Successfully loaded data!"}
    except Exception as e:
        LOGGER.error(e)
        return {'status': False, 'msg': e}, 400
예제 #2
0
async def load_images(item: Item):
    # Insert all the image under the file path to Milvus/MySQL
    try:
        total_num = do_load(item.Table, item.File, MODEL, MILVUS_CLI,
                            MYSQL_CLI)
        LOGGER.info(
            "Successfully loaded data, total objects: {}".format(total_num))
        return "Successfully loaded data!"
    except Exception as e:
        LOGGER.error(e)
        return {'status': False, 'msg': e}, 400
예제 #3
0
async def do_load_api(file: UploadFile = File(...), table_name: str = None):
    try:
        text = await file.read()
        fname = file.filename
        dirs = "QA_data"
        if not os.path.exists(dirs):
            os.makedirs(dirs)
        fname_path = os.path.join(os.getcwd(), os.path.join(dirs, fname))
        with open(fname_path, 'wb') as f:
            f.write(text)
    except Exception as e:
        return {'status': False, 'msg': 'Failed to load data.'}
    try:
        total_num = do_load(table_name, fname_path, MODEL, MILVUS_CLI,
                            MYSQL_CLI)
        LOGGER.info(
            "Successfully loaded data, total count: {}".format(total_num))
        return {
            'status': True,
            'msg': "Successfully loaded data: {}".format(total_num)
        }, 200
    except Exception as e:
        LOGGER.error(e)
        return {'status': False, 'msg': e}, 400