Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%load_node truncates import statements #3760

Open
natashadunstan opened this issue Mar 28, 2024 · 2 comments
Open

%load_node truncates import statements #3760

natashadunstan opened this issue Mar 28, 2024 · 2 comments
Labels
Issue: Bug Report 🐞 Bug that needs to be fixed

Comments

@natashadunstan
Copy link

natashadunstan commented Mar 28, 2024

Description

Hi, it seems to be broken when the import statement has multiple lines. My imports look like this:

from a import (
                         a,
                         b,
                         c
                         )

But in the cell that %load_node created, it got cut off at first line:

from a import (

Context

Cell couldn't be run, had to manually fix import

Steps to Reproduce

@noklam to update

  1. Create a node with similar format.
from os import (path,
                 os
                 )
  1. %load_node on that specific node
  2. See that the import statement get truncated as from os import (path,

Expected Result

Full import statement in cell

Actual Result

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

Your Environment

  • Kedro version used (pip show kedro or kedro -V): 0.19.3
  • Python version used (python -V): 3.9
  • Operating system and version: Linux
@natashadunstan natashadunstan changed the title %load_node truncates import import statements %load_node truncates import statements Mar 28, 2024
@noklam
Copy link
Contributor

noklam commented Mar 28, 2024

Thanks for reporting. I think this happens because right now we extract the import statements naively with the keywords start with either "from" or "import".

Quick thought on this is that we can add some logic to catch this, but it maybe quite fragile and still runs into edge cases.

Alternative is that we need a proper parser or look at the AST.

@astrojuanlu astrojuanlu added the Issue: Bug Report 🐞 Bug that needs to be fixed label Mar 29, 2024
@merelcht
Copy link
Member

merelcht commented Apr 8, 2024

Discussed in backlog grooming that initially we'll just fix this for the base case for the time being. It would be nice to find the edge cases eventually but for now we can stick to the basic version to get it up and running

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Bug Report 🐞 Bug that needs to be fixed
Projects
Status: No status
Development

No branches or pull requests

4 participants