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

fix: custom flyteremote usage by protocol #825

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
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}")`
Comment on lines +100 to +104
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the indentation is slightly off. This renders like:

from flytekit.remote.remote import FlyteRemote
  from flytekit.configuration import Config
  remote = FlyteRemote(
      Config.for_endpoint("localhost:30080", True),
  )
  remote.get("flyte://v1/flytesnacks/development/fbd6520cd736b4dd7ac6/n0/i")

: // 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
Loading