mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 23:55:16 +00:00
small tweaks to imagen callback
This commit is contained in:
1 parent
5d5b782760
commit
65580ec502
1 file changed
+18
-3
+18
-3
@@ -148,6 +148,7 @@ pub async fn update_gpt_image_job_status_handler(
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
match inference_job.status {
|
||||
JobStatusPlus::CompleteSuccess => {
|
||||
// Job has already been completed. Don't replay the request.
|
||||
@@ -162,6 +163,14 @@ pub async fn update_gpt_image_job_status_handler(
|
||||
_ => {} // Intentional fall through.
|
||||
}
|
||||
|
||||
let target_status = match request.job_status {
|
||||
UpdatedJobStatus::Started => JobStatusPlus::Started,
|
||||
UpdatedJobStatus::CompleteSuccess => JobStatusPlus::CompleteSuccess,
|
||||
UpdatedJobStatus::CompleteFailure => JobStatusPlus::CompleteFailure,
|
||||
UpdatedJobStatus::AttemptFailed => JobStatusPlus::AttemptFailed,
|
||||
UpdatedJobStatus::Dead => JobStatusPlus::Dead,
|
||||
};
|
||||
|
||||
if let Some(images) = &request.images {
|
||||
for image in images.iter() {
|
||||
let result = upload_and_save_image(
|
||||
@@ -180,13 +189,17 @@ pub async fn update_gpt_image_job_status_handler(
|
||||
}
|
||||
}
|
||||
|
||||
update_job_record(&request, &server_state, inference_job)
|
||||
info!("Updating job record for job: {:?}", request.job_token);
|
||||
|
||||
update_job_record(&request, &server_state, inference_job, target_status)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
error!("Error updating job: {:?}", err);
|
||||
UpdateGptImageJobStatusError::ServerError
|
||||
})?;
|
||||
|
||||
info!("Job record updated for job: {:?}", request.job_token);
|
||||
|
||||
Ok(Json(UpdateGptImageJobStatusSuccessResponse {
|
||||
success: true,
|
||||
}))
|
||||
@@ -254,13 +267,15 @@ async fn upload_and_save_image(
|
||||
async fn update_job_record(
|
||||
request: &Json<UpdateGptImageJobStatusRequest>,
|
||||
server_state: &Data<Arc<ServerState>>,
|
||||
inference_job: GenericInferenceJobStatus
|
||||
inference_job: GenericInferenceJobStatus,
|
||||
target_status: JobStatusPlus,
|
||||
) -> AnyhowResult<()> {
|
||||
|
||||
match inference_job.status {
|
||||
match target_status {
|
||||
JobStatusPlus::Pending => {}
|
||||
JobStatusPlus::Started => {}
|
||||
JobStatusPlus::CompleteSuccess => {
|
||||
info!("Matched job status complete_success");
|
||||
mark_generic_inference_job_successfully_done_by_token(
|
||||
&server_state.mysql_pool,
|
||||
&request.job_token,
|
||||
|
||||
Reference in new issue
Block a user