kedro-org / vscode-kedro

Kedro extension for VSCode including LSP and other features
https://marketplace.visualstudio.com/items?itemName=kedro.Kedro
Apache License 2.0
18 stars 2 forks source link

VS Code extension disable hook fail to initialise when use with other Kedro plugin #69

Open noklam opened 2 months ago

noklam commented 2 months ago

Description

Split out from #51.

Part of settings.py:

from kedro_pandera.framework.config.resolvers import (  # noqa: E402
    resolve_dataframe_model,
    resolve_interpolated_yaml_schema,
    resolve_yaml_schema,
)

CONFIG_LOADER_ARGS = {
    "base_env": "base",
    "default_run_env": "local",
    "custom_resolvers": {
        # For vscode-kedro extension to work we need to import kedro_pandera resolvers manually
        "pa.dict": resolve_yaml_schema,
        "pa.yaml": resolve_interpolated_yaml_schema,
        "pa.python": resolve_dataframe_model,
    },
}

which is basically this - https://github.com/Galileo-Galilei/kedro-pandera/blob/4fa5ca3c8bbb31f2fcbed00e3dbcd03594ff4a01/kedro_pandera/framework/hooks/pandera_hook.py#L46

The error is thrown during initialization of the extension

Context

The reason for this to happen is because VS Code extension disable all the hooks. The failure is because the kedro-pandera resolver is registered via hook (and is now missing), thus the initialisation step fails when we try to get catalog config.

An example can be found here:

example_iris_data:
  type: pandas.CSVDataset
  filepath: data/01_raw/iris.csv
  metadata:
    pandera:
      schema: ${pa.yaml:_example_iris_data_schema}

Steps to Reproduce

Checklist

Expected Result

Actual Result

-- If you received an error, place it here.
-- Separate them if you have more than one.

Your Environment

Calychas commented 2 months ago

Answering https://github.com/kedro-org/vscode-kedro/issues/51#issuecomment-2293776858:

Just need the import error to go away ;). Any highlighting and Go to definition of a schema would be a major + though