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

Deploy Action fails with ModuleNotFoundError: No module named 'https://github' #936

Closed
Attol8 opened this issue Aug 25, 2022 · 9 comments
Closed
Labels
bug Something isn't working

Comments

@Attol8
Copy link

Attol8 commented Aug 25, 2022

Hi, I have updated my library https://github.com/Attol8/istatapi to use nbdev v2. I keep having a fail in the deploy.yaml github Action. I do not know how to solve this as nbdev_preview works fine locally and also nbdev_prepare.

Specifically I get an error saying ModuleNotFoundError: No module named 'https://github' from nbdev/doclinks.py The error is the following.

Unpacking quarto (1.1.75) ...
Setting up quarto (1.1.75) ...
pandoc -o README.md
  to: gfm+footnotes+tex_math_dollars-yaml_metadata_block
  standalone: true
  default-image-extension: png
  
metadata
  description: Python API wrapper for ISTAT (The Italian National Institute of Statistics)
  title: ISTATAPI
  
Output created: _docs/README.md

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/IPython/core/formatters.py", line 222, in catch_format_error
    r = method(self, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/IPython/core/formatters.py", line 343, in __call__
    return method()
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/showdoc.py", line 166, in _repr_markdown_
    src = NbdevLookup().code(self.fn)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/doclinks.py", line 204, in code
    line = _lineno(sym, py)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/doclinks.py", line 149, in _lineno
    def _lineno(sym, fname): return _get_exps(fname).get(sym.rpartition('.')[2], None) if fname else None
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/doclinks.py", line 140, in _get_exps
    mf = _find_mod(mod)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/doclinks.py", line 135, in _find_mod
    loc = Path(importlib.util.find_spec(mp).origin).parent
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/importlib/util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'https://github'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.6/x64/bin/nbdev_filter", line 33, in <module>
    sys.exit(load_entry_point('nbdev==2.2.7', 'console_scripts', 'nbdev_filter')())
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/fastcore/script.py", line 117, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/cli.py", line 64, in nbdev_filter
    with redirect_stdout(dn): filt.nb_proc(nb).process()
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/process.py", line 122, in process
    for proc in self.procs: self._proc(proc)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/process.py", line 115, in _proc
    for cell in self.nb.cells: self._process_cell(proc, cell)
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/process.py", line 106, in _process_cell
    if callable(proc) and not _is_direc(proc): cell = opt_set(cell, proc(cell))
  File "/opt/hostedtoolcache/Python/3.10.6/x64/lib/python3.10/site-packages/nbdev/processors.py", line 290, in __call__
    if self.k.exc: raise Exception(f"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\n{cell.source}") from self.k.exc[1]
Exception: Error in notebook: Base in cell 5 :
#|output: asis
#| echo: false
show_doc(ISTAT)
Error: Process completed with exit code 1.

Can anybody help?

@jph00 jph00 changed the title Deploy Action keeps failing Deploy Action fails with ModuleNotFoundError: No module named 'https://github' Aug 26, 2022
@jph00 jph00 added the bug Something isn't working label Aug 26, 2022
@jph00
Copy link
Member

jph00 commented Aug 26, 2022

Fixed in master. Will do a release now.

@jph00 jph00 closed this as completed Aug 26, 2022
@Attol8
Copy link
Author

Attol8 commented Aug 26, 2022

Thanks Jeremy @jph00 , that was so fast!

I am not sure if you already released it, but I still get another error in the same spot:

AttributeError: 'NoneType' object has no attribute 'origin'

@jph00
Copy link
Member

jph00 commented Aug 26, 2022

Can you provide a full stack trace and check you've got fastcore and nbdev installed from master?

@jph00
Copy link
Member

jph00 commented Aug 26, 2022

In the meantime I added a check for this so it shouldn't give an error

@Attol8
Copy link
Author

Attol8 commented Aug 28, 2022

Hi @jph00. I installed nbdev and fastcore from master and I still get the error described above. I believe the error comes from the function show_doc. You can also reproduce it by running this notebook from my library https://github.com/Attol8/istatapi/

Here is the full trace.



---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/anaconda3/lib/python3.9/site-packages/IPython/core/formatters.py:707, in PlainTextFormatter.__call__(self, obj)
    700 stream = StringIO()
    701 printer = pretty.RepresentationPrinter(stream, self.verbose,
    702     self.max_width, self.newline,
    703     max_seq_length=self.max_seq_length,
    704     singleton_pprinters=self.singleton_printers,
    705     type_pprinters=self.type_printers,
    706     deferred_pprinters=self.deferred_printers)
--> 707 printer.pretty(obj)
    708 printer.flush()
    709 return stream.getvalue()

File ~/anaconda3/lib/python3.9/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj)
    407                         return meth(obj, self, cycle)
    408                 if cls is not object \
    409                         and callable(cls.__dict__.get('__repr__')):
--> 410                     return _repr_pprint(obj, self, cycle)
    412     return _default_pprint(obj, self, cycle)
    413 finally:

File ~/anaconda3/lib/python3.9/site-packages/IPython/lib/pretty.py:778, in _repr_pprint(obj, p, cycle)
    776 """A pprint that just redirects to the normal repr function."""
    777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
    779 lines = output.splitlines()
    780 with p.group():

