pythonpython-3.xjupyter-notebookgithub-actionspapermill

Papermill Run Errors in Github Actions with AttributeError


I am running my Python Notebook as part of my GitHub Action CI and it worked for quite some time. But today it stopped working complaining about this error:

Input Notebook:  03_Pcap.ipynb
Output Notebook: /tmp/ipynb/03_Pcap.ipynb
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/ipython_genutils/ipstruct.py", line 132, in __getattr__
    result = self[key]
KeyError: 'language'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.2/x64/bin/papermill", line 8, in <module>
    sys.exit(papermill())
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/cli.py", line 242, in papermill
    execute_notebook(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/execute.py", line 81, in execute_notebook
    nb = parameterize_notebook(nb, parameters, report_mode)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/parameterize.py", line 75, in parameterize_notebook
    language = nb.metadata.kernelspec.language
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/ipython_genutils/ipstruct.py", line 134, in __getattr__
    raise AttributeError(key)
AttributeError: language
  1. I haven't changed anything inbetween: https://github.com/DSPJ2021/syncmesh/compare/e97b1ced4ae90e27c7eb653dc27602edd9be81fa...1bdd32aefa621249a6d6223854d2c41f494da2d1

    Still it just stopped working: Last Working Action / First Failing Action

  2. I already compared the Workers version, both are 2.286.1

  3. I compared the installed python version, both are 3.10.2

  4. I compared the installed dependencies, but most are the same. (WORKING / FAILING)

    • papermill is the same version (2.3.3)
    • papermill-nb-runner is the same (1.1.16)
    • ipykernel is the same (6.7.0)
    • nbformat is the same (5.1.3)
    • nbconvert is the same (6.4.1)
  5. I tracked down the language error and resolved it (Commit) (Action Run) But run straight into the next one:

Input Notebook:  03_Pcap.ipynb
Output Notebook: /tmp/ipynb/03_Pcap.ipynb
Input notebook does not contain a cell with tag 'parameters'

Executing:   0%|          | 0/27 [00:00<?, ?cell/s]Notebook JSON is invalid: Additional properties are not allowed ('id' was unexpected)

Failed validating 'additionalProperties' in code_cell:

On instance['cells'][0]:
{'cell_type': 'code',
 'execution_count': None,
 'id': '4e48dff5',
 'metadata': {'papermill': {'duration': None,
                            'end_time': None,
                            'exception': None,
                            'start_time': None,
                            'status': 'pending'},
              'tags': ['injected-parameters']},
 'outputs': ['...0 outputs...'],
 'source': '# Parameters\n'
           '( = ["\'", "c", "i", "\'", ",", " ", "\'", "t", "r", "...'}

Executing:   0%|          | 0/27 [00:00<?, ?cell/s]
Notebook JSON is invalid: Additional properties are not allowed ('id' was unexpected)

Failed validating 'additionalProperties' in code_cell:

On instance['cells'][0]:
{'cell_type': 'code',
 'execution_count': None,
 'id': '4e48dff5',
 'metadata': {'papermill': {'duration': None,
                            'end_time': None,
                            'exception': None,
                            'start_time': None,
                            'status': 'completed'},
              'tags': ['injected-parameters']},
 'outputs': ['...0 outputs...'],
 'source': '# Parameters\n'
           '( = ["\'", "c", "i", "\'", ",", " ", "\'", "t", "r", "...'}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.2/x64/bin/papermill", line 8, in <module>
    sys.exit(papermill())
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/cli.py", line 242, in papermill
    execute_notebook(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/execute.py", line 91, in execute_notebook
    nb = papermill_engines.execute_notebook_with_engine(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 49, in execute_notebook_with_engine
    return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 310, in execute_notebook
    nb = cls.execute_managed_notebook(nb_man, kernel_name, log_output=log_output, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 372, in execute_managed_notebook
    preprocessor.preprocess(nb_man, safe_kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/preprocess.py", line 20, in preprocess
    with self.setup_preprocessor(nb_man.nb, resources, km=km):
AttributeError: 'PapermillExecutePreprocessor' object has no attribute 'setup_preprocessor'
Error: Process completed with exit code 1.
  1. Looked up the error and found:

  2. After updating my .ipynpb version (from 4.2 to 4.5). I am down to only this error:

Input Notebook:  03_Pcap.ipynb
Output Notebook: /tmp/ipynb/03_Pcap.ipynb
Input notebook does not contain a cell with tag 'parameters'

Executing:   0%|          | 0/27 [00:00<?, ?cell/s]
Executing:   0%|          | 0/27 [00:00<?, ?cell/s]
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.2/x64/bin/papermill", line 8, in <module>
    sys.exit(papermill())
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/cli.py", line 242, in papermill
    execute_notebook(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/execute.py", line 91, in execute_notebook
    nb = papermill_engines.execute_notebook_with_engine(
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 49, in execute_notebook_with_engine
    return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 310, in execute_notebook
    nb = cls.execute_managed_notebook(nb_man, kernel_name, log_output=log_output, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/engines.py", line 372, in execute_managed_notebook
    preprocessor.preprocess(nb_man, safe_kwargs)
  File "/opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/papermill/preprocess.py", line 20, in preprocess
    with self.setup_preprocessor(nb_man.nb, resources, km=km):
AttributeError: 'PapermillExecutePreprocessor' object has no attribute 'setup_preprocessor'

Anybody who knows what is going wrong and how to make it work again?

BTW: It works fine on my machine.


Solution

  • Complex Problem easy solution: My requirements.txt referenced an older package named papermill-nb-runner installing it (and papermill) pip somehow got confused and installed the old version of papermill but showed only the newest version.

    The solution was to remove papermill-nb-runner.

    Also, it only came to highlight through a bug in pip: https://github.com/pypa/pip/issues/10861