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

add pipeline input parameters #3293

Merged
merged 1 commit into from
Oct 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class RunDetails extends PipelinesTopology {
return cy.findByTestId('pipeline-run-tab-graph');
}

findInputParameterTab() {
return cy.findByTestId('pipeline-run-tab-parameters');
}

findDetailsTab() {
return cy.findByTestId('pipeline-run-tab-details');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,21 @@ describe('Pipeline topology', () => {
});
});

it('Test pipeline recurring run tab parameters', () => {
initIntercepts();

pipelineRecurringRunDetails.visit(
projectId,
mockVersion.pipeline_id,
mockVersion.pipeline_version_id,
mockRecurringRun.recurring_run_id,
);
pipelineRecurringRunDetails.findDetailsTab().click();
pipelineRecurringRunDetails.findInputParameterTab().click();
pipelineRecurringRunDetails.findDetailItem('min_max_scaler').findValue().contains('False');
pipelineRecurringRunDetails.findDetailItem('neighbors').findValue().contains('0');
});

it('Test pipeline recurring run tab details', () => {
initIntercepts();

Expand Down Expand Up @@ -494,6 +509,19 @@ describe('Pipeline topology', () => {
pipelineRunDetails.findDetailItem('Duration').findValue().contains('0:50');
});

it('Test pipeline triggered run tab parameters', () => {
initIntercepts();
pipelineRunDetails.visit(
projectId,
mockVersion.pipeline_id,
mockVersion.pipeline_version_id,
mockRun.run_id,
);
pipelineRunDetails.findInputParameterTab().click();
pipelineRunDetails.findDetailItem('min_max_scaler').findValue().contains('False');
pipelineRunDetails.findDetailItem('neighbors').findValue().contains('1');
});

it('Test pipeline triggered run YAML output', () => {
initIntercepts();
pipelineRunDetails.visit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import {
} from '~/concepts/pipelines/kfTypes';
import { isPipelineRecurringRun } from '~/concepts/pipelines/content/utils';
import PipelineRunTabDetails from './PipelineRunTabDetails';
import PipelineRunTabParameters from './PipelineRunTabParameters';

enum DetailsTabKey {
Graph = 'graph',
Details = 'details',
InputParameter = 'input-parameter',
Spec = 'spec',
}

Expand Down Expand Up @@ -77,6 +79,16 @@ export const PipelineRunDetailsTabs: React.FC<PipelineRunDetailsTabsProps> = ({
<PipelineRunTabDetails workflowName={run?.display_name} run={run} />
</TabContentBody>
</Tab>
<Tab
eventKey={DetailsTabKey.InputParameter}
title={<TabTitleText>Input parameters</TabTitleText>}
aria-label="Input parameter tab"
data-testid="pipeline-run-tab-parameters"
>
<TabContentBody data-testid="pipeline-parameter-tab" hasPadding>
<PipelineRunTabParameters run={run} pipelineSpec={pipelineSpec} />
</TabContentBody>
</Tab>

{!isRecurringRun && (
<Tab
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import * as React from 'react';
import {
Spinner,
EmptyStateVariant,
EmptyState,
EmptyStateBody,
EmptyStateHeader,
} from '@patternfly/react-core';
import {
InputDefinitionParameterType,
PipelineRecurringRunKFv2,
PipelineRunKFv2,
PipelineSpecVariable,
} from '~/concepts/pipelines/kfTypes';
import {
DetailItem,
renderDetailItems,
} from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/utils';
import { ExecutionDetailsPropertiesValueCode } from '~/pages/pipelines/global/experiments/executions/details/ExecutionDetailsPropertiesValue';

type PipelineRunTabParametersProps = {
run: PipelineRecurringRunKFv2 | PipelineRunKFv2 | null;
pipelineSpec: PipelineSpecVariable | undefined;
};

const PipelineRunTabParameters: React.FC<PipelineRunTabParametersProps> = ({
run,
pipelineSpec,
}) => {
if (!run) {
return (

Check warning on line 31 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L31

Added line #L31 was not covered by tests
<EmptyState variant={EmptyStateVariant.lg} data-id="loading-empty-state">
<Spinner size="xl" />
<EmptyStateHeader titleText="Loading" headingLevel="h4" />
</EmptyState>
);
}

const specParameters =
pipelineSpec?.root?.inputDefinitions?.parameters ||
pipelineSpec?.pipeline_spec?.root.inputDefinitions?.parameters;

const parameters = run.runtime_config?.parameters
? Object.entries(run.runtime_config.parameters)
: [];

if (parameters.length === 0) {
return (
<EmptyState variant={EmptyStateVariant.lg} data-id="parameters-empty-state">
<EmptyStateHeader titleText="No parameters" headingLevel="h2" />
<EmptyStateBody>This pipeline run does not have any parameters defined.</EmptyStateBody>
</EmptyState>
);
}

const details: DetailItem[] = parameters.map(([key, initialValue]) => {
let value: React.ReactNode;
const paramType = specParameters?.[key].parameterType;
switch (paramType) {
case InputDefinitionParameterType.DOUBLE:
value = Number.isInteger(Number(initialValue))
? Number(initialValue).toFixed(1)
: Number(initialValue);
break;

Check warning on line 64 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L60-L64

Added lines #L60 - L64 were not covered by tests
case InputDefinitionParameterType.INTEGER:
value = Number(initialValue);
break;
case InputDefinitionParameterType.BOOLEAN:
value = initialValue ? 'True' : 'False';
break;
case InputDefinitionParameterType.STRING:
value = String(initialValue);
break;
case InputDefinitionParameterType.LIST:
value = (

Check warning on line 75 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L74-L75

Added lines #L74 - L75 were not covered by tests
<ExecutionDetailsPropertiesValueCode code={JSON.stringify(initialValue, null, 2)} />
);
break;
case InputDefinitionParameterType.STRUCT:
value = (

Check warning on line 80 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L78-L80

Added lines #L78 - L80 were not covered by tests
<ExecutionDetailsPropertiesValueCode code={JSON.stringify(initialValue, null, 2)} />
);
break;

Check warning on line 83 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L83

Added line #L83 was not covered by tests
default:
value = JSON.stringify(initialValue);
}
return {
key,
value,
};
});

return <>{renderDetailItems(details)}</>;
};

export default PipelineRunTabParameters;
Loading