Skip to content

Commit

Permalink
Merge pull request #75 from kedro-org/noklam/bug-env
Browse files Browse the repository at this point in the history
Override default_run_env instead of base_env
  • Loading branch information
noklam authored Aug 23, 2024
2 parents 8d7d511 + 85dd521 commit 7b5b2a8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log


# 0.2.0
- `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.
- Add new extension setting `Kedro: Environment` to change the configuration environment.
Expand Down
16 changes: 8 additions & 8 deletions bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ 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 base environment',
placeHolder: 'Select Kedro runtime environment',
});

return result;
Expand Down
8 changes: 4 additions & 4 deletions src/common/status_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import {
} from './settings';
import { getProjectRoot } from './utilities';

export async function createStatusBar(commandName: string, serverId:string): Promise<vscode.StatusBarItem>{
export async function createStatusBar(commandName: string, serverId: string): Promise<vscode.StatusBarItem> {
// 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}`;
statusBarItem.text = `$(kedro-logo) base + ${environment}`;
statusBarItem.show();
return statusBarItem;
}

0 comments on commit 7b5b2a8

Please sign in to comment.