-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose caching status for NodeExecutions (#91)
* chore: update flyteidl * feat: show caching status on node executions details panel * fix: use a different icon for cache population * fix: adding source execution links if they exist * fix: showing cache status in the table as well * test: adding tests for cache status components
- Loading branch information
Showing
17 changed files
with
354 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { SvgIconProps, Tooltip, Typography } from '@material-ui/core'; | ||
import { makeStyles, Theme } from '@material-ui/core/styles'; | ||
import CachedOutlined from '@material-ui/icons/CachedOutlined'; | ||
import ErrorOutlined from '@material-ui/icons/ErrorOutlined'; | ||
import InfoOutlined from '@material-ui/icons/InfoOutlined'; | ||
import * as classnames from 'classnames'; | ||
import { assertNever } from 'common/utils'; | ||
import { PublishedWithChangesOutlined } from 'components/common/PublishedWithChanges'; | ||
import { useCommonStyles } from 'components/common/styles'; | ||
import { Core } from 'flyteidl'; | ||
import { TaskNodeMetadata } from 'models'; | ||
import * as React from 'react'; | ||
import { Link as RouterLink } from 'react-router-dom'; | ||
import { Routes } from 'routes'; | ||
import { | ||
cacheStatusMessages, | ||
unknownCacheStatusString, | ||
viewSourceExecutionString | ||
} from './constants'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
cacheStatus: { | ||
alignItems: 'center', | ||
display: 'flex', | ||
marginTop: theme.spacing(1) | ||
}, | ||
sourceExecutionLink: { | ||
fontWeight: 'normal' | ||
} | ||
})); | ||
|
||
/** Renders the appropriate icon for a given `Core.CatalogCacheStatus` */ | ||
export const NodeExecutionCacheStatusIcon: React.FC<SvgIconProps & { | ||
status: Core.CatalogCacheStatus; | ||
}> = React.forwardRef(({ status, ...props }, ref) => { | ||
switch (status) { | ||
case Core.CatalogCacheStatus.CACHE_DISABLED: | ||
case Core.CatalogCacheStatus.CACHE_MISS: { | ||
return <InfoOutlined {...props} ref={ref} />; | ||
} | ||
case Core.CatalogCacheStatus.CACHE_HIT: { | ||
return <CachedOutlined {...props} ref={ref} />; | ||
} | ||
case Core.CatalogCacheStatus.CACHE_POPULATED: { | ||
return <PublishedWithChangesOutlined {...props} ref={ref} />; | ||
} | ||
case Core.CatalogCacheStatus.CACHE_LOOKUP_FAILURE: | ||
case Core.CatalogCacheStatus.CACHE_PUT_FAILURE: { | ||
return <ErrorOutlined {...props} ref={ref} />; | ||
} | ||
default: { | ||
assertNever(status); | ||
return null; | ||
} | ||
} | ||
}); | ||
|
||
export interface NodeExecutionCacheStatusProps { | ||
taskNodeMetadata?: TaskNodeMetadata; | ||
/** `normal` will render an icon with description message beside it | ||
* `iconOnly` will render just the icon with the description as a tooltip | ||
*/ | ||
variant?: 'normal' | 'iconOnly'; | ||
} | ||
/** For a given `NodeExecution.closure.taskNodeMetadata` object, will render | ||
* the cache status with a descriptive message. For `Core.CacheCatalogStatus.CACHE_HIT`, | ||
* it will also attempt to render a link to the source `WorkflowExecution` (normal | ||
* variant only). | ||
*/ | ||
export const NodeExecutionCacheStatus: React.FC<NodeExecutionCacheStatusProps> = ({ | ||
taskNodeMetadata, | ||
variant = 'normal' | ||
}) => { | ||
const commonStyles = useCommonStyles(); | ||
const styles = useStyles(); | ||
if (taskNodeMetadata == null || taskNodeMetadata.cacheStatus == null) { | ||
return null; | ||
} | ||
|
||
const message = | ||
cacheStatusMessages[taskNodeMetadata.cacheStatus] || | ||
unknownCacheStatusString; | ||
|
||
const sourceExecutionId = taskNodeMetadata.catalogKey?.sourceTaskExecution; | ||
const sourceExecutionLink = sourceExecutionId ? ( | ||
<RouterLink | ||
className={classnames( | ||
commonStyles.primaryLink, | ||
styles.sourceExecutionLink | ||
)} | ||
to={Routes.ExecutionDetails.makeUrl( | ||
sourceExecutionId.nodeExecutionId.executionId | ||
)} | ||
> | ||
{viewSourceExecutionString} | ||
</RouterLink> | ||
) : null; | ||
|
||
return variant === 'iconOnly' ? ( | ||
<Tooltip title={message} aria-label="cache status"> | ||
<NodeExecutionCacheStatusIcon | ||
className={classnames( | ||
commonStyles.iconLeft, | ||
commonStyles.iconRight, | ||
commonStyles.iconSecondary | ||
)} | ||
status={taskNodeMetadata.cacheStatus} | ||
/> | ||
</Tooltip> | ||
) : ( | ||
<div> | ||
<Typography | ||
className={styles.cacheStatus} | ||
variant="subtitle1" | ||
color="textSecondary" | ||
> | ||
<NodeExecutionCacheStatusIcon | ||
status={taskNodeMetadata.cacheStatus} | ||
className={classnames( | ||
commonStyles.iconSecondary, | ||
commonStyles.iconLeft | ||
)} | ||
/> | ||
{message} | ||
</Typography> | ||
{sourceExecutionLink} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.