feat: add hash log
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import importlib.util
|
||||
import numpy as np
|
||||
import os
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
|
||||
@@ -19,6 +21,24 @@ def load_user_function(file_path, function_name):
|
||||
return getattr(user_code, function_name)
|
||||
|
||||
|
||||
def get_commit_hash_url():
|
||||
"""
|
||||
获取最新的提交哈希值
|
||||
"""
|
||||
try:
|
||||
commit_hash = (
|
||||
subprocess.check_output(["git", "rev-parse", "HEAD"])
|
||||
.strip()
|
||||
.decode("utf-8")
|
||||
)
|
||||
path = os.getcwd().replace("/workspace/", "")
|
||||
url = f"https://git.intcplab.cn/{path}/commit/{commit_hash}"
|
||||
return url
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def evaluate_knn(
|
||||
user_func, train_data, train_labels, test_data, test_labels, log_details
|
||||
):
|
||||
@@ -101,6 +121,7 @@ def upload_score(name, id, score_data):
|
||||
),
|
||||
"details": score_data["details"],
|
||||
"project": PROJECT_NAME,
|
||||
"hash": get_commit_hash_url(),
|
||||
},
|
||||
)
|
||||
if response.status_code == 200:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import importlib.util
|
||||
import numpy as np
|
||||
import os
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
|
||||
@@ -19,6 +20,24 @@ def load_user_function(file_path, function_name):
|
||||
return getattr(user_code, function_name)
|
||||
|
||||
|
||||
def get_commit_hash_url():
|
||||
"""
|
||||
获取最新的提交哈希值
|
||||
"""
|
||||
try:
|
||||
commit_hash = (
|
||||
subprocess.check_output(["git", "rev-parse", "HEAD"])
|
||||
.strip()
|
||||
.decode("utf-8")
|
||||
)
|
||||
path = os.getcwd().replace("/workspace/", "")
|
||||
url = f"https://git.intcplab.cn/{path}/commit/{commit_hash}"
|
||||
return url
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def evaluate_knn(
|
||||
user_func, train_data, train_labels, test_data, test_labels, log_details
|
||||
):
|
||||
@@ -101,6 +120,7 @@ def upload_score(name, id, score_data):
|
||||
),
|
||||
"details": score_data["details"],
|
||||
"project": PROJECT_NAME,
|
||||
"hash": get_commit_hash_url(),
|
||||
},
|
||||
)
|
||||
if response.status_code == 200:
|
||||
|
||||
Reference in New Issue
Block a user