Merge branch 'develop'
All checks were successful
定时 AiDA python develop 分支构建部署 / scheduled_deploy (push) Successful in 15s
All checks were successful
定时 AiDA python develop 分支构建部署 / scheduled_deploy (push) Successful in 15s
# Conflicts: # .gitea/workflows/develop_build_scheduled.yaml # app/service/design_fast/design_generate.py
This commit is contained in:
@@ -2,7 +2,7 @@ name: 定时 AiDA python develop 分支构建部署
|
|||||||
on:
|
on:
|
||||||
# 使用 schedule 触发器,遵循标准的 Cron 格式 (分钟 小时-8 日期 月份 星期)
|
# 使用 schedule 触发器,遵循标准的 Cron 格式 (分钟 小时-8 日期 月份 星期)
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '32 9 * * *'
|
- cron: '30 9 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
scheduled_deploy:
|
scheduled_deploy:
|
||||||
|
|||||||
@@ -34,12 +34,14 @@ async def startup_event():
|
|||||||
scheduler.start()
|
scheduler.start()
|
||||||
logger.info("定时任务已启动")
|
logger.info("定时任务已启动")
|
||||||
|
|
||||||
|
|
||||||
def softmax(scores):
|
def softmax(scores):
|
||||||
max_score = max(scores)
|
max_score = max(scores)
|
||||||
exp_scores = [math.exp(s - max_score) for s in scores]
|
exp_scores = [math.exp(s - max_score) for s in scores]
|
||||||
sum_exp = sum(exp_scores)
|
sum_exp = sum(exp_scores)
|
||||||
return [s / sum_exp for s in exp_scores]
|
return [s / sum_exp for s in exp_scores]
|
||||||
|
|
||||||
|
|
||||||
# def get_random_recommendations(category: str, num: int) -> List[str]:
|
# def get_random_recommendations(category: str, num: int) -> List[str]:
|
||||||
# """根据预加载热度向量推荐(冷启动)"""
|
# """根据预加载热度向量推荐(冷启动)"""
|
||||||
# try:
|
# try:
|
||||||
@@ -92,6 +94,7 @@ async def get_recommendations(user_id: int, category: str, brand_id: int, brand_
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
logger.info(f"user_id:{user_id}-----category:{category}-----brand_id:{brand_id}-----brand_scale:{brand_scale}-----num_recommendations:{num_recommendations}")
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
cache_key = (user_id, category)
|
cache_key = (user_id, category)
|
||||||
# === 新增:用户存在性检查 ===
|
# === 新增:用户存在性检查 ===
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class DesignStreamModel(BaseModel):
|
|||||||
objects: list[dict]
|
objects: list[dict]
|
||||||
process_id: str
|
process_id: str
|
||||||
requestId: str
|
requestId: str
|
||||||
|
callback_url: str
|
||||||
|
|
||||||
|
|
||||||
class DesignProgressModel(BaseModel):
|
class DesignProgressModel(BaseModel):
|
||||||
|
|||||||
@@ -145,10 +145,11 @@ def design_generate(request_data):
|
|||||||
@RunTime
|
@RunTime
|
||||||
def design_generate_v2(request_data):
|
def design_generate_v2(request_data):
|
||||||
objects_data = request_data.dict()['objects']
|
objects_data = request_data.dict()['objects']
|
||||||
|
callback_url = request_data.callback_url
|
||||||
request_id = request_data.requestId
|
request_id = request_data.requestId
|
||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
def process_object(step, object):
|
def process_object(step, object, callback_url):
|
||||||
basic = object['basic']
|
basic = object['basic']
|
||||||
items_response = {
|
items_response = {
|
||||||
'layers': [],
|
'layers': [],
|
||||||
@@ -211,12 +212,8 @@ def design_generate_v2(request_data):
|
|||||||
})
|
})
|
||||||
items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image'])
|
items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image'])
|
||||||
# 发送结果给java端
|
# 发送结果给java端
|
||||||
url = JAVA_STREAM_API_URL
|
url = callback_url
|
||||||
# xu_pei_test_url = "https://137f6b5c3490.ngrok-free.app/api/third/party/receiveDesignResults"
|
|
||||||
# tianxaing_test_url = "https://d7436c137fb9.ngrok-free.app/api/third/party/receiveDesignResults"
|
|
||||||
logger.info(f"java 回调 -> {url}")
|
logger.info(f"java 回调 -> {url}")
|
||||||
# logger.info(f"xupei java 回调 -> {xu_pei_test_url}")
|
|
||||||
# logger.info(f"tianxiang java 回调 -> {tianxaing_test_url}")
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': "*/*",
|
'Accept': "*/*",
|
||||||
@@ -231,17 +228,8 @@ def design_generate_v2(request_data):
|
|||||||
# 打印结果
|
# 打印结果
|
||||||
logger.info(response.text)
|
logger.info(response.text)
|
||||||
|
|
||||||
# test_xp_response = post_request(xu_pei_test_url, json_data=items_response, headers=headers)
|
|
||||||
# test_response = post_request(tianxaing_test_url, json_data=items_response, headers=headers)
|
|
||||||
|
|
||||||
# if test_response:
|
|
||||||
# 打印结果
|
|
||||||
# logger.info(f"tianxiang test response : {test_response.text}")
|
|
||||||
# if test_xp_response:
|
|
||||||
# logger.info(f"xupei test response : {test_xp_response.text}")
|
|
||||||
|
|
||||||
for step, object in enumerate(objects_data):
|
for step, object in enumerate(objects_data):
|
||||||
t = threading.Thread(target=process_object, args=(step, object))
|
t = threading.Thread(target=process_object, args=(step, object, callback_url))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user