vscode-kedro
The extension integrates Kedro projects with Visual Studio Code, providing features like enhanced code navigation and autocompletion for seamless development.
If you encounter issue, report it in Github or Slack, we will try to fix ASAP.
Requirements
- VS Code 1.64.0 or greater
- Python extension for VS Code
- Kedro Project >= 0.19
How to use this extension
- Install
Kedro
from the extension
- Select the correct Python interpreter that you use to run the Kedro project with the
> Python: select interpreter
command
- Open your VSCode workspace at the root of the Kedro project.
p.s. If you can kedro run
with the environment, you are good to go.
The extension requires bootstrap_project
in Kedro, you need to make sure you can do kedro run
without getting any immediate error, otherwise you may get a server panic error.
Feature
Go to Definition from pipeline.py to configuration files
Use Cmd
(Mac)/ Ctrl
(Window) + Click
or F12
to trigger Go to Definition
Go to Reference from configuration files to pipeline.py
Cmd
or Ctrl
(Window) + Click
on the definition.
- Use
Find Reference
- Use the shortcut
Shift
+ F12
Note: You can find pipeline reference in all the python files under <package_name>/pipelines
- pipelines
- sub_pipeline
- pipeline_data_processing.py
- sub_pipeline_1
- pipeline_data_processing_1.py
Autocompletion in Python
Type "
in any pipeline.py
and it should trigger the autocompletion list.
Schema Validation
Hover
Just hover your mouse over any params:
, datasets or hit the command Show or Focus Hover
To navigate between the flowchart and the code editor in Kedro-Viz:
Navigate to Node Functions:
Click on a node in the Kedro-Viz flowchart, and it will automatically navigate to the corresponding node function in your code.
Navigate to DataCatalog:
Clicking on a data node in the flowchart will open the corresponding dataset in the Data Catalog.
Settings
Change Configuration Environment
By default, the extension references the configuration loader's base_env (typically base
). To change the directory where the extension looks for configurations, the extension provides 3 different ways to do this:
- Click on the Kedro Icon in the status bar (bottom right)
- Use Command (
Cmd
+ Shift
+ P
) and choose kedro: Select Environment
- Change default environment
How to restart a server if there are error
Click Output
and select Kedro
from the dropdown list. It may gives you some hints and report back if you think this is a bug.
Hit Cmd
+ Shift
+ P
to open the VSCode command, look for kedro: restart server
in case it's panic.
Assumptions
Single Kedro Project
The extension need to identify where is the Kedro project. It assumes the root of the workspace is a Kedro project, i.e. open the project where the pyproject.toml
is.
Currently, the extension assume the source of configuration is in the base_env
defined by the config loader (if you didn't speficy, usually it is conf/base
).
This mean that if the configuration is overrided by the default_run_env
(usually it is local
), the extension may fails to resolve to the correct location.
Pipeline Discovery
The extension follows Kedro pipeline autodiscovery mechanism. It means that in general it is looking for modular pipelines structure, i.e. <src/package/pipelines/<pipeline>
. It can be visualised as follows:
.
├── conf
│ ├── base
│ └── local
├── notebooks
├── src
│ └── demo
│ ├── pipelines
│ ├── first_pipeline
│ └── second_pipeline
Visualisation with Kedro-Viz
To visualize your Kedro project using Kedro-Viz in Visual Studio Code, follow these steps:
Open the Command Palette:
Press Cmd
+ Shift
+ P
(on macOS) or Ctrl
+ Shift
+ P
(on Windows/Linux).
Run Kedro-Viz:
Type kedro: Run Kedro Viz
and select the command.
This will launch Kedro-Viz and display your pipeline visually within the extension.
Note: To update the Kedro-Viz flowchart after making any changes to your Kedro project, please hit Cmd
+ Shift
+ P
to open the VSCode command and look for kedro: restart server
.
Troubleshooting
In VSCode, you can check the Output
tab next to your terminal and select Kedro
to read the logs.
You can either run the Kedro: Show logs
command or click Output
and select Kedro
from the dropdown list. It may gives you some hints and report back if you think this is a bug.