Skip to content

Commit

Permalink
feat: show io urls & flyteremote usage
Browse files Browse the repository at this point in the history
Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina committed Oct 19, 2023
1 parent ce46159 commit 916e26c
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"prettier": "^2.8.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-syntax-highlighter": "^15.5.0",
"semantic-release": "^21.0.7",
"serve-static": "^1.12.3",
"source-map-loader": "^4.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import * as React from 'react';
import { Box, Button, SvgIconTypeMap, Typography } from '@material-ui/core';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { docco } from 'react-syntax-highlighter/dist/esm/styles/hljs/docco';
import FileCopyIcon from '@material-ui/icons/FileCopy';
import { DefaultComponentProps } from '@material-ui/core/OverridableComponent';
import copyToClipboard from 'copy-to-clipboard';
import { Theme, makeStyles } from '@material-ui/core/styles';
import { Core } from '@flyteorg/flyteidl-types';
import {
primaryHighlightColor,
separatorColor,
errorBackgroundColor,
listhoverColor,
} from 'components/Theme/constants';
import classNames from 'classnames';
import { RowExpander } from '../Tables/RowExpander';

const useStyles = makeStyles((theme: Theme) => ({
container: {
marginLeft: '-10px',
},
codeWrapper: {
overflow: 'hidden',
border: `1px solid ${separatorColor}`,
borderRadius: 4,
marginLeft: '16px',
},

hoverWrapper: {
position: 'relative',

'& .textButton': {
color: theme.palette.primary.main,
border: 'none',
right: '2px',
top: 0,
},

'& .copyButton': {
backgroundColor: theme.palette.common.white,
border: `1px solid ${primaryHighlightColor}`,
borderRadius: theme.spacing(1),
color: theme.palette.text.secondary,
height: theme.spacing(4),
minWidth: 0,
padding: 0,
position: 'absolute',
right: theme.spacing(2),
top: theme.spacing(1),
width: theme.spacing(4),
display: 'none',

'&:hover': {
backgroundColor: listhoverColor,
},
},
'&:hover': {
'& .copyButton': {
display: 'flex',
},
},

'& pre': {
margin: '0 !important',
},
},
}));

const CopyButton: React.FC<
DefaultComponentProps<SvgIconTypeMap<{}, 'svg'>> & {
onCopyClick: React.MouseEventHandler<HTMLButtonElement>;
buttonVariant?: 'text' | 'button';
}
> = ({ onCopyClick, buttonVariant, children, ...props }) => {
return (

Check warning on line 76 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L76

Added line #L76 was not covered by tests
<Button
// variant={buttonVariant === 'text' ? 'text' : 'outlined'}
color="primary"
className={buttonVariant === 'text' ? 'textButton' : 'copyButton'}

Check warning on line 80 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L80

Added line #L80 was not covered by tests
onClick={onCopyClick}
>
{children ? children : null}

Check warning on line 83 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L83

Added line #L83 was not covered by tests
<FileCopyIcon {...props} />
</Button>
);
};

/** Fetches and renders the deck data for a given `nodeExecutionId` */
export const ExecutionNodeURL: React.FC<{
nodeExecutionId: Core.NodeExecutionIdentifier;
dataSourceURI: string;
copyUrlText: string;
}> = ({ nodeExecutionId, dataSourceURI, copyUrlText }) => {
const styles = useStyles();
const [expanded, setExpanded] = React.useState<boolean>(false);

Check warning on line 96 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L95-L96

Added lines #L95 - L96 were not covered by tests

const project = nodeExecutionId.executionId?.project;
const domain = nodeExecutionId.executionId?.domain;

Check warning on line 99 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L98-L99

Added lines #L98 - L99 were not covered by tests

const code = `from flytekit.remote.remote import FlyteRemote

Check warning on line 101 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L101

Added line #L101 was not covered by tests
from flytekit.configuration import Config
remote = FlyteRemote(
Config.for_endpoint(endpoint="${window.location.host}"),
default_project="${project}",
default_domain="${domain}"
)
remote.get("${dataSourceURI}")`;

const toggleExpanded = () => {
setExpanded(!expanded);

Check warning on line 111 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L110-L111

Added lines #L110 - L111 were not covered by tests
};

return (

Check warning on line 114 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L114

Added line #L114 was not covered by tests
<Box
className={styles.container}
sx={{
marginBottom: '20px',
}}
>
<Box className={styles.hoverWrapper}>
<CopyButton
buttonVariant="text"
style={{
fontSize: '14px',
}}
onCopyClick={event => {
event.preventDefault();

Check warning on line 128 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L127-L128

Added lines #L127 - L128 were not covered by tests

copyToClipboard(dataSourceURI);

Check warning on line 130 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L130

Added line #L130 was not covered by tests
}}
>
<Typography
variant="body1"
style={{
paddingRight: '5px',
}}
>
{copyUrlText}
</Typography>
</CopyButton>
</Box>

<Box
sx={{
display: 'flex',
flex: '1 1 auto',
alignItems: 'center',
}}
>
<RowExpander expanded={expanded} onClick={toggleExpanded} />
<Typography variant="body2">FlyteRemote Usage</Typography>
</Box>

<Box
sx={{
display: expanded ? 'block' : 'none',

Check warning on line 157 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L157

Added line #L157 was not covered by tests
}}
>
<Box className={classNames(styles.hoverWrapper, styles.codeWrapper)}>
<SyntaxHighlighter
language="python"
style={docco}
customStyle={{
fontSize: '12px', // Adjust the font size as desired
backgroundColor: errorBackgroundColor,
}}
wrapLongLines={true}
>
{code}
</SyntaxHighlighter>

<CopyButton
buttonVariant="button"
fontSize="small"
onCopyClick={event => {
event.preventDefault();

Check warning on line 177 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L176-L177

Added lines #L176 - L177 were not covered by tests

copyToClipboard(code);

Check warning on line 179 in packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx#L179

Added line #L179 was not covered by tests
}}
/>
</Box>
</Box>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -412,33 +412,16 @@ export const NodeExecutionDetailsPanelContent: React.FC<
return computedPhase;
}, [nodeExecution, isGateNode]);

const isRunningPhase = useMemo(
() =>
frontendPhase === NodeExecutionPhase.QUEUED ||
frontendPhase === NodeExecutionPhase.RUNNING,
[frontendPhase],
);

const handleReasonsVisibility = () => {
setReasonsVisible(!isReasonsVisible);
};

const statusContent = nodeExecution ? (
<div className={styles.statusContainer}>
<div className={styles.statusHeaderContainer}>
<ExecutionStatusBadge phase={frontendPhase} type="node" />
{isRunningPhase && (
<InfoIcon
className={styles.reasonsIcon}
onClick={handleReasonsVisibility}
/>
)}
</div>
{isRunningPhase && isReasonsVisible && (
{reasons?.length ? (
<div className={styles.statusBody}>
<ScrollableMonospaceText text={reasons.join('\n\n')} />
</div>
)}
) : null}

Check warning on line 424 in packages/console/src/components/Executions/ExecutionDetails/NodeExecutionDetailsPanelContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/NodeExecutionDetailsPanelContent.tsx#L424

Added line #L424 was not covered by tests
</div>
) : (
<div className={styles.notRunStatus}>NOT RUN</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ import { useNodeExecutionData } from 'components/hooks/useNodeExecution';
import { LiteralMapViewer } from 'components/Literals/LiteralMapViewer';
import { NodeExecution } from 'models/Execution/types';
import * as React from 'react';
import { ExecutionNodeURL } from '../ExecutionNodeURL';

/** Fetches and renders the input data for a given `NodeExecution` */
export const NodeExecutionInputs: React.FC<{
execution: NodeExecution;
taskIndex?: number;
}> = ({ execution, taskIndex }) => {
const executionData = useNodeExecutionData(execution.id);

return (
<WaitForData {...executionData}>
<PanelSection>
{executionData.value?.flyteUrls?.inputs ? (
<ExecutionNodeURL

Check warning on line 20 in packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionInputs.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionInputs.tsx#L20

Added line #L20 was not covered by tests
nodeExecutionId={execution.id}
dataSourceURI={executionData.value?.flyteUrls?.inputs}
copyUrlText="Copy Inputs URI"
/>
) : null}

Check warning on line 25 in packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionInputs.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionInputs.tsx#L25

Added line #L25 was not covered by tests
<LiteralMapViewer
map={executionData.value.fullInputs}
mapTaskIndex={taskIndex}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ import { useNodeExecutionData } from 'components/hooks/useNodeExecution';
import { LiteralMapViewer } from 'components/Literals/LiteralMapViewer';
import { NodeExecution } from 'models/Execution/types';
import * as React from 'react';
import { ExecutionNodeURL } from '../ExecutionNodeURL';

/** Fetches and renders the output data for a given `NodeExecution` */
export const NodeExecutionOutputs: React.FC<{
execution: NodeExecution;
taskIndex?: number;
}> = ({ execution, taskIndex }) => {
const executionData = useNodeExecutionData(execution.id);

return (
<WaitForData {...executionData}>
<PanelSection>
{executionData.value?.flyteUrls?.outputs ? (
<ExecutionNodeURL

Check warning on line 20 in packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionOutputs.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionOutputs.tsx#L20

Added line #L20 was not covered by tests
nodeExecutionId={execution.id}
dataSourceURI={executionData.value?.flyteUrls?.outputs}
copyUrlText="Copy Outputs URI"
/>
) : null}

Check warning on line 25 in packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionOutputs.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/NodeExecutionTabs/NodeExecutionOutputs.tsx#L25

Added line #L25 was not covered by tests
<LiteralMapViewer
map={executionData.value.fullOutputs}
mapTaskIndex={taskIndex}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ export function getTaskExecutionDetailReasons(
? taskExecution.closure.reasons
: [{ message: taskExecution.closure.reason }]
).filter(r => !!r);

if (finalReasons) {
if (
finalReasons &&
finalReasons.some(eachReason => eachReason?.message?.trim() !== '')

Check warning on line 40 in packages/console/src/components/Executions/ExecutionDetails/utils.ts

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/utils.ts#L38-L40

Added lines #L38 - L40 were not covered by tests
) {
reasons = reasons.concat(
finalReasons.map(
reason =>
(reason.occurredAt
? formatDateUTC(timestampToDate(reason.occurredAt)) + ' '
? `${formatDateUTC(timestampToDate(reason.occurredAt))} `

Check warning on line 46 in packages/console/src/components/Executions/ExecutionDetails/utils.ts

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Executions/ExecutionDetails/utils.ts#L46

Added line #L46 was not covered by tests
: '') + reason.message,
),
);
Expand Down
4 changes: 4 additions & 0 deletions packages/console/src/models/Execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@ export interface ExecutionData {
fullOutputs: LiteralMap | null;
deckUri?: string;
dynamicWorkflow?: CompiledWorkflow;
flyteUrls?: {
inputs?: string;
outputs?: string;
};
}
2 changes: 1 addition & 1 deletion packages/flyteidl-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"protobufjs": "~6.11.3"
},
"dependencies": {
"@flyteorg/flyteidl": "1.3.18"
"@flyteorg/flyteidl": "^1.5.21"
}
}
Loading

0 comments on commit 916e26c

Please sign in to comment.