From 6c1d06c2ba8b173b2e39a8396804d5fca62e084f Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 13:00:03 +0100 Subject: [PATCH 01/10] Override default_run_env instead of base_env Signed-off-by: Nok Lam Chan --- bundled/tool/lsp_server.py | 16 ++++++++-------- src/common/commands.ts | 2 +- src/extension.ts | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 7090137..2898e7f 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -115,21 +115,20 @@ def _set_project_with_workspace(self): context = session.load_context() config_loader: OmegaConfigLoader = context.config_loader # context.env is set when KEDRO_ENV or kedro run --env is set - conf_env = context.env if context.env else config_loader.base_env - base_path = str(Path(config_loader.conf_source) / conf_env) + run_env = context.env if context.env else config_loader.default_run_env except RuntimeError as e: log_for_lsp_debug(str(e)) project_metadata = None context = None config_loader = None - base_path = None + run_env = None finally: self.project_metadata = project_metadata self.context = context self.config_loader = config_loader self.dummy_catalog = self._get_dummy_catalog() - self.base_path = base_path + self.run_env = run_env def _get_dummy_catalog(self): # '**/catalog*' reads modular pipeline configs @@ -196,10 +195,11 @@ def _get_conf_paths(server: KedroLanguageServer, key): A set of configuration paths. """ - config_loader: OmegaConfigLoader = LSP_SERVER.config_loader + config_loader: OmegaConfigLoader = server.config_loader patterns = config_loader.config_patterns.get(key, []) - default_run_env = str( - Path(config_loader.conf_source) / config_loader.default_run_env + # By default is local + run_env = str( + Path(config_loader.conf_source) / server.run_env ) base_env = str(Path(config_loader.conf_source) / config_loader.base_env) @@ -209,7 +209,7 @@ def _get_conf_paths(server: KedroLanguageServer, key): # That is, if a config is found in both environment, the LSP should return the default_run_env one. # The LSP start searching in default_run_env first, if there is match it will end eagerly. - for base_path in [default_run_env, base_env]: + for base_path in [run_env, base_env]: tmp_paths = [] for pattern in patterns: for each in config_loader._fs.glob( diff --git a/src/common/commands.ts b/src/common/commands.ts index ebfd2ce..308c061 100644 --- a/src/common/commands.ts +++ b/src/common/commands.ts @@ -15,7 +15,7 @@ export async function selectEnvironment() { const envs: QuickPickItem[] = directories.map((label) => ({ label })); const result = await window.showQuickPick(envs, { - placeHolder: 'Select Kedro base environment', + placeHolder: 'Select Kedro runtime environment', }); return result; diff --git a/src/extension.ts b/src/extension.ts index f3344d4..ae272d7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -85,9 +85,9 @@ export async function activate(context: vscode.ExtensionContext): Promise traceError( 'Python interpreter missing:\r\n' + - '[Option 1] Select python interpreter using the ms-python.python.\r\n' + - `[Option 2] Set an interpreter using "${serverId}.interpreter" setting.\r\n` + - 'Please use Python 3.8 or greater.', + '[Option 1] Select python interpreter using the ms-python.python.\r\n' + + `[Option 2] Set an interpreter using "${serverId}.interpreter" setting.\r\n` + + 'Please use Python 3.8 or greater.', ); }; @@ -97,7 +97,7 @@ export async function activate(context: vscode.ExtensionContext): Promise // https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration const projectRoot = await getProjectRoot(); const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); - let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings. + let environment = 'local'; // todo: Assume base, better to take this from server as it could be changed in project settings. if (workspaceSetting.environment) { environment = workspaceSetting.environment; From 9ba5b7dd58d2a089b577fb69a23057931421c63a Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 13:34:59 +0100 Subject: [PATCH 02/10] fix comment Signed-off-by: Nok Lam Chan --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index ae272d7..4ea1353 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -97,7 +97,7 @@ export async function activate(context: vscode.ExtensionContext): Promise // https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration const projectRoot = await getProjectRoot(); const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); - let environment = 'local'; // todo: Assume base, better to take this from server as it could be changed in project settings. + let environment = 'local'; if (workspaceSetting.environment) { environment = workspaceSetting.environment; From 813f050c82216d5777d3b2911443911bca4359c4 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 13:45:31 +0100 Subject: [PATCH 03/10] fix CI Signed-off-by: Nok Lam Chan --- .github/workflows/installation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/installation.yml b/.github/workflows/installation.yml index 2ff62bc..d1930be 100644 --- a/.github/workflows/installation.yml +++ b/.github/workflows/installation.yml @@ -19,8 +19,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} - - name: Set up Python + ref: $GITHUB_BASE_REF + - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.10" From 6e4aaf3b185ffdfaeef4577832a099412f459183 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 13:56:42 +0100 Subject: [PATCH 04/10] fix CI Signed-off-by: Nok Lam Chan --- .github/workflows/installation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/installation.yml b/.github/workflows/installation.yml index d1930be..6be384d 100644 --- a/.github/workflows/installation.yml +++ b/.github/workflows/installation.yml @@ -19,7 +19,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: $GITHUB_BASE_REF + ref: ${{ inputs.branch }} - name: Set up Python uses: actions/setup-python@v5 with: From 0acfd253b0e0d06dd6a86fca771c02c94f771a30 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 14:00:23 +0100 Subject: [PATCH 05/10] fix typo Signed-off-by: Nok Lam Chan --- src/common/commands.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/common/commands.ts b/src/common/commands.ts index 5dc909d..a577609 100644 --- a/src/common/commands.ts +++ b/src/common/commands.ts @@ -93,10 +93,7 @@ export async function executeServerDefinitionCommand(lsClient: LanguageClient | viewColumn: vscode.ViewColumn.One, } ); - } - - - +} From 40f394ce69bb3c1088a0f2da2e6e6fda30426f6e Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 14:51:05 +0100 Subject: [PATCH 06/10] update environment Signed-off-by: Nok Lam Chan --- src/common/status_bar.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/status_bar.ts b/src/common/status_bar.ts index c52ed41..099b684 100644 --- a/src/common/status_bar.ts +++ b/src/common/status_bar.ts @@ -4,17 +4,17 @@ import { } from './settings'; import { getProjectRoot } from './utilities'; -export async function createStatusBar(commandName: string, serverId:string): Promise{ +export async function createStatusBar(commandName: string, serverId: string): Promise { // Create a status bar item const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); statusBarItem.command = commandName; // https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration const projectRoot = await getProjectRoot(); const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true); - let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings. + let environment = 'local'; if (workspaceSetting.environment) { - environment = workspaceSetting.environment; + environment = workspaceSetting.environment; } statusBarItem.text = `$(kedro-logo) ${environment}`; From dba8949f9a7ddc80cb1fa4840d71c103452048ca Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 22 Aug 2024 17:28:26 +0100 Subject: [PATCH 07/10] update notes Signed-off-by: Nok Lam Chan --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd6504..b54fb6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log + +# 0.2.0 +- Changed default run environment to `local` to align with Kedro. +- Changed the select environment action to update the run environment instead of base. + # 0.1.0 - Expanded pipeline discovery to support `*pipeline*.py` patterns and improved handling of nested subdirectories. - Add new extension setting `Kedro: Environment` to change the configuration environment. From aa6e7ee632acc6a102ab19b58dfd4cbf7a17af96 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Fri, 23 Aug 2024 15:31:56 +0100 Subject: [PATCH 08/10] Update status bar text Signed-off-by: Nok Lam Chan --- src/common/status_bar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/status_bar.ts b/src/common/status_bar.ts index 099b684..21b16c6 100644 --- a/src/common/status_bar.ts +++ b/src/common/status_bar.ts @@ -17,7 +17,7 @@ export async function createStatusBar(commandName: string, serverId: string): Pr environment = workspaceSetting.environment; } - statusBarItem.text = `$(kedro-logo) ${environment}`; + statusBarItem.text = `$(kedro-logo) base + ${environment}`; statusBarItem.show(); return statusBarItem; } From bdae5ead1741d2c1243ddab47c1a1a265e3fb17d Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Fri, 23 Aug 2024 15:33:58 +0100 Subject: [PATCH 09/10] filter out base env Signed-off-by: Nok Lam Chan --- src/common/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/commands.ts b/src/common/commands.ts index e3e2330..a6b4d05 100644 --- a/src/common/commands.ts +++ b/src/common/commands.ts @@ -14,7 +14,7 @@ export async function selectEnvironment() { .filter((dirent) => dirent.isDirectory()) .map((dirent) => dirent.name); - const envs: QuickPickItem[] = directories.map((label) => ({ label })); + const envs: QuickPickItem[] = directories.filter(dir => dir !== 'base').map((label) => ({ label })); const result = await window.showQuickPick(envs, { placeHolder: 'Select Kedro runtime environment', From ed6ce528d246c5596ddfaabc714d106a41a46457 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Fri, 23 Aug 2024 15:36:03 +0100 Subject: [PATCH 10/10] update changelog Signed-off-by: Nok Lam Chan --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b54fb6d..336b22a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ # 0.2.0 -- Changed default run environment to `local` to align with Kedro. -- Changed the select environment action to update the run environment instead of base. +- `Select Environment` actions now update the run environment instead of base. +- Modified status bar to show both environments, i.e.`base + local`, and `base` is no longer selectable. # 0.1.0 - Expanded pipeline discovery to support `*pipeline*.py` patterns and improved handling of nested subdirectories.