diff --git a/app/majles/majles_conflict_works_async_v3.py b/app/majles/majles_conflict_works_async_v3.py index 471eb2c..b40f00a 100644 --- a/app/majles/majles_conflict_works_async_v3.py +++ b/app/majles/majles_conflict_works_async_v3.py @@ -47,16 +47,16 @@ def get_evaluation_data(data): ## ----------------------------------------------------------------------- -def run_to_procssing(list_files, out_put_index_name, host, password): +def run_to_procssing(list_files, index_name, file_jumps, host, password): results = [] for file in list_files: - result = asyncio.run(import_from_json(file, out_put_index_name, host, password)) + result = asyncio.run(import_from_json(file, index_name, file_jumps, host, password)) results.append(result) return results async def import_conflict_to_elastic( - input_path, out_put_index_name, file_jumps, host, password + input_path, index_name, file_jumps, host, password ): list_files = [] @@ -101,7 +101,8 @@ async def import_conflict_to_elastic( target=run_to_procssing, args=( list_input[split : list_spilt[b + 1]], - out_put_index_name, + index_name, + file_jumps, host, password, ), @@ -114,7 +115,7 @@ async def import_conflict_to_elastic( print("finish ⏹️✅") -async def import_from_json(file, out_put_index_name, host, password) -> list: +async def import_from_json(file, index_name, file_jumps, host, password) -> list: time = datetime.datetime.now().timestamp() file_name = file.split("/")[-1:][0] @@ -198,14 +199,19 @@ async def import_from_json(file, out_put_index_name, host, password) -> list: if len(bulk_data) > 200: # total_count += len(bulk_data) # print("=" * 10, "to_elastic , total=" + str(total_count) + " -- " + str(total_import)) - elastic.importBulkList(bulk_data, out_put_index_name) + elastic.importBulkList(bulk_data, index_name) bulk_data = [] if len(bulk_data) > 0: # total_count += len(bulk_data) # print("=" * 10, "to_elastic , total=" + str(total_count) + " -- " + str(total_import)) - elastic.importBulkList(bulk_data, out_put_index_name) + elastic.importBulkList(bulk_data, index_name) bulk_data = [] + + + with open(file_jumps, "w") as f: + f.write("\n"+file) + # total_import += total_count time1 = datetime.datetime.now().timestamp() time = time1 - time @@ -215,7 +221,7 @@ async def import_from_json(file, out_put_index_name, host, password) -> list: def append_conflict_to_elastic( elastic, input_path, - out_put_index_name, + index_name, ref_key, fields=[ "subject_unity", @@ -265,7 +271,7 @@ def append_conflict_to_elastic( _source = {} res = None try: - res = elastic.get_document(out_put_index_name, _id) + res = elastic.get_document(index_name, _id) except: list_notfound.append(_id) if not import_if_not_found: @@ -625,26 +631,26 @@ def append_conflict_to_elastic( if len(bulk_data_import) > 200: total_count += len(bulk_data_import) print("=!" * 10, " import to_elastic , total=" + str(total_count)) - elastic.importBulkList(bulk_data_import, out_put_index_name) + elastic.importBulkList(bulk_data_import, index_name) bulk_data_import = [] if len(bulk_data) > 200: total_count += len(bulk_data) print("=" * 10, "to_elastic , total=" + str(total_count)) - elastic.updateBulkList(bulk_data, out_put_index_name) + elastic.updateBulkList(bulk_data, index_name) bulk_data = [] # break if len(bulk_data_import) > 0: total_count += len(bulk_data_import) print("=!" * 10, " import to_elastic , total=" + str(total_count)) - elastic.importBulkList(bulk_data_import, out_put_index_name) + elastic.importBulkList(bulk_data_import, index_name) bulk_data_import = [] if len(bulk_data) > 0: total_count += len(bulk_data) print("=" * 10, "to_elastic , total=" + str(total_count)) - elastic.updateBulkList(bulk_data, out_put_index_name) + elastic.updateBulkList(bulk_data, index_name) bulk_data = [] @@ -993,6 +999,6 @@ if __name__ == "__main__": 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_2", file_jumps, host, password + input_path, "mj_qa_conflict", file_jumps, host, password ) )