Skip to content

Commit 170cdcc

Browse files
authored
feat: Execution Details - HuggingFace - Show job ID and link in container execution info section (#1332)
* feat: Execution Details - HuggingFace - Show job ID and link in container execution info section * Defined the ExecutionLinkItem interface
1 parent 591625c commit 170cdcc

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

src/components/shared/ExecutionDetails/ExecutionDetails.tsx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChevronsUpDown } from "lucide-react";
1+
import { ChevronsUpDown, ExternalLink } from "lucide-react";
22

33
import type { GetContainerExecutionStateResponse } from "@/api/types.gen";
44
import { Button } from "@/components/ui/button";
@@ -50,6 +50,7 @@ export const ExecutionDetails = ({
5050
}
5151

5252
const podName = executionPodName(containerState);
53+
const executionJobLinks = getExecutionJobLinks(containerState);
5354

5455
return (
5556
<div className="flex flex-col px-3 py-2">
@@ -150,6 +151,29 @@ export const ExecutionDetails = ({
150151
</span>
151152
</div>
152153
)}
154+
{executionJobLinks && (
155+
<>
156+
{executionJobLinks.map((linkInfo) => (
157+
<div
158+
key={linkInfo.name}
159+
className="flex text-xs items-center gap-2"
160+
>
161+
<span className="font-medium text-foreground min-w-fit">
162+
{linkInfo.name}:
163+
</span>
164+
<a
165+
href={linkInfo.url}
166+
className="text-sky-500 hover:underline flex items-center gap-1"
167+
target="_blank"
168+
rel="noopener noreferrer"
169+
>
170+
{linkInfo.value}
171+
<ExternalLink className="size-3 flex-shrink-0" />
172+
</a>
173+
</div>
174+
))}
175+
</>
176+
)}
153177

154178
{!isLoadingContainerState &&
155179
!containerState &&
@@ -191,3 +215,38 @@ function executionPodName(
191215

192216
return null;
193217
}
218+
219+
interface ExecutionLinkItem {
220+
name: string;
221+
value: string;
222+
url?: string;
223+
}
224+
225+
function getExecutionJobLinks(
226+
containerState?: GetContainerExecutionStateResponse,
227+
): Array<ExecutionLinkItem> | null {
228+
if (!containerState || !("debug_info" in containerState)) {
229+
return null;
230+
}
231+
232+
const debugInfo = containerState.debug_info as Record<string, any>;
233+
234+
const result = Array<ExecutionLinkItem>();
235+
236+
const huggingfaceJob = debugInfo.huggingface_job as Record<string, any>;
237+
if (
238+
huggingfaceJob &&
239+
typeof huggingfaceJob === "object" &&
240+
typeof huggingfaceJob.id === "string" &&
241+
typeof huggingfaceJob.namespace === "string"
242+
) {
243+
const url = `https://huggingface.co/jobs/${huggingfaceJob.namespace}/${huggingfaceJob.id}`;
244+
result.push({
245+
name: "HuggingFace Job",
246+
value: huggingfaceJob.id,
247+
url: url,
248+
});
249+
}
250+
251+
return result;
252+
}

0 commit comments

Comments
 (0)