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

Rename all Clone code identifier to Duplicate #3334

Merged
merged 1 commit into from
Oct 15, 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 @@ -7,8 +7,8 @@ import type {
} from '~/concepts/pipelines/kfTypes';
import { CreateRunPage } from '~/__tests__/cypress/cypress/pages/pipelines/createRunPage';

class CloneRunPage extends CreateRunPage {
protected testId = 'clone-run-page';
class DuplicateRunPage extends CreateRunPage {
protected testId = 'duplicate-run-page';

constructor(type: 'run' | 'schedule') {
super(type);
Expand Down Expand Up @@ -67,5 +67,5 @@ class CloneRunPage extends CreateRunPage {
}
}

export const cloneRunPage = new CloneRunPage('run');
export const cloneSchedulePage = new CloneRunPage('schedule');
export const duplicateRunPage = new DuplicateRunPage('run');
export const duplicateSchedulePage = new DuplicateRunPage('schedule');
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from './pipelineImportModal';
export * from './pipelineVersionImportModal';
export * from './pipelineRunTable';
export * from './createRunPage';
export * from './cloneRunPage';
export * from './duplicateRunPage';
export * from './pipelineFilterBar';
export * from './restoreModal';
export * from './archiveModal';
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
} from '~/__mocks__';
import {
createRunPage,
cloneRunPage,
duplicateRunPage,
pipelineRecurringRunTable,
pipelineRunsGlobal,
activeRunsTable,
createSchedulePage,
cloneSchedulePage,
duplicateSchedulePage,
} from '~/__tests__/cypress/cypress/pages/pipelines';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
import { getCorePipelineSpec } from '~/concepts/pipelines/getCorePipelineSpec';
Expand Down Expand Up @@ -221,44 +221,48 @@ describe('Pipeline create runs', () => {
});

// Mock experiments, pipelines & versions for form select dropdowns
cloneRunPage.mockGetExperiments(projectName, mockExperiments);
cloneRunPage.mockGetPipelines(projectName, [mockPipeline]);
cloneRunPage.mockGetPipelineVersions(
duplicateRunPage.mockGetExperiments(projectName, mockExperiments);
duplicateRunPage.mockGetPipelines(projectName, [mockPipeline]);
duplicateRunPage.mockGetPipelineVersions(
projectName,
[mockPipelineVersion],
mockPipelineVersion.pipeline_id,
);
cloneRunPage.mockGetRun(projectName, mockRun);
cloneRunPage.mockGetPipelineVersion(projectName, mockPipelineVersion);
cloneRunPage.mockGetPipeline(projectName, mockPipeline);
cloneRunPage.mockGetExperiment(projectName, mockExperiment);
duplicateRunPage.mockGetRun(projectName, mockRun);
duplicateRunPage.mockGetPipelineVersion(projectName, mockPipelineVersion);
duplicateRunPage.mockGetPipeline(projectName, mockPipeline);
duplicateRunPage.mockGetExperiment(projectName, mockExperiment);

// Mock runs list with newly cloned run
// Mock runs list with newly duplicated run
activeRunsTable.mockGetActiveRuns([...initialMockRuns, mockDuplicateRun], projectName);

// Navigate to clone run page for a given active run
// Navigate to duplicate run page for a given active run
cy.visitWithLogin(`/experiments/${projectName}/experiment-1/runs`);
pipelineRunsGlobal.findActiveRunsTab().click();
activeRunsTable.getRowByName(mockRun.display_name).findKebabAction('Duplicate').click();
verifyRelativeURL(`/experiments/${projectName}/experiment-1/runs/clone/${mockRun.run_id}`);
verifyRelativeURL(
`/experiments/${projectName}/experiment-1/runs/duplicate/${mockRun.run_id}`,
);

// Verify pre-populated values & submit
cloneRunPage.experimentSelect
duplicateRunPage.experimentSelect
.findToggleButton()
.should('have.text', mockExperiment.display_name);
cloneRunPage.pipelineSelect.findToggleButton().should('have.text', mockPipeline.display_name);
cloneRunPage.pipelineVersionSelect
duplicateRunPage.pipelineSelect
.findToggleButton()
.should('have.text', mockPipeline.display_name);
duplicateRunPage.pipelineVersionSelect
.findToggleButton()
.should('have.text', mockPipelineVersion.display_name);
const paramsSection = cloneRunPage.getParamsSection();
const paramsSection = duplicateRunPage.getParamsSection();
paramsSection.findParamById('radio-min_max_scaler-false').should('be.checked');
paramsSection.findParamById('neighbors').find('input').should('have.value', '1');
paramsSection.findParamById('standard_scaler').should('have.value', 'false');

cloneRunPage
duplicateRunPage
.mockCreateRun(projectName, mockPipelineVersion, mockDuplicateRun)
.as('duplicateRun');
cloneRunPage.submit();
duplicateRunPage.submit();

cy.wait('@duplicateRun').then((interception) => {
expect(interception.request.body).to.eql({
Expand All @@ -275,7 +279,7 @@ describe('Pipeline create runs', () => {
});
});

// Should redirect to the details of the newly cloned active run
// Should redirect to the details of the newly duplicated active run
verifyRelativeURL(`/experiments/${projectName}/experiment-1/runs/${mockDuplicateRun.run_id}`);
});

Expand Down Expand Up @@ -673,47 +677,47 @@ describe('Pipeline create runs', () => {
});

// Mock experiments, pipelines & versions for form select dropdowns
cloneSchedulePage.mockGetExperiments(projectName, mockExperiments);
cloneSchedulePage.mockGetPipelines(projectName, [mockPipeline]);
cloneSchedulePage.mockGetPipelineVersions(
duplicateSchedulePage.mockGetExperiments(projectName, mockExperiments);
duplicateSchedulePage.mockGetPipelines(projectName, [mockPipeline]);
duplicateSchedulePage.mockGetPipelineVersions(
projectName,
[mockPipelineVersion],
mockPipelineVersion.pipeline_id,
);
cloneSchedulePage.mockGetRecurringRun(projectName, mockRecurringRun);
cloneSchedulePage.mockGetPipelineVersion(projectName, mockPipelineVersion);
cloneSchedulePage.mockGetPipeline(projectName, mockPipeline);
cloneSchedulePage.mockGetExperiment(projectName, mockExperiment);
duplicateSchedulePage.mockGetRecurringRun(projectName, mockRecurringRun);
duplicateSchedulePage.mockGetPipelineVersion(projectName, mockPipelineVersion);
duplicateSchedulePage.mockGetPipeline(projectName, mockPipeline);
duplicateSchedulePage.mockGetExperiment(projectName, mockExperiment);

// Navigate to clone run page for a given schedule
// Navigate to duplicate run page for a given schedule
cy.visitWithLogin(`/experiments/${projectName}/experiment-1/runs`);
pipelineRunsGlobal.findSchedulesTab().click();
pipelineRecurringRunTable
.getRowByName(mockRecurringRun.display_name)
.findKebabAction('Duplicate')
.click();
verifyRelativeURL(
`/experiments/${projectName}/experiment-1/schedules/clone/${mockRecurringRun.recurring_run_id}`,
`/experiments/${projectName}/experiment-1/schedules/duplicate/${mockRecurringRun.recurring_run_id}`,
);

// Verify pre-populated values & submit
cloneSchedulePage.experimentSelect
duplicateSchedulePage.experimentSelect
.findToggleButton()
.should('have.text', mockExperiment.display_name);
cloneSchedulePage.pipelineSelect
duplicateSchedulePage.pipelineSelect
.findToggleButton()
.should('have.text', mockPipeline.display_name);
cloneSchedulePage.pipelineVersionSelect
duplicateSchedulePage.pipelineVersionSelect
.findToggleButton()
.should('have.text', mockPipelineVersion.display_name);
const paramsSection = cloneSchedulePage.getParamsSection();
const paramsSection = duplicateSchedulePage.getParamsSection();
paramsSection.findParamById('radio-min_max_scaler-false').should('be.checked');
paramsSection.findParamById('neighbors').find('input').should('have.value', '0');
paramsSection.findParamById('standard_scaler').should('have.value', 'yes');
cloneSchedulePage
duplicateSchedulePage
.mockCreateRecurringRun(projectName, mockPipelineVersion, mockDuplicateRecurringRun)
.as('duplicateSchedule');
cloneSchedulePage.submit();
duplicateSchedulePage.submit();

cy.wait('@duplicateSchedule').then((interception) => {
expect(interception.request.body).to.eql({
Expand Down Expand Up @@ -751,31 +755,31 @@ describe('Pipeline create runs', () => {
const mockExperiment = { ...mockExperiments[0], storage_state: StorageStateKF.ARCHIVED };

// Mock experiments, pipelines & versions for form select dropdowns
cloneSchedulePage.mockGetExperiments(projectName, mockExperiments);
cloneSchedulePage.mockGetPipelines(projectName, [mockPipeline]);
cloneSchedulePage.mockGetPipelineVersions(
duplicateSchedulePage.mockGetExperiments(projectName, mockExperiments);
duplicateSchedulePage.mockGetPipelines(projectName, [mockPipeline]);
duplicateSchedulePage.mockGetPipelineVersions(
projectName,
[mockPipelineVersion],
mockPipelineVersion.pipeline_id,
);
cloneSchedulePage.mockGetRecurringRun(projectName, mockRecurringRun);
cloneSchedulePage.mockGetPipelineVersion(projectName, mockPipelineVersion);
cloneSchedulePage.mockGetPipeline(projectName, mockPipeline);
cloneSchedulePage.mockGetExperiment(projectName, mockExperiment);
duplicateSchedulePage.mockGetRecurringRun(projectName, mockRecurringRun);
duplicateSchedulePage.mockGetPipelineVersion(projectName, mockPipelineVersion);
duplicateSchedulePage.mockGetPipeline(projectName, mockPipeline);
duplicateSchedulePage.mockGetExperiment(projectName, mockExperiment);

// Navigate to clone run page for a given schedule
// Navigate to duplicate run page for a given schedule
cy.visitWithLogin(`/experiments/${projectName}/experiment-1/runs`);
pipelineRunsGlobal.findSchedulesTab().click();
pipelineRecurringRunTable
.getRowByName(mockRecurringRun.display_name)
.findKebabAction('Duplicate')
.click();
verifyRelativeURL(
`/experiments/${projectName}/experiment-1/schedules/clone/${mockRecurringRun.recurring_run_id}`,
`/experiments/${projectName}/experiment-1/schedules/duplicate/${mockRecurringRun.recurring_run_id}`,
);

// Verify pre-populated values & submit
cloneSchedulePage.experimentSelect
duplicateSchedulePage.experimentSelect
.findToggleButton()
.should('have.text', 'Select an experiment');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
bulkRestoreRunModal,
archiveRunModal,
bulkArchiveRunModal,
cloneRunPage,
cloneSchedulePage,
duplicateRunPage,
duplicateSchedulePage,
} from '~/__tests__/cypress/cypress/pages/pipelines';
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url';
import { be } from '~/__tests__/cypress/cypress/utils/should';
Expand Down Expand Up @@ -330,9 +330,9 @@ describe('Pipeline runs', () => {
);
});

it('navigate to clone run page', () => {
cloneRunPage.mockGetExperiments(projectName, mockExperiments);
cloneRunPage.mockGetExperiment(projectName, mockExperiments[0]);
it('navigate to duplicate run page', () => {
duplicateRunPage.mockGetExperiments(projectName, mockExperiments);
duplicateRunPage.mockGetExperiment(projectName, mockExperiments[0]);
cy.visitWithLogin(`/experiments/${projectName}/test-experiment-1/runs`);

activeRunsTable
Expand All @@ -341,7 +341,7 @@ describe('Pipeline runs', () => {
.click();

verifyRelativeURL(
`/experiments/${projectName}/test-experiment-1/runs/clone/${mockActiveRuns[0].run_id}`,
`/experiments/${projectName}/test-experiment-1/runs/duplicate/${mockActiveRuns[0].run_id}`,
);
});

Expand Down Expand Up @@ -1006,9 +1006,9 @@ describe('Pipeline runs', () => {
);
});

it('navigate to clone scheduled run page', () => {
cloneSchedulePage.mockGetExperiments(projectName, mockExperiments);
cloneSchedulePage.mockGetExperiment(projectName, mockExperiments[0]);
it('navigate to duplicate scheduled run page', () => {
duplicateSchedulePage.mockGetExperiments(projectName, mockExperiments);
duplicateSchedulePage.mockGetExperiment(projectName, mockExperiments[0]);
cy.visitWithLogin(`/experiments/${projectName}/test-experiment-1/runs`);

pipelineRunsGlobal.findSchedulesTab().click();
Expand All @@ -1018,7 +1018,7 @@ describe('Pipeline runs', () => {
.click();

verifyRelativeURL(
`/experiments/${projectName}/test-experiment-1/schedules/clone/${mockRecurringRuns[0].recurring_run_id}`,
`/experiments/${projectName}/test-experiment-1/schedules/duplicate/${mockRecurringRuns[0].recurring_run_id}`,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ describe('Pipeline topology', () => {
);
pipelineRunDetails.selectActionDropdownItem('Duplicate');
verifyRelativeURL(
`/pipelines/${projectId}/${mockVersion.pipeline_id}/${mockVersion.pipeline_version_id}/runs/clone/${mockRun.run_id}`,
`/pipelines/${projectId}/${mockVersion.pipeline_id}/${mockVersion.pipeline_version_id}/runs/duplicate/${mockRun.run_id}`,
);
});

Expand All @@ -341,7 +341,7 @@ describe('Pipeline topology', () => {
);
pipelineRecurringRunDetails.selectActionDropdownItem('Duplicate');
verifyRelativeURL(
`/pipelines/${projectId}/${mockVersion.pipeline_id}/${mockVersion.pipeline_version_id}/schedules/clone/${mockRecurringRun.recurring_run_id}`,
`/pipelines/${projectId}/${mockVersion.pipeline_id}/${mockVersion.pipeline_version_id}/schedules/duplicate/${mockRecurringRun.recurring_run_id}`,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { ExperimentKFv2, PipelineKFv2, PipelineVersionKFv2 } from '~/concepts/pi
import usePipelineRecurringRunById from '~/concepts/pipelines/apiHooks/usePipelineRecurringRunById';
import { RunTypeOption } from './types';

type CloneRecurringRunPageProps = {
type DuplicateRecurringRunPageProps = {
detailsRedirect: (recurringRunId: string) => string;
contextExperiment?: ExperimentKFv2 | null;
contextPipeline?: PipelineKFv2 | null;
contextPipelineVersion?: PipelineVersionKFv2 | null;
};

const CloneRecurringRunPage: React.FC<PathProps & CloneRecurringRunPageProps> = ({
const DuplicateRecurringRunPage: React.FC<PathProps & DuplicateRecurringRunPageProps> = ({
breadcrumbPath,
contextPath,
detailsRedirect,
Expand Down Expand Up @@ -49,14 +49,14 @@ const CloneRecurringRunPage: React.FC<PathProps & CloneRecurringRunPageProps> =
empty={false}
>
<RunPage
cloneRun={recurringRun}
duplicateRun={recurringRun}
contextPath={contextPath}
runType={RunTypeOption.SCHEDULED}
testId="clone-run-page"
testId="duplicate-run-page"
{...props}
/>
</ApplicationsPage>
);
};

export default CloneRecurringRunPage;
export default DuplicateRecurringRunPage;
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { ExperimentKFv2, PipelineKFv2, PipelineVersionKFv2 } from '~/concepts/pi
import usePipelineRunById from '~/concepts/pipelines/apiHooks/usePipelineRunById';
import { RunTypeOption } from './types';

type CloneRunPageProps = {
type DuplicateRunPageProps = {
detailsRedirect: (runId: string) => string;
contextExperiment?: ExperimentKFv2 | null;
contextPipeline?: PipelineKFv2 | null;
contextPipelineVersion?: PipelineVersionKFv2 | null;
};

const CloneRunPage: React.FC<PathProps & CloneRunPageProps> = ({
const DuplicateRunPage: React.FC<PathProps & DuplicateRunPageProps> = ({
breadcrumbPath,
contextPath,
detailsRedirect,
Expand Down Expand Up @@ -49,14 +49,14 @@ const CloneRunPage: React.FC<PathProps & CloneRunPageProps> = ({
empty={false}
>
<RunPage
cloneRun={run}
duplicateRun={run}
contextPath={contextPath}
runType={RunTypeOption.ONE_TRIGGER}
testId="clone-run-page"
testId="duplicate-run-page"
{...props}
/>
</ApplicationsPage>
);
};

export default CloneRunPage;
export default DuplicateRunPage;
6 changes: 3 additions & 3 deletions frontend/src/concepts/pipelines/content/createRun/RunForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import { getInputDefinitionParams } from './utils';
type RunFormProps = {
data: RunFormData;
onValueChange: (key: keyof RunFormData, value: ValueOf<RunFormData>) => void;
isCloned: boolean;
isDuplicated: boolean;
};

const RunForm: React.FC<RunFormProps> = ({ data, onValueChange, isCloned }) => {
const RunForm: React.FC<RunFormProps> = ({ data, onValueChange, isDuplicated }) => {
const { api } = usePipelinesAPI();
const [latestVersion] = useLatestPipelineVersion(data.pipeline?.pipeline_id);
// Use this state to avoid the pipeline version being set as the latest version at the initial load
Expand Down Expand Up @@ -104,7 +104,7 @@ const RunForm: React.FC<RunFormProps> = ({ data, onValueChange, isCloned }) => {

return (
<Form onSubmit={(e) => e.preventDefault()} maxWidth="500px">
<RunTypeSection data={data} isCloned={isCloned} />
<RunTypeSection data={data} isDuplicated={isDuplicated} />

<ProjectAndExperimentSection
projectName={getDisplayNameFromK8sResource(data.project)}
Expand Down
Loading
Loading