def main(task, num_docs, request_size, data_set, model_name): config(model_name) workspace = os.environ['JINA_WORKSPACE'] logger = JinaLogger('cross-modal-search') if 'index' in task: if os.path.exists(workspace): logger.error( f'\n +------------------------------------------------------------------------------------+ \ \n | ������ | \ \n | The directory {workspace} already exists. Please remove it before indexing again. | \ \n | ������ | \ \n +------------------------------------------------------------------------------------+' ) sys.exit(1) logger.info(f'### task = {task}') if task == 'index': with Flow.load_config('flow-index.yml') as f: with TimeContext(f'QPS: indexing {num_docs}', logger=f.logger): f.index( input_fn=input_index_data(num_docs, request_size, data_set), request_size=request_size ) elif task == 'index_restful': index_restful(num_docs) elif task == 'query': with Flow.load_config('flow-query.yml') as f: f.use_rest_gateway() f.block() elif task == 'query_restful': if not os.path.exists(workspace): logger.warning(f'The directory {workspace} does not exist. Please index first via `python app.py -t index`') query_restful() elif task == 'dryrun': dryrun()
def main(task, num_docs, top_k): config() workspace = os.environ["JINA_WORKSPACE"] logger = JinaLogger('chinese-text-search') if 'index' in task: if os.path.exists(workspace): logger.error( f'\n +------------------------------------------------------------------------------------+ \ \n | 🤖🤖🤖 | \ \n | The directory {workspace} already exists. Please remove it before indexing again. | \ \n | 🤖🤖🤖 | \ \n +------------------------------------------------------------------------------------+' ) sys.exit(1) logger.info(f'### task = {task}') if task == "index": index(num_docs) elif task == "index_restful": index_restful(num_docs) elif task == "query": if not os.path.exists(workspace): logger.warning( f'The directory {workspace} does not exist. Please index first via `python app.py -t index`' ) query(top_k) elif task == "query_restful": if not os.path.exists(workspace): logger.warning( f'The directory {workspace} does not exist. Please index first via `python app.py -t index`' ) query_restful() elif task == "dryrun": dryrun()
def main(task, num_docs_query, num_docs_index): config(task) logger = JinaLogger('fashion-example-query') workspace = os.environ['JINA_WORKDIR'] if task == 'index': if os.path.exists(workspace): logger.error( f'\n +---------------------------------------------------------------------------------+ \ \n | ������ | \ \n | The directory {workspace} already exists. Please remove it before indexing again. | \ \n | ������ | \ \n +---------------------------------------------------------------------------------+' ) sys.exit(1) targets = download_fashionmnist() if task == 'index': index(num_docs_index, targets) elif task == 'query': if not os.path.exists(workspace): logger.error( f'The directory {workspace} does not exist. Please index first via `python app.py -t index`' ) sys.exit(1) query(num_docs_query, targets) else: raise NotImplementedError( f'unknown task: {task}. A valid task is either `index` or `query`.' )
def main(task, num_docs, request_size, data_set, model_name): config(model_name) workspace = os.environ['JINA_WORKSPACE'] logger = JinaLogger('cross-modal-search') if 'index' in task: if os.path.exists(workspace): logger.error( f'\n +------------------------------------------------------------------------------------+ \ \n | ������ | \ \n | The directory {workspace} already exists. Please remove it before indexing again. | \ \n | ������ | \ \n +------------------------------------------------------------------------------------+' ) sys.exit(1) if 'query' in task and not os.path.exists(workspace): logger.info(f"The directory {workspace} does not exist. Please index first via `python app.py -t index`") sys.exit(1) logger.info(f'### task = {task}') if task == 'index': index(data_set, num_docs, request_size) if task == 'query_restful': query_restful()