diff --git a/0001-Add-CODE_SNIPPET_URL-to-config.patch b/0001-Add-CODE_SNIPPET_URL-to-config.patch new file mode 100644 index 000000000..678bbc68b --- /dev/null +++ b/0001-Add-CODE_SNIPPET_URL-to-config.patch @@ -0,0 +1,105 @@ +From c08ffc01813efe56e4fe1b9225569d8e15a4a7e4 Mon Sep 17 00:00:00 2001 +From: ddl-rliu +Date: Wed, 17 Jul 2024 12:28:02 -0700 +Subject: [PATCH] Add CODE_SNIPPET_URL to config + +Signed-off-by: ddl-rliu +--- + packages/common/src/environment/index.ts | 6 +++++ + .../ExecutionDetails/ExecutionNodeURL.tsx | 22 +++++++++---------- + website/console/env/index.ts | 7 ++++++ + 3 files changed, 24 insertions(+), 11 deletions(-) + +diff --git a/packages/common/src/environment/index.ts b/packages/common/src/environment/index.ts +index 82e275c..78ccdd3 100644 +--- a/packages/common/src/environment/index.ts ++++ b/packages/common/src/environment/index.ts +@@ -33,6 +33,12 @@ export interface Env extends NodeJS.ProcessEnv { + * @example MAINTENANCE_MODE="We are currently down for maintenance.\n\nPlease try again later." + */ + MAINTENANCE_MODE?: string; ++ ++ /** ++ * Controls whether the config object in the inputs/outputs Python code snippet is automatically constructed ++ * Leave unset to use the config object for endpoint window.location.host ++ */ ++ CODE_SNIPPET_USE_AUTO_CONFIG?: string; + } + + /** Represents a plain object where string keys map to values of the same type */ +diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx +index 8cda4de..42d2c2a 100644 +--- a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx ++++ b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx +@@ -11,6 +11,7 @@ import Grid from '@mui/material/Grid'; + import Link from '@mui/material/Link'; + import { RowExpander } from '../Tables/RowExpander'; + import { ScrollableMonospaceText } from '../../common/ScrollableMonospaceText'; ++import { env } from '@clients/common/environment'; + + const StyledScrollableMonospaceText = styled(ScrollableMonospaceText)(({ theme }) => ({ + '&>div': { +@@ -31,19 +32,18 @@ export const ExecutionNodeURL: React.FC<{ + const isHttps = /^https:/.test(window.location.href); + const ref = React.useRef(null); + +- const code = isHttps +- ? // https snippet +- `from flytekit.remote.remote import FlyteRemote ++ const config = ++ env.CODE_SNIPPET_USE_AUTO_CONFIG ++ ? 'Config.auto()' ++ : isHttps ++ ? // https snippet ++ `Config.for_endpoint("${window.location.host}")` ++ : // http snippet ++ `Config.for_endpoint("${window.location.host}", True)`; ++ const code = `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), ++ ${config}, + ) + remote.get("${dataSourceURI}")`; + +diff --git a/website/console/env/index.ts b/website/console/env/index.ts +index 4114cb9..16772c2 100644 +--- a/website/console/env/index.ts ++++ b/website/console/env/index.ts +@@ -77,6 +77,11 @@ const ASSETS_PATH = `${BASE_URL}/assets/`; + */ + const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || ''; + ++/** ++ * Controls whether the config object in the inputs/outputs Python code snippet is automatically constructed ++ */ ++const CODE_SNIPPET_USE_AUTO_CONFIG = process.env.CODE_SNIPPET_USE_AUTO_CONFIG || ''; ++ + const processEnv = { + NODE_ENV, + PORT, +@@ -86,6 +91,7 @@ const processEnv = { + BASE_HREF, + DISABLE_CONSOLE_ROUTE_PREFIX, + MAINTENANCE_MODE, ++ CODE_SNIPPET_USE_AUTO_CONFIG, + }; + + export { +@@ -101,5 +107,6 @@ export { + ADMIN_API, + LOCAL_DEV_HOST, + MAINTENANCE_MODE, ++ CODE_SNIPPET_USE_AUTO_CONFIG, + processEnv, + }; +-- +2.44.0 + diff --git a/0001-x.patch b/0001-x.patch new file mode 100644 index 000000000..1d746fcc8 --- /dev/null +++ b/0001-x.patch @@ -0,0 +1,126 @@ +From 0dfb087b2ef56aef023d56c99baa625ab7d4ba9b Mon Sep 17 00:00:00 2001 +From: ddl-rliu +Date: Wed, 17 Jul 2024 12:28:02 -0700 +Subject: [PATCH] x + +--- + packages/common/src/environment/index.ts | 5 +++++ + .../Executions/ExecutionDetails/ExecutionNodeURL.tsx | 8 +++++--- + packages/primitives/src/utils/environment.ts | 2 ++ + website/console/env/index.ts | 10 ++++++++++ + 4 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/packages/common/src/environment/index.ts b/packages/common/src/environment/index.ts +index 82e275c..2f6b4d4 100644 +--- a/packages/common/src/environment/index.ts ++++ b/packages/common/src/environment/index.ts +@@ -33,6 +33,11 @@ export interface Env extends NodeJS.ProcessEnv { + * @example MAINTENANCE_MODE="We are currently down for maintenance.\n\nPlease try again later." + */ + MAINTENANCE_MODE?: string; ++ ++ /** ++ * Controls the endpoint used in Python code snippet ++ */ ++ CODE_SNIPPET_URL?: string; + } + + /** Represents a plain object where string keys map to values of the same type */ +diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx +index 8cda4de..9bbb89d 100644 +--- a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx ++++ b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx +@@ -11,6 +11,7 @@ import Grid from '@mui/material/Grid'; + import Link from '@mui/material/Link'; + import { RowExpander } from '../Tables/RowExpander'; + import { ScrollableMonospaceText } from '../../common/ScrollableMonospaceText'; ++import { env } from '@clients/common/environment'; + + const StyledScrollableMonospaceText = styled(ScrollableMonospaceText)(({ theme }) => ({ + '&>div': { +@@ -28,22 +29,23 @@ export const ExecutionNodeURL: React.FC<{ + copyUrlText: string; + }> = ({ dataSourceURI, copyUrlText }) => { + const [expanded, setExpanded] = React.useState(false); +- const isHttps = /^https:/.test(window.location.href); ++ const isHttps = /^https:/.test(env.ADMIN_API || window.location.href); + const ref = React.useRef(null); ++ const codeSnippetUrl = env.CODE_SNIPPET_URL || window.location.host; + + const code = isHttps + ? // https snippet + `from flytekit.remote.remote import FlyteRemote + from flytekit.configuration import Config + remote = FlyteRemote( +- Config.for_endpoint("${window.location.host}"), ++ Config.for_endpoint("${codeSnippetUrl}"), + ) + 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), ++ Config.for_endpoint("${codeSnippetUrl}", True), + ) + remote.get("${dataSourceURI}")`; + +diff --git a/packages/primitives/src/utils/environment.ts b/packages/primitives/src/utils/environment.ts +index 165daea..00ae2b8 100644 +--- a/packages/primitives/src/utils/environment.ts ++++ b/packages/primitives/src/utils/environment.ts +@@ -2,6 +2,8 @@ import { env as commonEnv, Env } from '@clients/common/environment'; + + const envVariables = { ...commonEnv }; + ++console.warn("envVariables", envVariables); ++ + export const currentAdminDomain = window.location.hostname.replace('localhost.', ''); + + if (!envVariables.ADMIN_API_URL) { +diff --git a/website/console/env/index.ts b/website/console/env/index.ts +index 4114cb9..c124949 100644 +--- a/website/console/env/index.ts ++++ b/website/console/env/index.ts +@@ -33,6 +33,7 @@ const CERTIFICATE_PATH = '../../scripts/certificate'; + // Use this to create SSL server + const ADMIN_API_USE_SSL = process.env.ADMIN_API_USE_SSL || 'http'; + ++console.warn("process.env", process.env); + // Admin domain used as base for window URL and API urls + const ADMIN_API_URL = process.env.ADMIN_API_URL?.replace(/https?:\/\//, '') || ''; + +@@ -77,6 +78,11 @@ const ASSETS_PATH = `${BASE_URL}/assets/`; + */ + const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || ''; + ++/** ++ * Controls the endpoint used in Python code snippet ++ */ ++const CODE_SNIPPET_URL = process.env.CODE_SNIPPET_URL || ''; ++ + const processEnv = { + NODE_ENV, + PORT, +@@ -86,8 +92,11 @@ const processEnv = { + BASE_HREF, + DISABLE_CONSOLE_ROUTE_PREFIX, + MAINTENANCE_MODE, ++ CODE_SNIPPET_URL, + }; + ++console.warn("processEnv", processEnv); ++ + export { + NODE_ENV, + PORT, +@@ -101,5 +110,6 @@ export { + ADMIN_API, + LOCAL_DEV_HOST, + MAINTENANCE_MODE, ++ CODE_SNIPPET_URL, + processEnv, + }; +-- +2.44.0 + diff --git a/packages/common/src/environment/index.ts b/packages/common/src/environment/index.ts index 82e275c52..78ccdd302 100644 --- a/packages/common/src/environment/index.ts +++ b/packages/common/src/environment/index.ts @@ -33,6 +33,12 @@ export interface Env extends NodeJS.ProcessEnv { * @example MAINTENANCE_MODE="We are currently down for maintenance.\n\nPlease try again later." */ MAINTENANCE_MODE?: string; + + /** + * Controls whether the config object in the inputs/outputs Python code snippet is automatically constructed + * Leave unset to use the config object for endpoint window.location.host + */ + CODE_SNIPPET_USE_AUTO_CONFIG?: string; } /** Represents a plain object where string keys map to values of the same type */ diff --git a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx index 8cda4de12..61abdc590 100644 --- a/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx +++ b/packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx @@ -11,6 +11,7 @@ import Grid from '@mui/material/Grid'; import Link from '@mui/material/Link'; import { RowExpander } from '../Tables/RowExpander'; import { ScrollableMonospaceText } from '../../common/ScrollableMonospaceText'; +import { env } from '@clients/common/environment'; const StyledScrollableMonospaceText = styled(ScrollableMonospaceText)(({ theme }) => ({ '&>div': { @@ -31,19 +32,18 @@ export const ExecutionNodeURL: React.FC<{ const isHttps = /^https:/.test(window.location.href); const ref = React.useRef(null); - const code = isHttps - ? // https snippet - `from flytekit.remote.remote import FlyteRemote + const config = + env.CODE_SNIPPET_USE_AUTO_CONFIG === "true" + ? 'Config.auto()' + : isHttps + ? // https snippet + `Config.for_endpoint("${window.location.host}")` + : // http snippet + `Config.for_endpoint("${window.location.host}", True)`; + const code = `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), + ${config}, ) remote.get("${dataSourceURI}")`; diff --git a/website/console/env/index.ts b/website/console/env/index.ts index 4114cb9a8..16772c23a 100644 --- a/website/console/env/index.ts +++ b/website/console/env/index.ts @@ -77,6 +77,11 @@ const ASSETS_PATH = `${BASE_URL}/assets/`; */ const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || ''; +/** + * Controls whether the config object in the inputs/outputs Python code snippet is automatically constructed + */ +const CODE_SNIPPET_USE_AUTO_CONFIG = process.env.CODE_SNIPPET_USE_AUTO_CONFIG || ''; + const processEnv = { NODE_ENV, PORT, @@ -86,6 +91,7 @@ const processEnv = { BASE_HREF, DISABLE_CONSOLE_ROUTE_PREFIX, MAINTENANCE_MODE, + CODE_SNIPPET_USE_AUTO_CONFIG, }; export { @@ -101,5 +107,6 @@ export { ADMIN_API, LOCAL_DEV_HOST, MAINTENANCE_MODE, + CODE_SNIPPET_USE_AUTO_CONFIG, processEnv, };