Skip to content

Commit

Permalink
Renamed skipCache flag to overwriteCache
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Müller <[email protected]>
  • Loading branch information
Nick Müller committed Nov 3, 2022
1 parent 88aca5b commit b6a9984
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ExecutionMetadataExtra: React.FC<{
rawOutputDataConfig,
securityContext,
interruptible,
skipCache,
overwriteCache,
} = execution.spec;

const [launchPlanSpec, setLaunchPlanSpec] = React.useState<Partial<LaunchPlanSpec>>({});
Expand Down Expand Up @@ -73,8 +73,8 @@ export const ExecutionMetadataExtra: React.FC<{
value: interruptible ? (interruptible.value ? 'true' : 'false') : dashedValueString,
},
{
label: ExecutionMetadataLabels.skipCache,
value: skipCache ? 'true' : 'false',
label: ExecutionMetadataLabels.overwriteCache,
value: overwriteCache ? 'true' : 'false',
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps)
authRole,
securityContext,
interruptible,
skipCache,
overwriteCache,
},
} = execution;

Expand All @@ -62,7 +62,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps)
authRole,
securityContext,
interruptible,
skipCache,
overwriteCache,
};
},
},
Expand All @@ -78,7 +78,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) {
defaultValue: {} as TaskInitialLaunchParameters,
doFetch: async (execution) => {
const {
spec: { authRole, launchPlan: taskId, interruptible, skipCache },
spec: { authRole, launchPlan: taskId, interruptible, overwriteCache },
} = execution;
const task = await apiContext.getTask(taskId);
const inputDefinitions = getTaskInputs(task);
Expand All @@ -89,7 +89,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) {
},
apiContext,
);
return { authRole, values, taskId, interruptible, skipCache };
return { authRole, values, taskId, interruptible, overwriteCache };
},
},
execution,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum ExecutionMetadataLabels {
parallelism = 'Parallelism',
securityContextDefault = 'default',
interruptible = 'Interruptible override',
skipCache = 'Skip cached outputs',
overwriteCache = 'Overwrite cached outputs',
}

export const tabs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const clusterTestId = `metadata-${ExecutionMetadataLabels.cluster}`;
const startTimeTestId = `metadata-${ExecutionMetadataLabels.time}`;
const durationTestId = `metadata-${ExecutionMetadataLabels.duration}`;
const interruptibleTestId = `metadata-${ExecutionMetadataLabels.interruptible}`;
const skipCacheTestId = `metadata-${ExecutionMetadataLabels.skipCache}`;
const overwriteCacheTestId = `metadata-${ExecutionMetadataLabels.overwriteCache}`;

jest.mock('models/Launch/api', () => ({
getLaunchPlan: jest.fn(() => Promise.resolve({ spec: {} })),
Expand Down Expand Up @@ -97,21 +97,21 @@ describe('ExecutionMetadata', () => {
expect(getByTestId(interruptibleTestId)).toHaveTextContent(dashedValueString);
});

it('shows true if cache was skipped for execution', () => {
execution.spec.skipCache = true;
it('shows true if cache was overwritten for execution', () => {
execution.spec.overwriteCache = true;
const { getByTestId } = renderMetadata();
expect(getByTestId(skipCacheTestId)).toHaveTextContent('true');
expect(getByTestId(overwriteCacheTestId)).toHaveTextContent('true');
});

it('shows false if cache was not skipped for execution', () => {
execution.spec.skipCache = false;
it('shows false if cache was not overwritten for execution', () => {
execution.spec.overwriteCache = false;
const { getByTestId } = renderMetadata();
expect(getByTestId(skipCacheTestId)).toHaveTextContent('false');
expect(getByTestId(overwriteCacheTestId)).toHaveTextContent('false');
});

it('shows false if no cache skip value is found in execution spec', () => {
delete execution.spec.skipCache;
it('shows false if no cache overwrite value is found in execution spec', () => {
delete execution.spec.overwriteCache;
const { getByTestId } = renderMetadata();
expect(getByTestId(skipCacheTestId)).toHaveTextContent('false');
expect(getByTestId(overwriteCacheTestId)).toHaveTextContent('false');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -189,35 +189,35 @@ describe('RelaunchExecutionForm', () => {
});
});

it('should not set cache skip value if not provided', async () => {
delete execution.spec.skipCache;
it('should not set cache overwrite value if not provided', async () => {
delete execution.spec.overwriteCache;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: undefined,
overwriteCache: undefined,
}),
});
});

it('should have correct cache skip value if override is enabled', async () => {
execution.spec.skipCache = true;
it('should have correct cache overwrite value if override is enabled', async () => {
execution.spec.overwriteCache = true;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: true,
overwriteCache: true,
}),
});
});

it('should have correct interruptible value if override is disabled', async () => {
execution.spec.interruptible = Protobuf.BoolValue.create({ value: false });
it('should have correct cache overwrite value if override is disabled', async () => {
execution.spec.overwriteCache = false;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: undefined,
overwriteCache: undefined,
}),
});
});
Expand Down Expand Up @@ -356,35 +356,35 @@ describe('RelaunchExecutionForm', () => {
});
});

it('should not set cache skip value if not provided', async () => {
delete execution.spec.skipCache;
it('should not set cache overwrite value if not provided', async () => {
delete execution.spec.overwriteCache;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: undefined,
overwriteCache: undefined,
}),
});
});

