1
This commit is contained in:
@@ -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 = []
|
results = []
|
||||||
for file in list_files:
|
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)
|
results.append(result)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
async def import_conflict_to_elastic(
|
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 = []
|
list_files = []
|
||||||
@@ -101,7 +101,8 @@ async def import_conflict_to_elastic(
|
|||||||
target=run_to_procssing,
|
target=run_to_procssing,
|
||||||
args=(
|
args=(
|
||||||
list_input[split : list_spilt[b + 1]],
|
list_input[split : list_spilt[b + 1]],
|
||||||
out_put_index_name,
|
index_name,
|
||||||
|
file_jumps,
|
||||||
host,
|
host,
|
||||||
password,
|
password,
|
||||||
),
|
),
|
||||||
@@ -114,7 +115,7 @@ async def import_conflict_to_elastic(
|
|||||||
print("finish ⏹️✅")
|
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()
|
time = datetime.datetime.now().timestamp()
|
||||||
file_name = file.split("/")[-1:][0]
|
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:
|
if len(bulk_data) > 200:
|
||||||
# total_count += len(bulk_data)
|
# total_count += len(bulk_data)
|
||||||
# print("=" * 10, "to_elastic , total=" + str(total_count) + " -- " + str(total_import))
|
# 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 = []
|
bulk_data = []
|
||||||
|
|
||||||
if len(bulk_data) > 0:
|
if len(bulk_data) > 0:
|
||||||
# total_count += len(bulk_data)
|
# total_count += len(bulk_data)
|
||||||
# print("=" * 10, "to_elastic , total=" + str(total_count) + " -- " + str(total_import))
|
# 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 = []
|
bulk_data = []
|
||||||
|
|
||||||
|
|
||||||
|
with open(file_jumps, "w") as f:
|
||||||
|
f.write("\n"+file)
|
||||||
|
|
||||||
# total_import += total_count
|
# total_import += total_count
|
||||||
time1 = datetime.datetime.now().timestamp()
|
time1 = datetime.datetime.now().timestamp()
|
||||||
time = time1 - time
|
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(
|
def append_conflict_to_elastic(
|
||||||
elastic,
|
elastic,
|
||||||
input_path,
|
input_path,
|
||||||
out_put_index_name,
|
index_name,
|
||||||
ref_key,
|
ref_key,
|
||||||
fields=[
|
fields=[
|
||||||
"subject_unity",
|
"subject_unity",
|
||||||
@@ -265,7 +271,7 @@ def append_conflict_to_elastic(
|
|||||||
_source = {}
|
_source = {}
|
||||||
res = None
|
res = None
|
||||||
try:
|
try:
|
||||||
res = elastic.get_document(out_put_index_name, _id)
|
res = elastic.get_document(index_name, _id)
|
||||||
except:
|
except:
|
||||||
list_notfound.append(_id)
|
list_notfound.append(_id)
|
||||||
if not import_if_not_found:
|
if not import_if_not_found:
|
||||||
@@ -625,26 +631,26 @@ def append_conflict_to_elastic(
|
|||||||
if len(bulk_data_import) > 200:
|
if len(bulk_data_import) > 200:
|
||||||
total_count += len(bulk_data_import)
|
total_count += len(bulk_data_import)
|
||||||
print("=!" * 10, " import to_elastic , total=" + str(total_count))
|
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 = []
|
bulk_data_import = []
|
||||||
|
|
||||||
if len(bulk_data) > 200:
|
if len(bulk_data) > 200:
|
||||||
total_count += len(bulk_data)
|
total_count += len(bulk_data)
|
||||||
print("=" * 10, "to_elastic , total=" + str(total_count))
|
print("=" * 10, "to_elastic , total=" + str(total_count))
|
||||||
elastic.updateBulkList(bulk_data, out_put_index_name)
|
elastic.updateBulkList(bulk_data, index_name)
|
||||||
bulk_data = []
|
bulk_data = []
|
||||||
# break
|
# break
|
||||||
|
|
||||||
if len(bulk_data_import) > 0:
|
if len(bulk_data_import) > 0:
|
||||||
total_count += len(bulk_data_import)
|
total_count += len(bulk_data_import)
|
||||||
print("=!" * 10, " import to_elastic , total=" + str(total_count))
|
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 = []
|
bulk_data_import = []
|
||||||
|
|
||||||
if len(bulk_data) > 0:
|
if len(bulk_data) > 0:
|
||||||
total_count += len(bulk_data)
|
total_count += len(bulk_data)
|
||||||
print("=" * 10, "to_elastic , total=" + str(total_count))
|
print("=" * 10, "to_elastic , total=" + str(total_count))
|
||||||
elastic.updateBulkList(bulk_data, out_put_index_name)
|
elastic.updateBulkList(bulk_data, index_name)
|
||||||
bulk_data = []
|
bulk_data = []
|
||||||
|
|
||||||
|
|
||||||
@@ -993,6 +999,6 @@ if __name__ == "__main__":
|
|||||||
file_jumps = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3_jump_files.json"
|
file_jumps = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3_jump_files.json"
|
||||||
asyncio.run(
|
asyncio.run(
|
||||||
import_conflict_to_elastic(
|
import_conflict_to_elastic(
|
||||||
input_path, "mj_qa_conflict_2", file_jumps, host, password
|
input_path, "mj_qa_conflict", file_jumps, host, password
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user