From ab57c87eedb57bb6a2a6bf5664101111a65367f9 Mon Sep 17 00:00:00 2001 From: va6996 Date: Tue, 14 May 2024 16:49:34 -0700 Subject: [PATCH 1/3] Reuse existing executionClusterLabel value during relaunch Signed-off-by: va6996 --- packages/common/package.json | 2 +- .../RelaunchExecutionForm.tsx | 6 +++-- .../Executions/ExecutionDetails/constants.ts | 1 + .../test/RelaunchExecutionForm.test.tsx | 23 +++++++++++++++++++ .../Launch/LaunchForm/launchMachine.ts | 2 ++ .../src/components/Launch/LaunchForm/types.ts | 9 ++++++++ .../LaunchForm/useLaunchTaskFormState.ts | 17 ++++++++++++-- .../LaunchForm/useLaunchWorkflowFormState.ts | 16 ++++++++++++- .../oss-console/src/models/Execution/api.ts | 3 +++ website/console/env/index.ts | 2 +- yarn.lock | 10 ++++---- 11 files changed, 79 insertions(+), 12 deletions(-) diff --git a/packages/common/package.json b/packages/common/package.json index 6c6274e94..9a34462e2 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -24,7 +24,7 @@ "tslib": "^2.4.1" }, "dependencies": { - "@flyteorg/flyteidl": "^1.10.7", + "@flyteorg/flyteidl": "^1.11.1-b1", "@protobuf-ts/runtime": "^2.6.0", "@protobuf-ts/runtime-rpc": "^2.6.0" }, diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx index 7f63873dc..9003a46ee 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx @@ -37,6 +37,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps) securityContext, interruptible, overwriteCache, + executionClusterLabel, }, } = execution; @@ -63,6 +64,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps) securityContext, interruptible, overwriteCache, + executionClusterLabel, }; }, }, @@ -78,7 +80,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) { defaultValue: {} as TaskInitialLaunchParameters, doFetch: async (execution) => { const { - spec: { authRole, launchPlan: taskId, interruptible, overwriteCache }, + spec: { authRole, launchPlan: taskId, interruptible, overwriteCache, executionClusterLabel }, } = execution; const task = await apiContext.getTask(taskId); const inputDefinitions = getTaskInputs(task); @@ -89,7 +91,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) { }, apiContext, ); - return { authRole, values, taskId, interruptible, overwriteCache }; + return { authRole, values, taskId, interruptible, overwriteCache, executionClusterLabel }; }, }, execution, diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/constants.ts b/packages/oss-console/src/components/Executions/ExecutionDetails/constants.ts index 55ddb8c6b..97522052e 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/constants.ts +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/constants.ts @@ -12,6 +12,7 @@ export enum ExecutionMetadataLabels { securityContextDefault = 'default', interruptible = 'Interruptible override', overwriteCache = 'Overwrite cached outputs', + executionClusterLabel = 'Execution Cluster Label', } export const tabs = { diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx index 71df5d24d..bfdf9aee1 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/test/RelaunchExecutionForm.test.tsx @@ -231,6 +231,29 @@ describe('RelaunchExecutionForm', () => { }), }); }); + + it('should have correct execution cluster label', async () => { + execution.spec.executionClusterLabel = { + value: 'label' + }; + const { getByText } = renderForm(); + await waitFor(() => expect(getByText(mockContentString))); + checkLaunchFormProps({ + initialParameters: expect.objectContaining({ + executionClusterLabel: execution.spec.executionClusterLabel, + }), + }); + }); + + it('should have null execution cluster label', async () => { + const { getByText } = renderForm(); + await waitFor(() => expect(getByText(mockContentString))); + checkLaunchFormProps({ + initialParameters: expect.objectContaining({ + executionClusterLabel: undefined, + }), + }); + }); }); describe('Launch form with full inputs', () => { diff --git a/packages/oss-console/src/components/Launch/LaunchForm/launchMachine.ts b/packages/oss-console/src/components/Launch/LaunchForm/launchMachine.ts index b38c46049..82be0584f 100644 --- a/packages/oss-console/src/components/Launch/LaunchForm/launchMachine.ts +++ b/packages/oss-console/src/components/Launch/LaunchForm/launchMachine.ts @@ -96,6 +96,7 @@ export interface WorkflowLaunchContext extends BaseLaunchContext { securityContext?: Core.ISecurityContext | null; interruptible?: Protobuf.IBoolValue | null; overwriteCache?: boolean | null; + executionClusterLabel?: Admin.IExecutionClusterLabel | null; } export interface TaskLaunchContext extends BaseLaunchContext { @@ -105,6 +106,7 @@ export interface TaskLaunchContext extends BaseLaunchContext { taskVersionOptions?: Task[]; interruptible?: Protobuf.IBoolValue | null; overwriteCache?: boolean | null; + executionClusterLabel?: Admin.IExecutionClusterLabel | null; } export interface TaskResumeContext extends BaseLaunchContext { diff --git a/packages/oss-console/src/components/Launch/LaunchForm/types.ts b/packages/oss-console/src/components/Launch/LaunchForm/types.ts index fabd3495b..55f50cea0 100644 --- a/packages/oss-console/src/components/Launch/LaunchForm/types.ts +++ b/packages/oss-console/src/components/Launch/LaunchForm/types.ts @@ -68,6 +68,7 @@ export interface WorkflowInitialLaunchParameters extends BaseInitialLaunchParame annotations?: Admin.IAnnotations | null; interruptible?: Protobuf.IBoolValue | null; overwriteCache?: boolean | null; + executionClusterLabel?: Admin.IExecutionClusterLabel | null; } export interface LaunchWorkflowFormProps extends BaseLaunchFormProps { @@ -82,6 +83,7 @@ export interface TaskInitialLaunchParameters extends BaseInitialLaunchParameters securityContext?: Core.ISecurityContext; interruptible?: Protobuf.IBoolValue | null; overwriteCache?: boolean | null; + executionClusterLabel?: Admin.IExecutionClusterLabel | null; } export interface LaunchTaskFormProps extends BaseLaunchFormProps { taskId: NamedEntityIdentifier; @@ -115,6 +117,11 @@ export interface LaunchInterruptibleInputRef { validate(): boolean; } +export interface LaunchExecutionClusterLabelInputRef { + getValue(): Admin.IExecutionClusterLabel | null | undefined; + validate(): boolean; +} + export interface LaunchAdvancedOptionsRef { getValues(): Admin.IExecutionSpec; validate(): boolean; @@ -143,6 +150,7 @@ export interface LaunchWorkflowFormState { roleInputRef: React.RefObject; interruptibleInputRef: React.RefObject; overwriteCacheInputRef: React.RefObject; + executionClusterLabelInputRef: React.RefObject; state: State; service: Interpreter; workflowSourceSelectorState: WorkflowSourceSelectorState; @@ -153,6 +161,7 @@ export interface LaunchTaskFormState { roleInputRef: React.RefObject; interruptibleInputRef: React.RefObject; overwriteCacheInputRef: React.RefObject; + executionClusterLabelInputRef: React.RefObject; state: State; service: Interpreter; taskSourceSelectorState: TaskSourceSelectorState; diff --git a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchTaskFormState.ts b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchTaskFormState.ts index 466c6700d..b2bed5477 100644 --- a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchTaskFormState.ts +++ b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchTaskFormState.ts @@ -22,7 +22,7 @@ import { } from './launchMachine'; import { validate as baseValidate } from './services'; import { - LaunchFormInputsRef, + LaunchExecutionClusterLabelInputRef, LaunchFormInputsRef, LaunchInterruptibleInputRef, LaunchOverwriteCacheInputRef, LaunchRoleInputRef, @@ -116,6 +116,7 @@ async function submit( roleInputRef: RefObject, interruptibleInputRef: RefObject, overwriteCacheInputRef: RefObject, + executionClusterLabelInputRef: RefObject, { referenceExecutionId, taskVersion }: TaskLaunchContext, ) { if (!taskVersion) { @@ -132,6 +133,7 @@ async function submit( const literals = formInputsRef.current.getValues(); const interruptible = interruptibleInputRef.current?.getValue(); const overwriteCache = overwriteCacheInputRef.current?.getValue(); + const executionClusterLabel = executionClusterLabelInputRef.current?.getValue(); const launchPlanId = taskVersion; const { domain, project } = taskVersion; @@ -144,6 +146,7 @@ async function submit( inputs: { literals }, interruptible, overwriteCache, + executionClusterLabel, }); const newExecutionId = response.id as WorkflowExecutionIdentifier; if (!newExecutionId) { @@ -159,6 +162,7 @@ function getServices( roleInputRef: RefObject, interruptibleInputRef: RefObject, overwriteCacheInputRef: RefObject, + executionClusterLabelInputRef: RefObject, ) { return { loadTaskVersions: partial(loadTaskVersions, apiContext), @@ -170,6 +174,7 @@ function getServices( roleInputRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, launchContext, ), validate: partial( @@ -198,6 +203,7 @@ export function useLaunchTaskFormState({ values: defaultInputValues, interruptible, overwriteCache, + executionClusterLabel, } = initialParameters; const apiContext = useAPIContext(); @@ -205,6 +211,10 @@ export function useLaunchTaskFormState({ const roleInputRef = useRef(null); const interruptibleInputRef = useRef(null); const overwriteCacheInputRef = useRef(null); + const executionClusterLabelInputRef = useRef({ + getValue: () => executionClusterLabel, + validate: () => true, + }); const services = useMemo( () => @@ -214,8 +224,9 @@ export function useLaunchTaskFormState({ roleInputRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, ), - [apiContext, formInputsRef, roleInputRef, interruptibleInputRef, overwriteCacheInputRef], + [apiContext, formInputsRef, roleInputRef, interruptibleInputRef, overwriteCacheInputRef, executionClusterLabelInputRef], ); const [state, sendEvent, service] = useMachine< @@ -233,6 +244,7 @@ export function useLaunchTaskFormState({ sourceId, interruptible, overwriteCache, + executionClusterLabel, }, }); @@ -286,6 +298,7 @@ export function useLaunchTaskFormState({ roleInputRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, state, service, taskSourceSelectorState, diff --git a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts index bfbd56c2c..b37efe3a2 100644 --- a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts +++ b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts @@ -31,7 +31,7 @@ import { LaunchRoles, LaunchInterruptibleInputRef, LaunchOverwriteCacheInputRef, - LaunchRoleInputRef, + LaunchRoleInputRef, LaunchExecutionClusterLabelInputRef, } from './types'; import { useWorkflowSourceSelectorState } from './useWorkflowSourceSelectorState'; import { getUnsupportedRequiredInputs } from './utils'; @@ -165,6 +165,7 @@ async function submit( advancedOptionsRef: RefObject, interruptibleInputRef: RefObject, overwriteCacheInputRef: RefObject, + executionClusterLabelInputRef: RefObject, { launchPlan, referenceExecutionId, workflowVersion }: WorkflowLaunchContext, ) { if (!launchPlan) { @@ -183,6 +184,7 @@ async function submit( advancedOptionsRef.current?.getValues() || {}; const interruptible = interruptibleInputRef.current?.getValue(); const overwriteCache = overwriteCacheInputRef.current?.getValue(); + const executionClusterLabel = executionClusterLabelInputRef.current?.getValue(); const launchPlanId = launchPlan.id; const { domain, project } = workflowVersion; @@ -200,6 +202,7 @@ async function submit( inputs: { literals }, interruptible, overwriteCache, + executionClusterLabel, }); const newExecutionId = response.id as WorkflowExecutionIdentifier; if (!newExecutionId) { @@ -229,6 +232,7 @@ function getServices( advancedOptionsRef: RefObject, interruptibleInputRef: RefObject, overwriteCacheInputRef: RefObject, + executionClusterLabelInputRef: RefObject, ) { return { loadWorkflowVersions: partial(loadWorkflowVersions, apiContext), @@ -245,6 +249,7 @@ function getServices( advancedOptionsRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, launchContext, ), validate: () => @@ -281,6 +286,7 @@ export function useLaunchWorkflowFormState({ securityContext, interruptible, overwriteCache, + executionClusterLabel, } = initialParameters; const apiContext = useAPIContext(); @@ -289,6 +295,10 @@ export function useLaunchWorkflowFormState({ const advancedOptionsRef = useRef(null); const interruptibleInputRef = useRef(null); const overwriteCacheInputRef = useRef(null); + const executionClusterLabelInputRef = useRef({ + getValue: () => executionClusterLabel, + validate: () => true, + }); const services = useMemo( () => @@ -299,6 +309,7 @@ export function useLaunchWorkflowFormState({ advancedOptionsRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, ), [ apiContext, @@ -307,6 +318,7 @@ export function useLaunchWorkflowFormState({ advancedOptionsRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, ], ); @@ -332,6 +344,7 @@ export function useLaunchWorkflowFormState({ annotations, interruptible, overwriteCache, + executionClusterLabel, }, }); @@ -448,6 +461,7 @@ export function useLaunchWorkflowFormState({ roleInputRef, interruptibleInputRef, overwriteCacheInputRef, + executionClusterLabelInputRef, state, service, workflowSourceSelectorState, diff --git a/packages/oss-console/src/models/Execution/api.ts b/packages/oss-console/src/models/Execution/api.ts index 9d37e9231..87b5a519f 100644 --- a/packages/oss-console/src/models/Execution/api.ts +++ b/packages/oss-console/src/models/Execution/api.ts @@ -115,6 +115,7 @@ export interface CreateWorkflowExecutionArguments { referenceExecutionId?: WorkflowExecutionIdentifier; interruptible?: Protobuf.IBoolValue | null; overwriteCache?: boolean | null; + executionClusterLabel?: Admin.IExecutionClusterLabel | null; } /** Submits a request to create a new `WorkflowExecution` using the provided @@ -135,6 +136,7 @@ export const createWorkflowExecution = ( referenceExecutionId: referenceExecution, interruptible, overwriteCache, + executionClusterLabel, }: CreateWorkflowExecutionArguments, config?: RequestConfig, ) => { @@ -147,6 +149,7 @@ export const createWorkflowExecution = ( }, labels, annotations, + executionClusterLabel, }; if (securityContext?.runAs?.iamRole || securityContext?.runAs?.k8sServiceAccount) { diff --git a/website/console/env/index.ts b/website/console/env/index.ts index b714b52de..5a68c5ad4 100644 --- a/website/console/env/index.ts +++ b/website/console/env/index.ts @@ -37,7 +37,7 @@ const ADMIN_API_URL = process.env.ADMIN_API_URL?.replace(/https?:\/\//, '') || ' const ADMIN_API = ADMIN_API_URL ? `//${ADMIN_API_URL}` : ''; // Webpage for local development -const LOCAL_DEV_HOST = process.env.LOCAL_DEV_HOST || `localhost.${ADMIN_API_URL}`; +const LOCAL_DEV_HOST = process.env.LOCAL_DEV_HOST || 'localhost'; /** * @deprecated use BASE_HREF diff --git a/yarn.lock b/yarn.lock index 2bd7e9dca..fb40cac2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2092,7 +2092,7 @@ __metadata: version: 0.0.0-use.local resolution: "@clients/common@workspace:packages/common" dependencies: - "@flyteorg/flyteidl": ^1.10.7 + "@flyteorg/flyteidl": ^1.11.1-b1 "@protobuf-ts/runtime": ^2.6.0 "@protobuf-ts/runtime-rpc": ^2.6.0 peerDependencies: @@ -2940,10 +2940,10 @@ __metadata: languageName: node linkType: hard -"@flyteorg/flyteidl@npm:^1.10.7": - version: 1.10.7 - resolution: "@flyteorg/flyteidl@npm:1.10.7" - checksum: fa559d1b5fc676a220fdfdad1a689affcc7e34e375e9755153f14f44e41a1637414ccf43b5eeab8b4d8cd3b1f5d36d30ae5d75922e391f45d50e0b3f593fb8bb +"@flyteorg/flyteidl@npm:^1.11.1-b1": + version: 1.11.1-b1 + resolution: "@flyteorg/flyteidl@npm:1.11.1-b1" + checksum: 2d0932231b269c6b8d58d69caccf28c5a9222a64a448016cc5cbc0662e6d4d2445a17e403c61a459ec7998c85c4e07d4641c55cb3f1d967c468a7cdcc818f135 languageName: node linkType: hard From 630adfd7cb8c17abc28b6d511ba6dfcabbf54602 Mon Sep 17 00:00:00 2001 From: va6996 Date: Fri, 17 May 2024 09:32:54 -0700 Subject: [PATCH 2/3] revert minor change Signed-off-by: va6996 --- website/console/env/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/console/env/index.ts b/website/console/env/index.ts index c56d4e855..4114cb9a8 100644 --- a/website/console/env/index.ts +++ b/website/console/env/index.ts @@ -40,7 +40,7 @@ const ADMIN_API_URL = process.env.ADMIN_API_URL?.replace(/https?:\/\//, '') || ' const ADMIN_API = ADMIN_API_URL ? `//${ADMIN_API_URL}` : ''; // Webpage for local development -const LOCAL_DEV_HOST = process.env.LOCAL_DEV_HOST || 'localhost'; +const LOCAL_DEV_HOST = process.env.LOCAL_DEV_HOST || `localhost.${ADMIN_API_URL}`; /** * @deprecated use BASE_HREF From 312af24a7a488cd093416e919b1f5d15e4500b03 Mon Sep 17 00:00:00 2001 From: Vinayak Agarwal Date: Fri, 23 Aug 2024 16:24:40 -0700 Subject: [PATCH 3/3] Update useLaunchWorkflowFormState.ts --- .../components/Launch/LaunchForm/useLaunchWorkflowFormState.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts index b37efe3a2..2a813a7d6 100644 --- a/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts +++ b/packages/oss-console/src/components/Launch/LaunchForm/useLaunchWorkflowFormState.ts @@ -31,7 +31,8 @@ import { LaunchRoles, LaunchInterruptibleInputRef, LaunchOverwriteCacheInputRef, - LaunchRoleInputRef, LaunchExecutionClusterLabelInputRef, + LaunchRoleInputRef, + LaunchExecutionClusterLabelInputRef, } from './types'; import { useWorkflowSourceSelectorState } from './useWorkflowSourceSelectorState'; import { getUnsupportedRequiredInputs } from './utils';