vericast / nbconflux

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

TraitError when attempting to convert ipynb to confluence page #41

Open boleszek opened 3 years ago

boleszek commented 3 years ago

I'm having trouble using this package because of a traitlets.traitlets.TraitError which I can't fix. I have already installed the relevant packages, created an Atlassian API key, set CONFLUENCE_USERNAME & CONFLUENCE_PASSWORD environment variables, and created a blank Atlassian webpage.

My command is

nbconflux "/Users/bo.osinski/Documents/imaging-research/bo/fragment-analyzer/fragmentation_data_EDA.ipynb" "https://tempuslabs.atlassian.net/wiki/spaces/TEM/pages/2021654744/Predicting+QC2"

And the error is

Using credentials for bo.osinski@tempus.com from environment variables
Traceback (most recent call last):
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'exporter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/bin/nbconflux", line 8, in <module>
    sys.exit(main())
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconflux/cli.py", line 55, in main
    enable_style=not args.exclude_style, enable_mathjax=args.include_mathjax)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconflux/api.py", line 52, in notebook_to_page
    result = exporter.from_filename(notebook_file)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconflux/exporter.py", line 330, in from_filename
    return super(ConfluenceExporter, self).from_filename(filename, *args, **kwargs)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 181, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 199, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconflux/exporter.py", line 297, in from_notebook_node
    html, resources = super(ConfluenceExporter, self).from_notebook_node(nb, resources, **kw)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/html.py", line 119, in from_notebook_node
    return super().from_notebook_node(nb, resources, **kw)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 369, in from_notebook_node
    nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 143, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 318, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/nbconflux/preprocessor.py", line 41, in preprocess
    .format(server=self.exporter.server, page_id=self.exporter.page_id),
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 591, in _validate
    value = self.validate(obj, value)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 1677, in validate
    self.error(obj, value)
  File "/Users/bo.osinski/miniconda3/envs/nbconflux_conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 1524, in error
    raise TraitError(e)
traitlets.traitlets.TraitError: The 'exporter' trait of a ConfluencePreprocessor instance must be a ConfluenceExporter, but a value of class 'NoneType' (i.e. None) was specified.

Relevant installed packages:

bleach==3.3.0
html5lib==1.1
jupyter-client==6.1.11
jupyter-core==4.7.1
nbconflux==0.5.0
nbconvert==6.0.7
nbformat==5.1.2
traitlets==4.3.3
Python 3.6.13
Mac OS 10.14.6

I've tried running this in my native python as well as a new python 3.6 conda environment, but always get the same TraitError. Does anybody have an idea how I can fix this? Thank you!

abhishekbodhekar commented 3 years ago

@boleszek - have you got the solution? Stucked on same point....

boleszek commented 3 years ago

@boleszek - have you got the solution? Stucked on same point....

Unfortunately no. I've tried different versions of nbconflux, but always getting the same error.

makammoun commented 3 years ago

The problem occurs because nbconvert 6 actually breaks nbconflux. This is my attempt to fix the problem https://github.com/criteo-forks/nbconflux/pull/2