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

errors related to default format when paired to 'auto' #249

Closed
hatemhosny opened this issue Jun 8, 2019 · 6 comments
Closed

errors related to default format when paired to 'auto' #249

hatemhosny opened this issue Jun 8, 2019 · 6 comments

Comments

@hatemhosny
Copy link
Contributor

a great project!
thanks a lot for making this available :)

I am trying to setup default format pairing like that in .jupyter/jupyter_notebook_config.py

c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"
c.ContentsManager.default_jupytext_formats = "ipynb,auto"
c.ContentsManager.preferred_jupytext_formats_save = "auto:percent"

now, whenever I try creating a new notebook in jupyter lab I get these errors:

Screenshot (126)

Screenshot (127)

and in jupyter notebook:

Screenshot (129)

on the other hand, if I open a pre-existing notebook and save it, it is saved correctly with the extension suitable for the kernel I use, even if I change the kernel.

the described errors do not occur if I use a regular extension like py or md:

c.ContentsManager.default_jupytext_formats = "ipynb,md"

am I missing something?

I am using jupytext==1.1.5

thank you

@hatemhosny
Copy link
Contributor Author

another thing related to 'auto' (not sure if it should be in a separate issue):

using

c.ContentsManager.default_jupytext_formats = "ipynb,auto"

as I mentioned in the previous post, I can open an already present notebook and when I save it, it is saved to the file type corresponding to the used kernel.

now, if I used a kernel not supported by jupytext (e.g. ijavascript or itypescript), I am no longer able to save the changes in the notebook (not even to the .ipynb file)

Screenshot (131)

Screenshot (133)

this prevents me from using other kernels with this setting

my questions:

  • what should jupytext do when saving files running on unsupported kernels? (not save any text representation with or without warning / save a default format - e.g md)
  • any plans to support javascript / typescript? :)
    they are quite popular by the way ;)

thank you

@hatemhosny hatemhosny changed the title error creating new notebooks with default format paired to 'auto' errors related to default format when paired to 'auto' Jun 8, 2019
@mwouts
Copy link
Owner

mwouts commented Jun 8, 2019

Thanks @hatemhosny for reporting this - I really appreciate the effort you put in documenting the issues !

We shall be able to fix these points soon.

  • The first issue is caused by the fact that JupyterLab saves an empty notebook (I mean, with no kernel information) when you click on new notebook. Within a few days, I shall be able to add a test in test_contentsmanager.py to reproduce, and then fix this. We could start with this one, but use an empty notebook instead of a real one.
  • Regarding the support for .js files, sure that would be an interesting (and easy) PR. Do you want to give it a try? The required steps are documented in our CONTRIBUTING.md.

@hatemhosny
Copy link
Contributor Author

Thank you 👍

I will work on a PR for both js and ts

Thanks for the guidance

mwouts added a commit that referenced this issue Jun 11, 2019
- Allow saving empty notebooks
- Make sure script is the source when notebook is reloaded
Fixes #249
mwouts added a commit that referenced this issue Jun 11, 2019
- only in the introduction
- links to CONTRIBUTING.md and to languages.py
#249
mwouts added a commit that referenced this issue Jun 11, 2019
@mwouts mwouts mentioned this issue Jun 11, 2019
@mwouts mwouts closed this as completed in 699b60d Jun 11, 2019
mwouts added a commit that referenced this issue Jun 11, 2019
- only in the introduction
- links to CONTRIBUTING.md and to languages.py
#249
mwouts added a commit that referenced this issue Jun 11, 2019
@mwouts
Copy link
Owner

mwouts commented Jun 11, 2019

Hello @hatemhosny , I have released a new version of Jupytext (v 1.1.6) with both your contribution, and a fix for this issue:

pip install jupytext --upgrade

Thanks again for reporting this - and please let me know if you find any other unexpected behavior !

@hatemhosny
Copy link
Contributor Author

great!
thanks @mwouts for the quick response.

I confirm, now jupytext supports javascript and typescript, I can create notebooks with default format "ipynb,auto" and the script files get saved with the correct extension.

still if I use a kernel with unsupported language I get the errors shown here

do we plan to handle this case in a better way?

@mwouts
Copy link
Owner

mwouts commented Jun 12, 2019

You're welcome, thanks again @hatemhosny for your contribution. I was also planning to announce the support for the new languages on twitter, do you have an account there?

still if I use a kernel with unsupported language I get the errors shown here

That's right - I should have commented on that. It should be easy to intercept that error and skip the auto format when the actual extension is not supported (that could take place on this line: test if the actual extension is one of NOTEBOOK_EXTENSIONS, otherwise replace it with .auto).

The reason why I've not implemented that is because I see this error... as an invitation to contribute additional languages to Jupytext 😄 . Can you tell us which languages you are using in addition to the supported ones ?

Also, I am interested in your experience with Jupytext on these new languages. Are the Javascript scripts produced by Jupytext syntaxicaly correct? Reversely, does the conversion script -> notebook produce reasonable cells? I am asking because currently 1. the detection of multiline strings (and comments) is only implemented for Python and R and 2. cells breaks are on blank lines that are followed by an non-indented paragraph, which is very Pythonic, but turns out to work also for languages that use brackets, at least until the user inserts blank lines before the closing brackets...

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

No branches or pull requests

2 participants