Skip to content

Commit

Permalink
fix: custom flyteremote usage by protocol (#825)
Browse files Browse the repository at this point in the history
Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina authored Oct 19, 2023
1 parent 4adc6e3 commit a1fb29e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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,
Expand Down Expand Up @@ -88,30 +87,34 @@ const CopyButton: React.FC<

/** Fetches and renders the deck data for a given `nodeExecutionId` */
export const ExecutionNodeURL: React.FC<{
nodeExecutionId: Core.NodeExecutionIdentifier;
dataSourceURI: string;
dataSourceURI?: string;
copyUrlText: string;
}> = ({ nodeExecutionId, dataSourceURI, copyUrlText }) => {
}> = ({ 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 isHttps = /^https:/.test(window.location.href);

const code = isHttps
? // https snippet
`from flytekit.remote.remote import FlyteRemote
from flytekit.configuration import Config
remote = FlyteRemote(
Config.for_endpoint("${window.location.host}"),
)
remote.get("${dataSourceURI}")`
: // http snippet
`from flytekit.remote.remote import FlyteRemote
from flytekit.configuration import Config
remote = FlyteRemote(
Config.for_endpoint("${window.location.host}", True),
)
remote.get("${dataSourceURI}")`;

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

return (
return dataSourceURI ? (
<Box
className={styles.container}
sx={{
Expand Down Expand Up @@ -165,7 +168,6 @@ remote.get("${dataSourceURI}")`;
fontSize: '12px', // Adjust the font size as desired
backgroundColor: errorBackgroundColor,
}}
wrapLongLines={true}
>
{code}
</SyntaxHighlighter>
Expand All @@ -182,5 +184,5 @@ remote.get("${dataSourceURI}")`;
</Box>
</Box>
</Box>
);
) : null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@ export const NodeExecutionInputs: React.FC<{
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}
/>
{(() => {
const data = executionData?.value;
const fullInputs = data?.fullInputs;
const dataSourceURI = data?.flyteUrls?.inputs;
const hasInputs = Object.keys(fullInputs?.literals || {}).length > 0;
return (
<>
{hasInputs && taskIndex === undefined ? (
<ExecutionNodeURL
dataSourceURI={dataSourceURI}
copyUrlText="Copy Inputs URI"
/>
) : null}
<LiteralMapViewer map={fullInputs} mapTaskIndex={taskIndex} />
</>
);
})()}
</PanelSection>
</WaitForData>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@ export const NodeExecutionOutputs: React.FC<{
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}
/>
{(() => {
const data = executionData?.value;
const fullOutputs = data?.fullOutputs;
const dataSourceURI = data?.flyteUrls?.outputs;
const hasOutputs =
Object.keys(fullOutputs?.literals || {}).length > 0;
return (
<>
{hasOutputs && taskIndex === undefined ? (
<ExecutionNodeURL
dataSourceURI={dataSourceURI}
copyUrlText="Copy Outputs URI"
/>
) : null}
<LiteralMapViewer map={fullOutputs} mapTaskIndex={taskIndex} />
</>
);
})()}
</PanelSection>
</WaitForData>
);
Expand Down

0 comments on commit a1fb29e

Please sign in to comment.