Merge pull request #26 from SDSRV-IDP/enhancment/accuracy_calculation
Enhancment/accuracy calculation
This commit is contained in:
commit
10baecb337
@ -117,7 +117,10 @@ def process_csv_feedback(csv_file_path, feedback_id):
|
|||||||
_predict_result = copy.deepcopy(predict_result_to_ready(sub_rq.predict_result))
|
_predict_result = copy.deepcopy(predict_result_to_ready(sub_rq.predict_result))
|
||||||
_feedback_result = copy.deepcopy(sub_rq.feedback_result)
|
_feedback_result = copy.deepcopy(sub_rq.feedback_result)
|
||||||
_reviewed_result = copy.deepcopy(sub_rq.reviewed_result)
|
_reviewed_result = copy.deepcopy(sub_rq.reviewed_result)
|
||||||
image.processing_time = time_cost.get(image.doc_type, [0 for _ in range(image.index_in_request)])[image.index_in_request]
|
try:
|
||||||
|
image.processing_time = time_cost.get(image.doc_type, [0 for _ in range(image.index_in_request)])[image.index_in_request]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[ERROR] image.doc_type: {image.doc_type} - image.index_in_request: {image.index_in_request} - time_cost: {time_cost} - {e}")
|
||||||
if not validate_feedback_file(_feedback_result, _predict_result):
|
if not validate_feedback_file(_feedback_result, _predict_result):
|
||||||
status[request_id] = "Missalign imei number between feedback and predict"
|
status[request_id] = "Missalign imei number between feedback and predict"
|
||||||
continue
|
continue
|
||||||
|
66
cope2n-api/scripts/re_feedback.py
Normal file
66
cope2n-api/scripts/re_feedback.py
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import os
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
from datetime import datetime
|
||||||
|
# from tqdm import tqdm
|
||||||
|
|
||||||
|
ROOT = "/root/TannedCung/sbt-idp/feedback"
|
||||||
|
|
||||||
|
interval = 3
|
||||||
|
# Get the proxy URL from the environment variable
|
||||||
|
proxy_url = os.getenv('PROXY', "localhost")
|
||||||
|
|
||||||
|
# Define the login API URL
|
||||||
|
login_url = f'{proxy_url}/api/ctel/login/'
|
||||||
|
login_token = None
|
||||||
|
|
||||||
|
# Define the login credentials
|
||||||
|
login_credentials = {
|
||||||
|
'username': 'sbt',
|
||||||
|
# 'password': '7Eg4AbWIXDnufgn'
|
||||||
|
'password': 'abc'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the command to call the update API
|
||||||
|
update_url = f'{proxy_url}/api/ctel/images/feedback_file/'
|
||||||
|
|
||||||
|
def login():
|
||||||
|
login_token = None
|
||||||
|
login_response = requests.post(login_url, data=login_credentials)
|
||||||
|
# login_response.raise_for_status()
|
||||||
|
if login_response.status_code == 200:
|
||||||
|
login_token = login_response.json()['token']
|
||||||
|
print("[INFO] relogged in at {}".format(datetime.now()))
|
||||||
|
return login_token
|
||||||
|
|
||||||
|
def feedback(login_token, file_path):
|
||||||
|
headers = {'Authorization': login_token}
|
||||||
|
files = {
|
||||||
|
'files': (file_path.split("/")[-1], open(file_path, 'rb'), 'text/csv')
|
||||||
|
}
|
||||||
|
response = requests.post(update_url, headers=headers, files=files)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
print('[INFO]: File uploaded successfully.')
|
||||||
|
else:
|
||||||
|
print('[ERROR]: File upload failed.')
|
||||||
|
|
||||||
|
def search_csv_files(directory):
|
||||||
|
csv_files = []
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith(".csv"):
|
||||||
|
csv_files.append(os.path.join(root, file))
|
||||||
|
|
||||||
|
csv_files.sort(key=lambda path: int(os.path.basename(os.path.dirname(path))))
|
||||||
|
return csv_files
|
||||||
|
|
||||||
|
def main():
|
||||||
|
login_token = login()
|
||||||
|
list_files = search_csv_files(ROOT)
|
||||||
|
for _file in list_files:
|
||||||
|
feedback(login_token, _file)
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -5,7 +5,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
# Get the proxy URL from the environment variable
|
# Get the proxy URL from the environment variable
|
||||||
interval = 60*60*1 # 1 minute
|
interval = 60*60*1 # 1 minute
|
||||||
update_cost = 60*3
|
update_cost = 60*2
|
||||||
proxy_url = os.getenv('PROXY', "localhost")
|
proxy_url = os.getenv('PROXY', "localhost")
|
||||||
|
|
||||||
# Define the login API URL
|
# Define the login API URL
|
||||||
@ -15,7 +15,8 @@ login_token = None
|
|||||||
# Define the login credentials
|
# Define the login credentials
|
||||||
login_credentials = {
|
login_credentials = {
|
||||||
'username': 'sbt',
|
'username': 'sbt',
|
||||||
'password': '7Eg4AbWIXDnufgn'
|
# 'password': '7Eg4AbWIXDnufgn'
|
||||||
|
'password': 'abc'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define the command to call the update API
|
# Define the command to call the update API
|
||||||
|
Loading…
Reference in New Issue
Block a user