vericast / nbconflux

nbconflux converts Jupyter Notebooks to Atlassian Confluence pages
BSD 3-Clause "New" or "Revised" License
117 stars 33 forks source link

The 'exporter' trait of a ConfluencePreprocessor instance expected a ConfluenceExporter, not the NoneType None. #46

Open stephwen-tempus opened 2 years ago

stephwen-tempus commented 2 years ago

Hi,

I get the following error when using the _notebook_topage function.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in get(self, obj, cls)
    534         try:
--> 535             value = obj._trait_values[self.name]
    536         except KeyError:

KeyError: 'exporter'

During handling of the above exception, another exception occurred:

TraitError                                Traceback (most recent call last)
<ipython-input-2-9a4929330a3c> in <module>
      8 url = "xxxxx"
      9 nb_path = "xxxxx"
---> 10 html, resources = nbconflux.notebook_to_page(nb_path, url, CONFLUENCE_USERNAME, CONFLUENCE_PASSWORD)
     11 

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconflux/api.py in notebook_to_page(notebook_file, confluence_url, username, password, generate_toc, attach_ipynb, enable_style, enable_mathjax, extra_labels)
     55 
     56     exporter = ConfluenceExporter(c)
---> 57     result = exporter.from_filename(notebook_file)
     58     print('Updated', confluence_url)
     59     return result

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconflux/exporter.py in from_filename(self, filename, *args, **kwargs)
    345         # so stash it here for later lookup
    346         self.notebook_filename = filename
--> 347         return super(ConfluenceExporter, self).from_filename(filename, *args, **kwargs)

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/exporter.py in from_filename(self, filename, resources, **kw)
    179 
    180         with io.open(filename, encoding='utf-8') as f:
--> 181             return self.from_file(f, resources=resources, **kw)
    182 
    183 

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/exporter.py in from_file(self, file_stream, resources, **kw)
    197 
    198         """
--> 199         return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
    200 
    201 

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconflux/exporter.py in from_notebook_node(self, nb, resources, **kw)
    307 
    308         # Convert the notebook to Confluence storage format, which is XHTML-like
--> 309         html, resources = super(ConfluenceExporter, self).from_notebook_node(nb, resources, **kw)
    310 
    311         # Update the page with the new content

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/html.py in from_notebook_node(self, nb, resources, **kw)
    127         highlight_code = self.filters.get('highlight_code', Highlight2HTML(pygments_lexer=lexer, parent=self))
    128         self.register_filter('highlight_code', highlight_code)
--> 129         return super().from_notebook_node(nb, resources, **kw)
    130 
    131     def _init_resources(self, resources):

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py in from_notebook_node(self, nb, resources, **kw)
    372             preprocessors and filters.
    373         """
--> 374         nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
    375         resources.setdefault('raw_mimetypes', self.raw_mimetypes)
    376         resources['global_content_filter'] = {

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/exporter.py in from_notebook_node(self, nb, resources, **kw)
    141 
    142         # Preprocess
--> 143         nb_copy, resources = self._preprocess(nb_copy, resources)
    144 
    145         return nb_copy, resources

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/exporters/exporter.py in _preprocess(self, nb, resources)
    316         # to each preprocessor
    317         for preprocessor in self._preprocessors:
--> 318             nbc, resc = preprocessor(nbc, resc)
    319             try:
    320                 nbformat.validate(nbc, relax_add_props=True)

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconvert/preprocessors/base.py in __call__(self, nb, resources)
     45             self.log.debug("Applying preprocessor: %s",
     46                            self.__class__.__name__)
---> 47             return self.preprocess(nb, resources)
     48         else:
     49             return nb, resources

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/nbconflux/preprocessor.py in preprocess(self, nb, resources)
     58         # names and versions.
     59         path = ('/rest/api/content/{page_id}/child/attachment?expand=version'
---> 60                 .format(page_id=self.exporter.page_id))
     61         resources['attachments'] = {}
     62         while path:

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in __get__(self, obj, cls)
    573             return self
    574         else:
--> 575             return self.get(obj, cls)
    576 
    577     def set(self, obj, value):

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in get(self, obj, cls)
    546                 )
    547             with obj.cross_validation_lock:
--> 548                 value = self._validate(obj, default)
    549             obj._trait_values[self.name] = value
    550             obj._notify_observers(Bunch(

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in _validate(self, obj, value)
    608             return value
    609         if hasattr(self, 'validate'):
--> 610             value = self.validate(obj, value)
    611         if obj._cross_validation_lock is False:
    612             value = self._cross_validate(obj, value)

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in validate(self, obj, value)
   1843             return value
   1844         else:
-> 1845             self.error(obj, value)
   1846 
   1847     def info(self):

~/miniconda3/envs/jupyterlab/lib/python3.8/site-packages/traitlets/traitlets.py in error(self, obj, value, error, info)
    688                     e = "The '%s' trait expected %s, not %s." % (
    689                         self.name, self.info(), describe("the", value))
--> 690                 raise TraitError(e)
    691 
    692     def get_metadata(self, key, default=None):

TraitError: The 'exporter' trait of a ConfluencePreprocessor instance expected a ConfluenceExporter, not the NoneType None.

I get a similar error when running nbconflux from the command line.