Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show io urls & flyteremote usage #824

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (
<Button
// variant={buttonVariant === 'text' ? 'text' : 'outlined'}
color="primary"
className={buttonVariant === 'text' ? 'textButton' : 'copyButton'}
onClick={onCopyClick}
>
{children ? children : null}
<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);

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

const code = `from flytekit.remote.remote import FlyteRemote
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);
};

return (
<Box
className={styles.container}
sx={{
marginBottom: '20px',
}}
>
<Box className={styles.hoverWrapper}>
<CopyButton
buttonVariant="text"
style={{
fontSize: '14px',
}}
onCopyClick={event => {
event.preventDefault();

copyToClipboard(dataSourceURI);
}}
>
<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',
}}
>
<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();

copyToClipboard(code);
}}
/>
</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}
</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
nodeExecutionId={execution.id}
dataSourceURI={executionData.value?.flyteUrls?.inputs}
copyUrlText="Copy Inputs URI"
/>
) : null}
<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
nodeExecutionId={execution.id}
dataSourceURI={executionData.value?.flyteUrls?.outputs}
copyUrlText="Copy Outputs URI"
/>
) : null}
<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() !== '')
) {
reasons = reasons.concat(
finalReasons.map(
reason =>
(reason.occurredAt
? formatDateUTC(timestampToDate(reason.occurredAt)) + ' '
? `${formatDateUTC(timestampToDate(reason.occurredAt))} `
: '') + 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