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

File Load Error - content.indexOf is not a function when opening a text file in JupyterLab #659

Closed
mwouts opened this issue Oct 12, 2020 · 9 comments · Fixed by #680
Closed

Comments

@mwouts
Copy link
Owner

mwouts commented Oct 12, 2020

If I try to open a text notebook, say World population.md on Binder, then I get this error:

Capture d’écran de 2020-10-12 23-08-29

The version of JupyterLab used on Binder is 2.2.0.

@mwouts
Copy link
Owner Author

mwouts commented Oct 12, 2020

Locally with JupyterLab 2.2.6 I don't reproduce the issue

@dfm
Copy link

dfm commented Nov 15, 2020

I'm finding the same with JupyterLab 2.2.9 and jupytext 1.7.0. Any ideas about what's happening?

@dfm
Copy link

dfm commented Nov 15, 2020

FWIW: Downgrading to jupytext 1.6.0 fixed the issue for me.

@mwouts
Copy link
Owner Author

mwouts commented Nov 15, 2020

Thank you @dfm for the input, that's very helpful. The major change between 1.6.0 and 1.7.0 is a refactoring of Jupytext's contents manager, I will have a look at it and see if I can identify any difference in how text notebooks are loaded between the two...

@mwouts
Copy link
Owner Author

mwouts commented Nov 15, 2020

Indeed, there is a slight difference in the model returned by the new contents manager, and that may be the cause of the issue.

With Jupytext 1.7.0 the model for a text notebook is

{'name': 'text.py', 'path': 'text.py', 'last_modified': datetime.datetime(2020, 11, 15, 21, 58, 7, 683993, tzinfo=<notebook._tz.tzUTC object at 0x7f8a59918640>), 'created': datetime.datetime(2020, 11, 15, 21, 58, 7, 683993, tzinfo=<notebook._tz.tzUTC object at 0x7f8a59918640>), 'content': {'nbformat': 4, 'nbformat_minor': 4, 'metadata': {'jupytext': {'notebook_metadata_filter': '-all', 'cell_metadata_filter': '-all', 'text_representation': {'extension': '.py', 'format_name': 'percent'}}, 'kernelspec': {'name': 'jupytext-dev', 'language': 'python', 'display_name': 'jupytext-dev'}}, 'cells': [{'cell_type': 'code', 'metadata': {}, 'execution_count': None, 'source': '1 + 1', 'outputs': []}]}, 'format': 'text', 'mimetype': 'text/x-python', 'size': 11, 'writable': True, 'type': 'notebook'}

while in Jupytext 1.6.0 that was

{'name': 'text.py', 'path': 'text.py', 'last_modified': datetime.datetime(2020, 11, 15, 22, 3, 9, 136043, tzinfo=<notebook._tz.tzUTC object at 0x7fc9e013c910>), 'created': datetime.datetime(2020, 11, 15, 22, 3, 9, 136043, tzinfo=<notebook._tz.tzUTC object at 0x7fc9e013c910>), 'content': {'nbformat': 4, 'nbformat_minor': 4, 'metadata': {'jupytext': {'notebook_metadata_filter': '-all', 'cell_metadata_filter': '-all', 'text_representation': {'extension': '.py', 'format_name': 'percent'}}, 'kernelspec': {'name': 'jupytext-dev', 'language': 'python', 'display_name': 'jupytext-dev'}}, 'cells': [{'cell_type': 'code', 'metadata': {'trusted': True}, 'execution_count': None, 'source': '1 + 1', 'outputs': []}]}, 'format': 'json', 'mimetype': None, 'size': 11, 'writable': True, 'type': 'notebook'}

the difference is

  • 'format': 'json', 'mimetype': None in v1.6.0 vs
  • 'format': 'text', 'mimetype': 'text/x-python' in v1.7.0

That should be fairly easy to fix...

@mwouts
Copy link
Owner Author

mwouts commented Nov 15, 2020

@dfm, may I ask you to give a try to the proposed fix? I mean:

pip install git+https://github.com/mwouts/jupytext.git

Thanks!

@mwouts
Copy link
Owner Author

mwouts commented Nov 16, 2020

The issue is gone on Binder. I will make a few more tests and distribute the new version later today if everything works fine.

@dfm
Copy link

dfm commented Nov 16, 2020

@mwouts: I can confirm that this fix works for me. Thanks!

@mwouts
Copy link
Owner Author

mwouts commented Nov 16, 2020

Excellent! Thank you for the confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants