Skip to content

Commit

Permalink
fix: fix multipart trigger data_mapping_indices empty
Browse files Browse the repository at this point in the history
  • Loading branch information
pinglin committed Sep 8, 2022
1 parent 59f0fb8 commit d3160b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
Binary file modified integration-test/data/dummy-det-model.zip
Binary file not shown.
27 changes: 18 additions & 9 deletions integration-test/rest-trigger-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function CheckTriggerAsyncSingleImageSingleModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageURL.inputs.length,
});

var payloadImageBase64 = {
Expand All @@ -59,16 +60,18 @@ export function CheckTriggerAsyncSingleImageSingleModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageBase64.inputs.length,
});

const fd = new FormData();
fd.append("file", {data: http.file(constant.dogImg), filename: "dog"});
fd.append("file", { data: http.file(constant.dogImg), filename: "dog" });
check(http.request("POST", `${pipelineHost}/v1alpha/pipelines/${reqBody.id}:trigger-multipart`, fd.body(), {
headers: {
"Content-Type": `multipart/form-data; boundary=${fd.boundary}`,
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === fd.parts.length,
});

});
Expand Down Expand Up @@ -122,6 +125,7 @@ export function CheckTriggerAsyncMultiImageSingleModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageURL.inputs.length,
});

var payloadImageBase64 = {
Expand All @@ -144,19 +148,21 @@ export function CheckTriggerAsyncMultiImageSingleModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageBase64.inputs.length,
});

const fd = new FormData();
fd.append("file", {data: http.file(constant.dogImg), filename: "dog"});
fd.append("file", {data: http.file(constant.catImg), filename: "cat"});
fd.append("file", {data: http.file(constant.bearImg), filename: "bear"});
fd.append("file", {data: http.file(constant.dogRGBAImg), filename: "dogRGBA"});
fd.append("file", { data: http.file(constant.dogImg), filename: "dog" });
fd.append("file", { data: http.file(constant.catImg), filename: "cat" });
fd.append("file", { data: http.file(constant.bearImg), filename: "bear" });
fd.append("file", { data: http.file(constant.dogRGBAImg), filename: "dogRGBA" });
check(http.request("POST", `${pipelineHost}/v1alpha/pipelines/${reqBody.id}:trigger-multipart`, fd.body(), {
headers: {
"Content-Type": `multipart/form-data; boundary=${fd.boundary}`,
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === fd.parts.length,
});

});
Expand Down Expand Up @@ -210,6 +216,7 @@ export function CheckTriggerAsyncMultiImageMultiModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (url) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageURL.inputs.length,
});

var payloadImageBase64 = {
Expand All @@ -232,19 +239,21 @@ export function CheckTriggerAsyncMultiImageMultiModelInst() {
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (base64) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === payloadImageBase64.inputs.length,
});

const fd = new FormData();
fd.append("file", {data: http.file(constant.dogImg), filename: "dog"});
fd.append("file", {data: http.file(constant.catImg), filename: "cat"});
fd.append("file", {data: http.file(constant.bearImg), filename: "bear"});
fd.append("file", {data: http.file(constant.dogRGBAImg), filename: "dogRGBA"});
fd.append("file", { data: http.file(constant.dogImg), filename: "dog" });
fd.append("file", { data: http.file(constant.catImg), filename: "cat" });
fd.append("file", { data: http.file(constant.bearImg), filename: "bear" });
fd.append("file", { data: http.file(constant.dogRGBAImg), filename: "dogRGBA" });
check(http.request("POST", `${pipelineHost}/v1alpha/pipelines/${reqBody.id}:trigger-multipart`, fd.body(), {
headers: {
"Content-Type": `multipart/form-data; boundary=${fd.boundary}`,
},
}), {
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response status is 200`]: (r) => r.status === 200,
[`POST /v1alpha/pipelines/${reqBody.id}:trigger (multipart) response data_mapping_indices.length`]: (r) => r.json().data_mapping_indices.length === fd.parts.length,
});

});
Expand Down
5 changes: 4 additions & 1 deletion pkg/handler/handlercustom.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func HandleTriggerPipelineBinaryFileUpload(w http.ResponseWriter, req *http.Requ

w.Header().Add("Content-Type", "application/json")
w.WriteHeader(200)
ret, _ := protojson.MarshalOptions{EmitUnpopulated: true, UseProtoNames: true}.Marshal(obj)
ret, _ := protojson.MarshalOptions{
EmitUnpopulated: true,
UseProtoNames: true,
}.Marshal(obj)
_, _ = w.Write(ret)

} else {
Expand Down
5 changes: 4 additions & 1 deletion pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,10 @@ func (s *service) TriggerPipelineBinaryFileUpload(fileBuf bytes.Buffer, fileName
return nil, status.Errorf(codes.Internal, "[connector-backend] Error %s at %dth model instance %s: %v", "WriteDestinationConnector", idx, modelInstRecName, err.Error())
}
}
return &pipelinePB.TriggerPipelineBinaryFileUploadResponse{}, nil
return &pipelinePB.TriggerPipelineBinaryFileUploadResponse{
DataMappingIndices: dataMappingIndices,
ModelInstanceOutputs: nil,
}, nil

}

Expand Down

0 comments on commit d3160b4

Please sign in to comment.