microsoft / pybryt

Python library for pedagogical auto-assessment
https://microsoft.github.io/pybryt
MIT License
63 stars 19 forks source link

PyBryt and ipykernel>=6.0 issue #114

Closed marijanbeg closed 3 years ago

marijanbeg commented 3 years ago

PyBryt did not work with ipykernel>=6.0. As a temporary fix, I fixed ipykernel to 5.5.5 in requirements.txt before one of the releases a few months ago. I hoped this problem could resolve itself on its own when ipykernel matures, but it did not.

marijanbeg commented 3 years ago

@chrispyles The error message:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_29646/1585344199.py in <module>
      2 for subm in notebooks:
      3     print(subm)
----> 4     student_impls.append(pybryt.StudentImplementation(subm))
      5 
      6 student_impls

/data/programs/pybryt/pybryt/student.py in __init__(self, path_or_nb, addl_filenames, output, timeout)
     79             raise TypeError(f"path_or_nb is of unsupported type {type(path_or_nb)}")
     80 
---> 81         self._execute(timeout, addl_filenames=addl_filenames, output=output)
     82 
     83     def _execute(self, timeout: Optional[int], addl_filenames: List[str] = [], output: Optional[str] = None) -> NoReturn:

/data/programs/pybryt/pybryt/student.py in _execute(self, timeout, addl_filenames, output)
     92             output (``str``, optional): a path at which to write executed notebook
     93         """
---> 94         self.steps, self.values, self.calls, self.executed_nb = execute_notebook(
     95             self.nb, self.nb_path, addl_filenames=addl_filenames, output=output, timeout=timeout,
     96         )

/data/programs/pybryt/pybryt/execution/__init__.py in execute_notebook(nb, nb_path, addl_filenames, output, timeout)
     92     os.remove(observed_fp)
     93 
---> 94     n_steps = max([t[1] for t in observed])
     95 
     96     return n_steps, observed, calls, nb

ValueError: max() arg is an empty sequence
chrispyles commented 3 years ago

@marijanbeg what version of ipykernel is producing this error? Also can you send the notebook that produced it? I'm running the demos with ipykernel==6.5.0 and everything is working fine.

marijanbeg commented 3 years ago

Hi @chrispyles, I have just created a fresh environment (exported to yml, appended at the end) and tried to run https://github.com/marijanbeg/pybryt-examples/blob/master/examples/insertion-sort.ipynb. The error is the same as the one above:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/lr/hsg067s53m3bw35fmxmfyb680000gn/T/ipykernel_36406/3622103152.py in <module>
      1 with pybryt.check(pybryt_reference(1, 1)):
----> 2     insertion_sort([55, 111, -33, 65, 1001, -362, 451])

~/repos/tmp/pybryt/pybryt/student.py in __exit__(self, exc_type, exc_value, traceback)
    422 
    423     def __exit__(self, exc_type, exc_value, traceback):
--> 424         tracing_off(save_func=False)
    425 
    426         if self._frame is not None:

ValueError: max() arg is an empty sequence

Environment:

name: pbtest
channels:
  - defaults
dependencies:
  - ca-certificates=2021.10.26=hecd8cb5_2
  - certifi=2021.10.8=py39hecd8cb5_0
  - libcxx=12.0.0=h2f01273_0
  - libffi=3.3=hb1e8313_2
  - ncurses=6.3=hca72f7f_1
  - openssl=1.1.1l=h9ed2024_0
  - pip=21.2.4=py39hecd8cb5_0
  - python=3.9.7=h88f2d9e_1
  - readline=8.1=h9ed2024_0
  - setuptools=58.0.4=py39hecd8cb5_0
  - sqlite=3.36.0=hce871da_0
  - tk=8.6.11=h7bc2e8c_0
  - tzdata=2021e=hda174b7_0
  - wheel=0.37.0=pyhd3eb1b0_1
  - xz=5.2.5=h1de35cc_0
  - zlib=1.2.11=h1de35cc_3
  - pip:
    - appnope==0.1.2
    - argon2-cffi==21.1.0
    - astunparse==1.6.3
    - attrs==21.2.0
    - backcall==0.2.0
    - bleach==4.1.0
    - cffi==1.15.0
    - click==8.0.3
    - cython==0.29.24
    - debugpy==1.5.1
    - decorator==5.1.0
    - defusedxml==0.7.1
    - dill==0.3.4
    - entrypoints==0.3
    - ipykernel==6.5.0
    - ipython==7.29.0
    - ipython-genutils==0.2.0
    - ipywidgets==7.6.5
    - jedi==0.18.0
    - jinja2==3.0.2
    - jsonschema==4.2.1
    - jupyter==1.0.0
    - jupyter-client==7.0.6
    - jupyter-console==6.4.0
    - jupyter-core==4.9.1
    - jupyterlab-pygments==0.1.2
    - jupyterlab-widgets==1.0.2
    - markupsafe==2.0.1
    - matplotlib-inline==0.1.3
    - mistune==0.8.4
    - nbclient==0.5.5
    - nbconvert==6.2.0
    - nbformat==5.1.3
    - nest-asyncio==1.5.1
    - notebook==6.4.5
    - numpy==1.21.4
    - packaging==21.2
    - pandas==1.3.4
    - pandocfilters==1.5.0
    - parso==0.8.2
    - pexpect==4.8.0
    - pickleshare==0.7.5
    - prometheus-client==0.12.0
    - prompt-toolkit==3.0.22
    - ptyprocess==0.7.0
    - pycparser==2.21
    - pygments==2.10.0
    - pyparsing==2.4.7
    - pyrsistent==0.18.0
    - python-dateutil==2.8.2
    - pytz==2021.3
    - pyzmq==22.3.0
    - qtconsole==5.2.0
    - qtpy==1.11.2
    - send2trash==1.8.0
    - six==1.16.0
    - terminado==0.12.1
    - testpath==0.5.0
    - tornado==6.1
    - traitlets==5.1.1
    - wcwidth==0.2.5
    - webencodings==0.5.1
    - widgetsnbextension==3.5.2
prefix: /Users/marijanbeg/miniconda3/envs/pbtest

I hope this helps. Please let me know if I can provide any further information.