File ~/anaconda3/lib/python3.9/site-packages/nbdev/showdoc.py:166, in BasicMarkdownRenderer._repr_markdown_(self)
    164 def _repr_markdown_(self):
    165     doc = '---\n\n'
--> 166     src = NbdevLookup().code(self.fn)
    167     if src: doc += _ext_link(src, 'source', 'style="float:right; font-size:smaller"') + '\n\n'
    168     h = '#'*self.title_level

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:204, in NbdevLookup.code(self, sym)
    202 if not isinstance(res, tuple): return None
    203 _,py,gh = res
--> 204 line = _lineno(sym, py)
    205 return f'{gh}#L{line}'

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:149, in _lineno(sym, fname)
--> 149 def _lineno(sym, fname): return _get_exps(fname).get(sym.rpartition('.')[2], None) if fname else None

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:140, in _get_exps(mod)
    138 @lru_cache(None)
    139 def _get_exps(mod):
--> 140     mf = _find_mod(mod)
    141     txt = mf.read_text()
    142     _def_types = ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:135, in _find_mod(mod)
    133 def _find_mod(mod):
    134     mp,_,mr = mod.rpartition('/')
--> 135     loc = Path(importlib.util.find_spec(mp).origin).parent
    136     return loc/mr

File ~/anaconda3/lib/python3.9/importlib/util.py:94, in find_spec(name, package)
     92 parent_name = fullname.rpartition('.')[0]
     93 if parent_name:
---> 94     parent = __import__(parent_name, fromlist=['__path__'])
     95     try:
     96         parent_path = parent.__path__

ModuleNotFoundError: No module named 'https://github'

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/anaconda3/lib/python3.9/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     method = get_real_method(obj, self.print_method)
    342     if method is not None:
--> 343         return method()
    344     return None
    345 else:

File ~/anaconda3/lib/python3.9/site-packages/nbdev/showdoc.py:166, in BasicMarkdownRenderer._repr_markdown_(self)
    164 def _repr_markdown_(self):
    165     doc = '---\n\n'
--> 166     src = NbdevLookup().code(self.fn)
    167     if src: doc += _ext_link(src, 'source', 'style="float:right; font-size:smaller"') + '\n\n'
    168     h = '#'*self.title_level

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:204, in NbdevLookup.code(self, sym)
    202 if not isinstance(res, tuple): return None
    203 _,py,gh = res
--> 204 line = _lineno(sym, py)
    205 return f'{gh}#L{line}'

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:149, in _lineno(sym, fname)
--> 149 def _lineno(sym, fname): return _get_exps(fname).get(sym.rpartition('.')[2], None) if fname else None

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:140, in _get_exps(mod)
    138 @lru_cache(None)
    139 def _get_exps(mod):
--> 140     mf = _find_mod(mod)
    141     txt = mf.read_text()
    142     _def_types = ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef

File ~/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py:135, in _find_mod(mod)
    133 def _find_mod(mod):
    134     mp,_,mr = mod.rpartition('/')
--> 135     loc = Path(importlib.util.find_spec(mp).origin).parent
    136     return loc/mr

File ~/anaconda3/lib/python3.9/importlib/util.py:94, in find_spec(name, package)
     92 parent_name = fullname.rpartition('.')[0]
     93 if parent_name:
---> 94     parent = __import__(parent_name, fromlist=['__path__'])
     95     try:
     96         parent_path = parent.__path__

ModuleNotFoundError: No module named 'https://github'

@jph00
Copy link
Member

jph00 commented Aug 28, 2022

To fix this, please run nbdev_prepare

@Attol8
Copy link
Author

Attol8 commented Aug 28, 2022

I already tried but with v2.2.9 of nbdev_prepare fails with

Traceback (most recent call last):
  File "/home/jacopo/anaconda3/bin/nbdev_prepare", line 8, in <module>
    sys.exit(prepare())
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/fastcore/script.py", line 117, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/quarto.py", line 161, in prepare
    nbdev_export.__wrapped__()
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/doclinks.py", line 124, in nbdev_export
    for f in files: nb_export(f)
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/export.py", line 49, in nb_export
    nb.process()
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/process.py", line 122, in process
    for proc in self.procs: self._proc(proc)
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/process.py", line 115, in _proc
    for cell in self.nb.cells: self._process_cell(proc, cell)
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/process.py", line 105, in _process_cell
    if f: self._process_comment(f, cell, cmd)
  File "/home/jacopo/anaconda3/lib/python3.9/site-packages/nbdev/process.py", line 111, in _process_comment
    return proc(cell, *args)
TypeError: _default_exp_() takes 3 positional arguments but 6 were given

@jph00
Copy link
Member

jph00 commented Aug 29, 2022

That's because in your 03_retrieval notebook you have this line:

#| default_exp retrievalfrom istatapi.discovery import DataSet

It appears you accidentally combined two lines there.

@Attol8
Copy link
Author

Attol8 commented Aug 29, 2022

All tests pass now, with wonderful docs from nbdev v2 live! Sorry for missing that line, my bad! And thanks for all the help and the good work you're doing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants