Skip to content

Syntax error prevents init from running through #265

@falexwolf

Description

@falexwolf

This here is quite unfortunate. It should only be run if one actually wants to parse pypackages and/or should log a clear error message.

---------------------------------------------------------------------------
SyntaxError                               Traceback (most recent call last)
File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/lamindb/_context.py:271, in context._track_notebook(cls, filepath, pypackage, editor)
    270 try:
--> 271     metadata, needs_init = nbproject.header(
    272 pypackage=pypackage,
    273 filepath=notebook_pathiffilepathisNoneelsefilepath,
    274 env=_envifeditorisNoneelseeditor,
    275 metadata_only=True,
    276 )
    277     # this contains filepath if the header was run successfully

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/nbproject/_header.py:141, in header(parent, pypackage, filepath, env, metadata_only)
    140 metadata = nb.metadata["nbproject"]
--> 141 table = table_metadata(metadata,nb,time_run)
    142 if not metadata_only:

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/nbproject/dev/_metadata_display.py:163, in table_metadata(metadata, notebook, time_run)
    162     add_pkgs = None
--> 163 dep_live = dm.pypackage(infer_pypackages(notebook,add_pkgs,pin_versions=True))
    165 # simplify display when stored & live pypackages match

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/nbproject/dev/_pypackage.py:98, in infer_pypackages(content, add_pkgs, pin_versions)
     96     cell_source = magics_re.sub(r"\1", cell_source)
---> 98 for imp in cell_imports(cell_source):
     99     if imp in std_libs:  # type: ignore

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/nbproject/dev/_pypackage.py:40, in cell_imports(cell_source)
     37 def cell_imports(cell_source: str):
     38     # based on the package https://github.com/bndr/pipreqs for python scripts
     39     # parses python import statements in the code cells
---> 40     tree = parse(cell_source)
     41     for node in walk(tree):

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/ast.py:50, in parse(source, filename, mode, type_comments, feature_version)
     49 # Else it should be an int giving the minor version for 3.x.
---> 50 return compile(source,filename,mode,flags,
     51 _feature_version=feature_version)

SyntaxError: invalid syntax (<unknown>, line 6)

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
Cell In[2], line 4
      1 import lamindb as ln
      2 import pytest
----> 4 ln.track()

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/lamindb/_context.py:161, in context._track(cls, transform, new_run, notebook_path, pypackage, editor)
    158 import lamindb as ln
    160 if is_run_from_ipython and transform is None:
--> 161     cls._track_notebook(
    162 pypackage=pypackage,
    163 filepath=notebook_path,
    164 editor=editor,
    165 )
    166 elif transform is None:
    167     raise ValueError("Pass `transform` to .track()!")

File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/lamindb/_context.py:285, in context._track_notebook(cls, filepath, pypackage, editor)
    [279](https://github.com/laminlabs/lamindb/actions/runs/5153002144/jobs/9279708838#step:16:280)     except Exception:
    280         nbproject_failed_msg = (
    281             "Auto-retrieval of notebook name & title failed.\nPlease paste"
    282             " error at: https://github.com/laminlabs/nbproject/issues/new"
    283             " \n\nFix: Run `ln.track(ln.Transform(name='My notebook'))`"
    284         )
--> 285         raise RuntimeError(nbproject_failed_msg)
    287 import lamindb as ln
    289 if needs_init:

RuntimeError: Auto-retrieval of notebook name & title failed.
Please paste error at: https://github.com/laminlabs/nbproject/issues/new 

Fix: Run `ln.track(ln.Transform(name='My notebook'))`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions