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
17 stars 2 forks source link

Clicking on a dataset node in kedro-viz doesn't navigate to code when the dataset is defined as dataset factory #122

Open Calychas opened 4 weeks ago

Calychas commented 4 weeks ago

Description

Clicking on a dataset node in kedro-viz doesn't navigate to code.

Steps to Reproduce

In my case

  1. Run kedro-viz via the extension
  2. Click on dataset node that is defined by dataset factory

Checklist

Expected Result

Navigated to the code

Actual Result

Nothing happens and errors in logs:

2024-09-23 13:45:42.369 [info] [Trace - 13:45:42] Sending request 'workspace/executeCommand - (4)'.
2024-09-23 13:45:42.437 [info] [Trace - 13:45:42] Received response 'workspace/executeCommand - (4)' in 68ms. Request failed: AttributeError: 'NoneType' object has no attribute 'text_document' (-32603).
2024-09-23 13:45:42.437 [info] [Error - 13:45:42] Request workspace/executeCommand failed.
2024-09-23 13:45:42.437 [info]   Message: AttributeError: 'NoneType' object has no attribute 'text_document'
  Code: -32603 
[object Object]

Your Environment

noklam commented 4 weeks ago

@Calychas Thanks for trying this in pre-release already! Does clicking on any nodes lead to navigation? Or is it a specific type of nodes? Try clicking on a dataset, or a function node.

Can I also ask what's the path of that pipeline/node file stored?

noklam commented 4 weeks ago

Saying this because we have a rather simple logic to search for functions: filePattern = '**/pipelines/**/*.py';

Calychas commented 4 weeks ago

@noklam hey! Functions actually work -> it navigates me to the code.

It turns out I have only problems with datasets -> nothing happens (no navigation)

Can I also ask what's the path of that pipeline/node file stored? Could find a dataset node on which the navigation works. An example of one where it doesn't:

"{group_class}.payload_raw":
  type: json.JSONDataset
  filepath: data/01_raw/{group_class}/model_payload_{group_class}.json
  metadata:
    kedro-viz:
      layer: raw
Calychas commented 4 weeks ago

I think I managed to pinpoint the issue -> dataset factories

Specifying it this way fixes navigation:

na.payload_raw:
  type: json.JSONDataset
  filepath: data/01_raw/na/model_payload_na.json
  metadata:
    kedro-viz:
      layer: raw
noklam commented 4 weeks ago

@Calychas Thanks for reporting! factory indeed is not working yet since it is not "explicitly" defined in catalog. I have idea how to add support for dataset factory.

I will update the issue to reflect this is a specific issue about Dataset Factory and make it a feature request, hope that is fine!

noklam commented 4 weeks ago

My current idea is keeping existing resolution logic, but add a new factory pattern logic.

  1. Search for exact match, since this has higher priority
  2. If not found, try to match pattern to see if it matches any pattern

Alternatively: The extension can eagerly resolve all the pattern (a tricky part here is the resolution logic depends on the pipeline, maybe we can assume default as a starting point). Then the rest is just mapping which dataset was generated from pattern, and re-direct the dataset definition to the pattern entry.