任务分布式运行
This commit is contained in:
1 parent
677a836569
commit
d09e0c8c17
14 files changed
+462
-53
No files matched your search
+18
-10
@@ -2,10 +2,12 @@ import os, sys, time, shlex, subprocess, shutil, requests, cv2, numpy as np
|
||||
from PIL import Image
|
||||
import platform
|
||||
if platform.system() == 'Windows':
|
||||
sys.path.append('e:\\libs\\')
|
||||
#sys.path.append('e:\\libs\\')
|
||||
sys.path.append('libs')
|
||||
sys.path.append('logic')
|
||||
else:
|
||||
sys.path.append('/data/deploy/make3d/make2/libs/')
|
||||
import config, libs, libs_db
|
||||
import config, libs, libs_db,logic_main_service
|
||||
|
||||
def filter_dark_texture_image(pid):
|
||||
start_time = time.time()
|
||||
@@ -107,7 +109,7 @@ def cal_reconstruction_region(psid, pid):
|
||||
fix_region()
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 重建区域计算完成')
|
||||
|
||||
def step1(pid, experience=False, makeloop=True):
|
||||
def step1(pid, experience=False, makeloop=True,task_distributed_id=""):
|
||||
libs_db.start_task({"task_type": "make", "task_key": pid})
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 开始处理{pid}建模任务')
|
||||
@@ -158,15 +160,21 @@ def step1(pid, experience=False, makeloop=True):
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} step1图片预处理完成,共费时{libs.diff_time(start_time)}')
|
||||
|
||||
# TODO: 更新本地step1任务状态,加入step2任务队列
|
||||
if makeloop:
|
||||
os.system(f'python main_step2.py {pid}')
|
||||
if task_distributed_id == "":#不是分布式任务的时候就自动往下个步骤走,是分布式任务的时候就就执行当前任务
|
||||
if makeloop:
|
||||
os.system(f'python main_step2.py {pid}')
|
||||
else:
|
||||
os.system(f'python main_step2.py {pid}')
|
||||
# if os.path.exists(os.path.join(config.sharedir, pid)):
|
||||
# shutil.rmtree(os.path.join(config.sharedir, pid), ignore_errors=True)
|
||||
# shutil.move(os.path.join(config.workdir, pid), config.sharedir)
|
||||
|
||||
# print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} step1任务完成,移动到共享目录')
|
||||
else:
|
||||
os.system(f'python main_step2.py {pid}')
|
||||
# if os.path.exists(os.path.join(config.sharedir, pid)):
|
||||
# shutil.rmtree(os.path.join(config.sharedir, pid), ignore_errors=True)
|
||||
# shutil.move(os.path.join(config.workdir, pid), config.sharedir)
|
||||
#分布式服务执行完后,需要更新任务状态,更新字表的finished_at字段
|
||||
logic_main_service.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
|
||||
return
|
||||
|
||||
# print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} step1任务完成,移动到共享目录')
|
||||
|
||||
def main(pid, experience=False, makeloop=True):
|
||||
if pid == '0':
|
||||
|
||||
Reference in new issue
Block a user