feat: snapshot product suite reference assets
This commit is contained in:
@@ -270,6 +270,9 @@ def _run_one_job(job_id, runtime, config, image_root, aspect_ratio, db_path, sho
|
||||
return {"job": updated, "status": "failed", "error": "项目或源图不存在"}
|
||||
try:
|
||||
image_studio.update_job_status(job.id, "running", path=db_path)
|
||||
reference_assets = ()
|
||||
if not job.task_id:
|
||||
reference_assets = _reference_assets_for_job(job, db_path)
|
||||
request_result = _submit_or_resume_job(
|
||||
job,
|
||||
source_asset,
|
||||
@@ -279,6 +282,7 @@ def _run_one_job(job_id, runtime, config, image_root, aspect_ratio, db_path, sho
|
||||
db_path,
|
||||
should_stop,
|
||||
on_event,
|
||||
reference_assets=reference_assets,
|
||||
)
|
||||
image_studio.update_job_status(job.id, "running", path=db_path)
|
||||
request_result = _poll_job(job.id, request_result["task_id"], runtime, request_result, db_path, should_stop, on_event)
|
||||
@@ -343,6 +347,20 @@ def _run_one_job(job_id, runtime, config, image_root, aspect_ratio, db_path, sho
|
||||
return {"job": updated, "status": status, "error": error}
|
||||
|
||||
|
||||
def _reference_assets_for_job(job, db_path):
|
||||
assets = []
|
||||
for asset_id in image_studio.job_reference_asset_ids(job):
|
||||
asset = image_studio.get_asset(asset_id, path=db_path)
|
||||
if asset is None:
|
||||
raise ImageStudioGenerationError("参考图资产不存在,无法继续生成")
|
||||
try:
|
||||
_source_path(asset)
|
||||
except ImageStudioGenerationError as exc:
|
||||
raise ImageStudioGenerationError("参考图尚未下载到本地,无法继续生成") from exc
|
||||
assets.append(asset)
|
||||
return assets
|
||||
|
||||
|
||||
def _submit_or_resume_job(
|
||||
job,
|
||||
source_asset,
|
||||
|
||||
Reference in New Issue
Block a user