From 0992af372523899bd228734533efec0996b81754 Mon Sep 17 00:00:00 2001 From: Nok Date: Fri, 30 Aug 2024 12:53:35 +0000 Subject: [PATCH 1/5] lsClient has been remove from webview. clean up Signed-off-by: Nok --- bundled/tool/lsp_server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 0c9062c..7178c69 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -216,7 +216,13 @@ def _get_conf_paths(server: KedroLanguageServer, key): ): if not config_loader._is_hidden(each): tmp_paths.append(Path(each)) - paths = paths + list(set(tmp_paths)) + + # Reuse OmegaConfigLoader logic as much as possible so we don't need to write our tests here + deduplicated_paths = set(tmp_paths) + valid_config_paths = [ + path for path in deduplicated_paths if config_loader._is_valid_config_path(path) + ] + paths = paths + list(valid_config_paths) return paths From bab39a07df31d6c7f4289338af7ea1d91740a669 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Tue, 17 Sep 2024 16:16:29 +0100 Subject: [PATCH 2/5] split word properly Signed-off-by: Nok Lam Chan --- bundled/tool/lsp_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 7178c69..19200c8 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -231,7 +231,8 @@ def _get_param_location( ) -> Optional[Location]: words = word.split("params:") if len(words) > 1: - param = words[0] # Top key + words = words[1].split(".") # ["params:", "a.b.c"] + param = words[0] # Top level key ["a","b","c"] else: return None log_to_output(f"Attempt to search `{param}` from parameters file") From 8079b9efa3662bb25a0a3e07e845be7d57ed5f37 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Tue, 17 Sep 2024 16:16:53 +0100 Subject: [PATCH 3/5] filter pipelines properly Signed-off-by: Nok Lam Chan --- bundled/tool/lsp_server.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 19200c8..5e25b7e 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -83,6 +83,7 @@ ) from pygls.server import LanguageServer + class KedroLanguageServer(LanguageServer): """Store Kedro-specific information in the language server.""" @@ -197,9 +198,7 @@ def _get_conf_paths(server: KedroLanguageServer, key): config_loader: OmegaConfigLoader = server.config_loader patterns = config_loader.config_patterns.get(key, []) # By default is local - run_env = str( - Path(config_loader.conf_source) / server.run_env - ) + run_env = str(Path(config_loader.conf_source) / server.run_env) base_env = str(Path(config_loader.conf_source) / config_loader.base_env) # Extract from OmegaConfigLoader source code @@ -220,18 +219,18 @@ def _get_conf_paths(server: KedroLanguageServer, key): # Reuse OmegaConfigLoader logic as much as possible so we don't need to write our tests here deduplicated_paths = set(tmp_paths) valid_config_paths = [ - path for path in deduplicated_paths if config_loader._is_valid_config_path(path) + path + for path in deduplicated_paths + if config_loader._is_valid_config_path(path) ] paths = paths + list(valid_config_paths) return paths -def _get_param_location( - server: KedroLanguageServer, word: str -) -> Optional[Location]: +def _get_param_location(server: KedroLanguageServer, word: str) -> Optional[Location]: words = word.split("params:") if len(words) > 1: - words = words[1].split(".") # ["params:", "a.b.c"] + words = words[1].split(".") # ["params:", "a.b.c"] param = words[0] # Top level key ["a","b","c"] else: return None @@ -540,11 +539,15 @@ def log_for_lsp_debug(msg: str): def _is_pipeline(uri): - from pathlib import Path - - filename = Path(uri).name + path = Path(uri) + filename = path.name if "pipeline" in str(filename): return True + # Inside pipelines folder + if ( + "pipelines" in path.parts + ): # [file:, Users, dummy, pipelines, pipeline_name, file.py] + return True return False @@ -559,10 +562,10 @@ def definition_from_flowchart(ls, word): result = definition(LSP_SERVER, params=None, word=word) return result + @LSP_SERVER.command("kedro.getProjectData") def get_project_data_from_viz(lsClient): - """Get project data from kedro viz - """ + """Get project data from kedro viz""" from kedro_viz.server import load_and_populate_data from kedro_viz.api.rest.responses import get_kedro_project_json_data @@ -577,6 +580,7 @@ def get_project_data_from_viz(lsClient): print("Execution completed.") return data + ### End of kedro-lsp From 5a0718e9189f27a2e05737ca952bca60e40a59c1 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Tue, 17 Sep 2024 16:27:18 +0100 Subject: [PATCH 4/5] fix navigation for namespace catalog Signed-off-by: Nok Lam Chan --- bundled/tool/lsp_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index 5e25b7e..fcd383e 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -290,7 +290,7 @@ def _query_parameter(document, word=None): def _query_catalog(document, word=None): if not word: - word = document.word_at_position(params.position) + word = document.word_at_position(params.position, RE_START_WORD, RE_END_WORD) catalog_paths = _get_conf_paths(server, "catalog") log_for_lsp_debug(f"Attempt to search `{word}` from catalog") log_for_lsp_debug(f"{catalog_paths=}") @@ -331,7 +331,7 @@ def _query_catalog(document, word=None): # If no result, return current location # This is a VSCode specific logic called Alternative Definition Command # By default, it triggers Go to Reference so it supports using mouse click for both directions - # from pipline to config and config to pipeline + # from pipeline to config and config to pipeline uri = params.text_document.uri pos = params.position curr_pos = Position(line=pos.line, character=pos.character) From e95e3b9c5c23ed8c62950e35f7b4dada81054af3 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Tue, 3 Sep 2024 11:55:35 +0100 Subject: [PATCH 5/5] add consent script Signed-off-by: Nok Lam Chan --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dbf8ac..8dfee9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - `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. - Fixed a minor bug where status bar showing incorrect text, i.e. it shows `prod` insteadf of `base + prod`. +- Fixed a bug where namespace dataset navigation is not working properly +- Fixed a bug where navigating on nested parameters should go to the top level key. # 0.1.0 - Expanded pipeline discovery to support `*pipeline*.py` patterns and improved handling of nested subdirectories. diff --git a/package.json b/package.json index 7cf840e..9caaa1f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "Kedro", "displayName": "Kedro", "description": "A Kedro VSCode Extension.", - "version": "0.2.0-rc0", + "version": "0.2.0-rc1", "preview": false, "serverInfo": { "name": "Kedro",