Skip to content

Commit

Permalink
feat: upload to blob based on the user selected namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
EiffelFly committed Nov 25, 2024
1 parent 5b3260e commit c416bc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ export const PipelinePlayground = ({

setIsPipelineRunning(true);

const targetNamespace = userNamespaces.data.find(
(namespace) => namespace.id === navigationNamespaceAnchor,
);

if (!targetNamespace) {
toastInstillError({
title: "Something went wrong, please refresh the page and try again",
toast,
error: new Error("Failed to find the target namespace"),
});
return;
}

// Backend need to have the encoded JSON input. So we need to double check
// the metadata whether this field is a semi-structured object and parse it
const semiStructuredObjectKeys: string[] = [];
Expand Down Expand Up @@ -276,7 +289,7 @@ export const PipelinePlayground = ({
continue;
}
const downloadURL = await uploadAndGetDownloadNamespaceObjectURL({
namespaceId: routeInfo.data.namespaceId,
namespaceId: targetNamespace.id,
accessToken,
object: targetValue,
});
Expand Down Expand Up @@ -318,10 +331,6 @@ export const PipelinePlayground = ({
);
}

const targetNamespace = userNamespaces.data.find(
(namespace) => namespace.id === navigationNamespaceAnchor,
);

const data = await triggerPipeline.mutateAsync({
namespaceId: routeInfo.data.namespaceId,
pipelineId: routeInfo.data.resourceId,
Expand Down
11 changes: 6 additions & 5 deletions packages/toolkit/src/view/recipe-editor/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ export const Input = ({
}
}

// We use the current route namespace as the requester namespace
// This only happens when the user is on the recipe editor page
const tartgetNamespace = userNamespaces.data.find(
(ns) => ns.id === routeInfo.data.namespaceId,
);

// The data comes from the form is either File or URL for these file related fields
// like image, video, audio, file
for (const key of uploadedToArtifactKeys) {
Expand Down Expand Up @@ -265,11 +271,6 @@ export const Input = ({
),
);

// We use the current route namespace as the requester namespace
const tartgetNamespace = userNamespaces.data.find(
(ns) => ns.id === routeInfo.data.namespaceId,
);

const downloadedFromArtifactKeys: string[] = [];

if (outputSchema && outputSchema.properties) {
Expand Down

0 comments on commit c416bc7

Please sign in to comment.