Skip to content

Commit 922bd3a

Browse files
Future-OutlierYicheng-Lu-lllllyonlu13ursucarina
authored
feat: Streaming Decks (#890)
* "Use Yi-Cheng Lu's code" Signed-off-by: Future-Outlier <eric901201@gmail.com> Co-authored-by: Yicheng-Lu-llll <luyc58576@gmail.com> * Add Refresh Bottom Signed-off-by: Future-Outlier <eric901201@gmail.com> * refresh fix Signed-off-by: Lyon Lu <lyon@union.ai> * move refresh button out Signed-off-by: Lyon Lu <lyon@union.ai> * update my code Signed-off-by: Future-Outlier <eric901201@gmail.com> * handle 404 vs 500 error rendering Signed-off-by: Carina Ursu <carina@union.ai> --------- Signed-off-by: Future-Outlier <eric901201@gmail.com> Signed-off-by: Lyon Lu <lyon@union.ai> Signed-off-by: Carina Ursu <carina@union.ai> Co-authored-by: Yicheng-Lu-llll <luyc58576@gmail.com> Co-authored-by: Lyon Lu <lyon@union.ai> Co-authored-by: Carina Ursu <carina@union.ai>
1 parent 17ef806 commit 922bd3a

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionDetailsActions/FlyteDeckButton.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Grid from '@mui/material/Grid';
88
import IconButton from '@mui/material/IconButton';
99
import Typography from '@mui/material/Typography';
1010
import DialogContent from '@mui/material/DialogContent';
11+
import { useDownloadLink } from '@clients/oss-console/components/hooks/useDataProxy';
12+
import RefreshIcon from '@mui/icons-material/Refresh';
1113
import t from '../strings';
1214
import { WorkflowNodeExecution } from '../../contexts';
1315
import { NodeExecutionPhase } from '../../../../models/Execution/enums';
@@ -52,14 +54,11 @@ export const FlyteDeckButton: FC<FlyteDeckButtonProps> = ({
5254
setSetFullScreen(!fullScreen);
5355
};
5456

57+
const downloadLink = useDownloadLink(nodeExecution?.id);
58+
5559
return nodeExecution?.closure?.deckUri ? (
5660
<>
57-
<Button
58-
variant="outlined"
59-
color="primary"
60-
onClick={() => setShowDeck(true)}
61-
disabled={phase !== NodeExecutionPhase.SUCCEEDED}
62-
>
61+
<Button variant="outlined" color="primary" onClick={() => setShowDeck(true)}>
6362
{flyteDeckText || t('flyteDeck')}
6463
</Button>
6564
<Dialog
@@ -91,10 +90,17 @@ export const FlyteDeckButton: FC<FlyteDeckButtonProps> = ({
9190
fontSize: '24px',
9291
lineHeight: '32px',
9392
marginBlock: 0,
93+
display: 'flex',
94+
justifyContent: 'center',
95+
alignItems: 'center',
96+
gap: 1,
9497
}}
9598
py={2}
9699
>
97-
{t('flyteDeck')}
100+
{flyteDeckText || t('flyteDeck')}
101+
<IconButton onClick={() => downloadLink.fetch()}>
102+
<RefreshIcon />
103+
</IconButton>
98104
</Typography>
99105
</Grid>
100106
<Grid item>
@@ -109,7 +115,7 @@ export const FlyteDeckButton: FC<FlyteDeckButtonProps> = ({
109115
overflow: 'hidden',
110116
}}
111117
>
112-
<ExecutionNodeDeck nodeExecutionId={nodeExecution.id} />
118+
<ExecutionNodeDeck nodeExecutionId={nodeExecution.id} downloadLink={downloadLink} />
113119
</DialogContent>
114120
</Dialog>
115121
</>

packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeDeck.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import Core from '@clients/common/flyteidl/core';
3+
import NotFoundError from '@clients/common/Errors/NotFoundError';
34
import { LoadingSpinner } from '@clients/primitives/LoadingSpinner';
45
import { useDownloadLink } from '../../hooks/useDataProxy';
56
import { WaitForData } from '../../common/WaitForData';
@@ -8,8 +9,8 @@ import { WaitForData } from '../../common/WaitForData';
89
export const ExecutionNodeDeck: React.FC<{
910
nodeExecutionId: Core.NodeExecutionIdentifier;
1011
className?: string;
11-
}> = ({ nodeExecutionId, className = '' }) => {
12-
const downloadLink = useDownloadLink(nodeExecutionId);
12+
downloadLink: ReturnType<typeof useDownloadLink>;
13+
}> = ({ className = '', downloadLink }) => {
1314
const iFrameSrc = downloadLink?.value?.signedUrl?.[0];
1415

1516
// Taken from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#sandbox
@@ -27,6 +28,27 @@ export const ExecutionNodeDeck: React.FC<{
2728
'allow-downloads',
2829
].join(' ');
2930

31+
/**
32+
* if the download link query has an error other than 404, we show a 'pretty' message to the user.
33+
* else: we show the built in DataError handler passed to the WaitForQuery component.
34+
*/
35+
if (downloadLink?.lastError && !(downloadLink?.lastError instanceof NotFoundError)) {
36+
return (
37+
<div style={{ textAlign: 'center' }}>
38+
<h1>The deck will be ready soon. Please try again later.</h1>
39+
<p>
40+
If you're using the real-time deck, it's because the 'publish' function has not been
41+
invoked yet.
42+
</p>
43+
<p>
44+
If you're not using the real-time deck, it's because the corresponding task is still in
45+
progress.
46+
</p>
47+
</div>
48+
);
49+
}
50+
51+
// 404 or no error case
3052
return (
3153
<WaitForData {...downloadLink} loadingComponent={LoadingSpinner}>
3254
<iframe

0 commit comments

Comments
 (0)