Skip to content

[BUG]: Account for notebook exported with .py extension #3652

@JCZuurmond

Description

@JCZuurmond

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The NotebookLoader accounts for notebooks being referred without extension, like %run child_notebook, but being exported to .py files, [see this](

def resolve(self, path_lookup: PathLookup, path: Path) -> Path | None:
"""If the path is a Python file, return the path to the Python file. If the path is neither,
return None."""
# check current working directory first
absolute_path = path_lookup.cwd / path
absolute_path = absolute_path.resolve()
if is_a_notebook(absolute_path):
return absolute_path
# When exported through Git, notebooks are saved with a .py extension. So check with and without extension
candidates = (path, self._adjust_path(path)) if not path.suffix else (path,)
for candidate in candidates:
a_path = path_lookup.resolve(candidate)
if not a_path:
continue
return a_path
return None
.

Expected Behavior

The is_a_notebook does NOT account for the additional .py extension. Which could - I think but am not sure that this is the case - lead to bugs or unfound notebook/files

Steps To Reproduce

No response

Cloud

AWS

Operating System

macOS

Version

latest via Databricks CLI

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions