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

Syntax error prevents init from running through #265

Open
falexwolf opened this issue Jun 2, 2023 · 2 comments
Open

Syntax error prevents init from running through #265

falexwolf opened this issue Jun 2, 2023 · 2 comments

Comments

@falexwolf
Copy link
Member

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'))`
@Koncopd
Copy link
Member

Koncopd commented Jun 2, 2023

Maybe we should even omit the parsing in track, as they are not shown anyways?

@falexwolf
Copy link
Member Author

Yes, that could be the default. But I'd also really like them to be shown by default if everything works out well!

Just in form of a text logging output that blends in an aesthetically nice way with the other logging that's shown.

The HTML display and the logging otherwise clash, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants