From 9ad8aeee13e73ffac8584f1a281554eb1f8d12e4 Mon Sep 17 00:00:00 2001 From: hsafaei Date: Wed, 1 Jul 2026 19:29:56 +0330 Subject: [PATCH] 1 --- app/majles/majles_conflict_works_async_v3.py | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/majles/majles_conflict_works_async_v3.py b/app/majles/majles_conflict_works_async_v3.py index c5cc9bd..471eb2c 100644 --- a/app/majles/majles_conflict_works_async_v3.py +++ b/app/majles/majles_conflict_works_async_v3.py @@ -47,10 +47,10 @@ def get_evaluation_data(data): ## ----------------------------------------------------------------------- -def run_to_procssing(list_files, out_put_index_name): +def run_to_procssing(list_files, out_put_index_name, host, password): results = [] for file in list_files: - result = asyncio.run(import_from_json(file, out_put_index_name)) + result = asyncio.run(import_from_json(file, out_put_index_name, host, password)) results.append(result) return results @@ -121,15 +121,19 @@ async def import_from_json(file, out_put_index_name, host, password) -> list: print("▶️", file_name) elastic = ElasticHelper( - es_url=f"http://{host}:6900", es_pass=password, es_user="elastic" + es_url=host, es_pass=password, es_user="elastic" ) data_all = [] try: - with open(file, "r") as rfile: + with open(file, "rb") as rfile: data_all = json.loads(rfile.read()) - except: - print("not read file {file}") - data_all = data_all[0] + if data_all[0] and isinstance(data_all[0], list): + data_all = data_all[0] + + + except Exception as e: + print(f"not read file {file}", str(e)) + bulk_data = [] failed_data = [] total_count = 0 @@ -986,9 +990,9 @@ if __name__ == "__main__": # elastic.es.close() input_path = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3" - file_jumps = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3_jump_ids.json" + file_jumps = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3_jump_files.json" asyncio.run( import_conflict_to_elastic( - input_path, "mj_qa_conflict", file_jumps, host, password + input_path, "mj_qa_conflict_2", file_jumps, host, password ) )