|
@@ -109,10 +109,14 @@ def _aigc_write_record(context: StepContext) -> dict[str, Any]:
|
|
|
publish_videos_from_discovery,
|
|
publish_videos_from_discovery,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ settings = get_infra_settings()
|
|
|
|
|
+ dry_run = not settings.pipeline_external_effects_enabled
|
|
|
payload = publish_videos_from_discovery(
|
|
payload = publish_videos_from_discovery(
|
|
|
biz_dt=context.biz_dt,
|
|
biz_dt=context.biz_dt,
|
|
|
- dry_run=True,
|
|
|
|
|
|
|
+ dry_run=dry_run,
|
|
|
)
|
|
)
|
|
|
|
|
+ publish_success = bool(payload.get("success", True))
|
|
|
|
|
+ effective_dry_run = bool(payload.get("dry_run", dry_run))
|
|
|
canonical = json.dumps(
|
|
canonical = json.dumps(
|
|
|
payload,
|
|
payload,
|
|
|
ensure_ascii=False,
|
|
ensure_ascii=False,
|
|
@@ -126,7 +130,7 @@ def _aigc_write_record(context: StepContext) -> dict[str, Any]:
|
|
|
payload_uri: str | None = None
|
|
payload_uri: str | None = None
|
|
|
stored_payload: dict[str, Any] | None = payload
|
|
stored_payload: dict[str, Any] | None = payload
|
|
|
if len(encoded) > _MAX_INLINE_EFFECT_BYTES:
|
|
if len(encoded) > _MAX_INLINE_EFFECT_BYTES:
|
|
|
- log_dir = Path(get_infra_settings().pipeline_log_dir)
|
|
|
|
|
|
|
+ log_dir = Path(settings.pipeline_log_dir)
|
|
|
if not log_dir.is_absolute():
|
|
if not log_dir.is_absolute():
|
|
|
log_dir = _REPO_ROOT / log_dir
|
|
log_dir = _REPO_ROOT / log_dir
|
|
|
effect_dir = log_dir / context.run_id / "effects"
|
|
effect_dir = log_dir / context.run_id / "effects"
|
|
@@ -142,7 +146,7 @@ def _aigc_write_record(context: StepContext) -> dict[str, Any]:
|
|
|
"payload_hash": payload_hash,
|
|
"payload_hash": payload_hash,
|
|
|
}
|
|
}
|
|
|
with get_session() as session:
|
|
with get_session() as session:
|
|
|
- record = PipelineOutboxRepository(session).record_dry_run(
|
|
|
|
|
|
|
+ record = PipelineOutboxRepository(session).record_effect(
|
|
|
run_id=context.run_id,
|
|
run_id=context.run_id,
|
|
|
step_run_id=context.step_run_id,
|
|
step_run_id=context.step_run_id,
|
|
|
effect_type="aigc_write_record",
|
|
effect_type="aigc_write_record",
|
|
@@ -150,18 +154,30 @@ def _aigc_write_record(context: StepContext) -> dict[str, Any]:
|
|
|
payload_hash=payload_hash,
|
|
payload_hash=payload_hash,
|
|
|
payload=stored_payload,
|
|
payload=stored_payload,
|
|
|
payload_uri=payload_uri,
|
|
payload_uri=payload_uri,
|
|
|
|
|
+ dry_run=effective_dry_run,
|
|
|
)
|
|
)
|
|
|
outbox_id = record.outbox_id
|
|
outbox_id = record.outbox_id
|
|
|
- return {
|
|
|
|
|
- "success": True,
|
|
|
|
|
- "dry_run_recorded": True,
|
|
|
|
|
- "external_request_made": False,
|
|
|
|
|
|
|
+
|
|
|
|
|
+ result: dict[str, Any] = {
|
|
|
|
|
+ "success": publish_success,
|
|
|
|
|
+ "effect_recorded": True,
|
|
|
|
|
+ "dry_run_recorded": effective_dry_run,
|
|
|
|
|
+ "external_request_made": not effective_dry_run,
|
|
|
"outbox_id": outbox_id,
|
|
"outbox_id": outbox_id,
|
|
|
"payload_hash": payload_hash,
|
|
"payload_hash": payload_hash,
|
|
|
"payload_uri": payload_uri,
|
|
"payload_uri": payload_uri,
|
|
|
"candidate_count": payload.get("candidate_count", 0),
|
|
"candidate_count": payload.get("candidate_count", 0),
|
|
|
"batch_count": payload.get("batch_count", 0),
|
|
"batch_count": payload.get("batch_count", 0),
|
|
|
|
|
+ "failed_batch_count": payload.get("failed_batch_count", 0),
|
|
|
|
|
+ "dry_run": effective_dry_run,
|
|
|
}
|
|
}
|
|
|
|
|
+ if not publish_success:
|
|
|
|
|
+ result["error"] = str(
|
|
|
|
|
+ payload.get("error")
|
|
|
|
|
+ or f"AIGC publish failed ({result['failed_batch_count']} batch(es))"
|
|
|
|
|
+ )
|
|
|
|
|
+ result["error_code"] = "aigc_publish_failed"
|
|
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
|
|
|
|
STEP_REGISTRY: dict[str, StepHandler] = {
|
|
STEP_REGISTRY: dict[str, StepHandler] = {
|