Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Step Parameters #705

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/NestedCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function RenderArray({ title, value }: { title: string; value: unknown[] }) {
const simpleValues: unknown[] = value.filter(
(val) => (!isArray(val) && !isObject(val)) || val === null
);
const nestedValues: unknown[] = value.filter((val) => isArray(val) || isObject);
const nestedValues: unknown[] = value.filter((val) => isArray(val) || isObject(val));

return (
<>
Expand Down
48 changes: 5 additions & 43 deletions src/components/steps/step-sheet/ConfigurationTab.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import { DockerImageCollapsible } from "@/app/runs/[id]/_Tabs/Configuration/DockerImageCollapsible";
import { Codesnippet } from "@/components/CodeSnippet";
import { CollapsibleCard } from "@/components/CollapsibleCard";
import { KeyValue } from "@/components/KeyValue";
import { usePipelineBuild } from "@/data/pipeline-builds/all-pipeline-builds-query";
import { usePipelineRun } from "@/data/pipeline-runs/pipeline-run-detail-query";
import { useStepDetail } from "@/data/steps/step-detail-query";
import { renderAnyToString } from "@/lib/strings";
import { AnyDict } from "@/types/common";
import { BuildItemMap } from "@/types/pipeline-builds";
import { Skeleton } from "@zenml-io/react-component-library";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger
} from "@zenml-io/react-component-library/components/client";
import { useParams } from "react-router-dom";
import { ErrorFallback } from "../../Error";
import { NestedCollapsible } from "../../NestedCollapsible";
Expand Down Expand Up @@ -78,7 +70,11 @@ export function StepConfigTab({ stepId }: Props) {

return (
<div className="space-y-5">
<KeyValueCard data={data.metadata?.config?.parameters as AnyDict} title="Parameters" />
<NestedCollapsible
isInitialOpen
data={data.metadata?.config?.parameters as AnyDict}
title="Parameters"
/>
{dataImage ? <DockerImageCollapsible data={dataImage} /> : null}
<CodeSnippetCard id={data.id} />
<NestedCollapsible
Expand All @@ -91,40 +87,6 @@ export function StepConfigTab({ stepId }: Props) {
);
}

export function KeyValueCard({ data, title }: { title: string; data: AnyDict }) {
const hasData = Object.keys(data).length > 0;

if (!hasData)
return (
<CollapsibleCard initialOpen title={title}>
<p className="text-theme-text-secondary">No data available</p>
</CollapsibleCard>
);
return (
<CollapsibleCard initialOpen title={title}>
<dl className="grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4">
{Object.entries(data).map(
([key, value]) =>
typeof value !== "object" && (
<KeyValue
key={key}
label={
<TooltipProvider>
<Tooltip>
<TooltipTrigger className="cursor-default truncate">{key}</TooltipTrigger>
<TooltipContent className="max-w-[480px]">{key}</TooltipContent>
</Tooltip>
</TooltipProvider>
}
value={<div>{renderAnyToString(value)}</div>}
/>
)
)}
</dl>
</CollapsibleCard>
);
}

function CodeSnippetCard({ id }: { id: string }) {
function returnConfigSchema(id: string) {
return `from zenml.client import Client
Expand Down