it('should have correct cache skip value if override is enabled', async () => {
execution.spec.skipCache = true;
it('should have correct cache overwrite value if override is enabled', async () => {
execution.spec.overwriteCache = true;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: true,
overwriteCache: true,
}),
});
});

it('should have correct cache skip value if override is disabled', async () => {
execution.spec.skipCache = false;
it('should have correct cache overwrite value if override is disabled', async () => {
execution.spec.overwriteCache = false;
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
skipCache: false,
overwriteCache: false,
}),
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Typography } from '@material-ui/core';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Checkbox from '@material-ui/core/Checkbox';
import * as React from 'react';
import { useStyles } from './styles';
import { LaunchOverwriteCacheInputRef } from './types';
import t from './strings';

const isValueValid = (value: any) => {
return value !== undefined && value !== null;
};

interface LaunchOverwriteCacheInputProps {
initialValue?: boolean | null;
}

export const LaunchOverwriteCacheInputImpl: React.ForwardRefRenderFunction<
LaunchOverwriteCacheInputRef,
LaunchOverwriteCacheInputProps
> = (props, ref) => {
// overwriteCache stores the override to enable/disable the setting for an execution
const [overwriteCache, setOverwriteCache] = React.useState(false);

React.useEffect(() => {
if (isValueValid(props.initialValue)) {
setOverwriteCache(() => props.initialValue!);
}
}, [props.initialValue]);

const handleInputChange = React.useCallback(() => {
setOverwriteCache((prevState) => !prevState);
}, [overwriteCache]);

React.useImperativeHandle(
ref,
() => ({
getValue: () => {
return overwriteCache;
},
validate: () => true,
}),
[overwriteCache],
);

const styles = useStyles();

return (
<section>
<header className={styles.sectionHeader}>
<Typography variant="h6">Caching</Typography>
<Typography variant="body2">
Enabling the cache overwrite causes Flyte to ignore all previously computed and stored
outputs for a single execution and run all calculations again, overwriting any cached data
after a successful execution.
</Typography>
</header>
<section title={t('overwriteCache')}>
<FormControlLabel
control={<Checkbox checked={overwriteCache} onChange={handleInputChange} />}
label={t('overwriteCache')}
/>
</section>
</section>
);
};

export const LaunchOverwriteCacheInput = React.forwardRef(LaunchOverwriteCacheInputImpl);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LaunchFormInputs } from './LaunchFormInputs';
import { LaunchState } from './launchMachine';
import { LaunchRoleInput } from './LaunchRoleInput';
import { LaunchInterruptibleInput } from './LaunchInterruptibleInput';
import { LaunchSkipCacheInput } from './LaunchSkipCacheInput';
import { LaunchOverwriteCacheInput } from './LaunchOverwriteCacheInput';
import { SearchableSelector } from './SearchableSelector';
import { useStyles } from './styles';
import { BaseInterpretedLaunchState, BaseLaunchService, LaunchTaskFormProps } from './types';
Expand All @@ -21,7 +21,7 @@ export const LaunchTaskForm: React.FC<LaunchTaskFormProps> = (props) => {
formInputsRef,
roleInputRef,
interruptibleInputRef,
skipCacheInputRef,
overwriteCacheInputRef,
state,
service,
taskSourceSelectorState,
Expand Down Expand Up @@ -83,7 +83,10 @@ export const LaunchTaskForm: React.FC<LaunchTaskFormProps> = (props) => {
initialValue={state.context.interruptible}
ref={interruptibleInputRef}
/>
<LaunchSkipCacheInput initialValue={state.context.skipCache} ref={skipCacheInputRef} />
<LaunchOverwriteCacheInput
initialValue={state.context.overwriteCache}
ref={overwriteCacheInputRef}
/>
</DialogContent>
<LaunchFormActions
state={baseState}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { isEnterInputsState } from './utils';
import { LaunchRoleInput } from './LaunchRoleInput';
import { LaunchFormAdvancedInputs } from './LaunchFormAdvancedInputs';
import { LaunchInterruptibleInput } from './LaunchInterruptibleInput';
import { LaunchSkipCacheInput } from './LaunchSkipCacheInput';
import { LaunchOverwriteCacheInput } from './LaunchOverwriteCacheInput';

/** Renders the form for initiating a Launch request based on a Workflow */
export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) => {
Expand All @@ -23,7 +23,7 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) =>
roleInputRef,
advancedOptionsRef,
interruptibleInputRef,
skipCacheInputRef,
overwriteCacheInputRef,
state,
service,
workflowSourceSelectorState,
Expand Down Expand Up @@ -126,7 +126,10 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) =>
initialValue={state.context.interruptible}
ref={interruptibleInputRef}
/>
<LaunchSkipCacheInput initialValue={state.context.skipCache} ref={skipCacheInputRef} />
<LaunchOverwriteCacheInput
initialValue={state.context.overwriteCache}
ref={overwriteCacheInputRef}
/>
</AccordionDetails>
</Accordion>
</DialogContent>
Expand Down
Loading

0 comments on commit b6a9984

Please sign in to comment.