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

jupytext not syncing notebook to python files #1274

Open
nathaniellarson opened this issue Sep 27, 2024 · 4 comments
Open

jupytext not syncing notebook to python files #1274

nathaniellarson opened this issue Sep 27, 2024 · 4 comments

Comments

@nathaniellarson
Copy link

Context
I am working on a Amazon Linux 2 machine that has JupyterLab installed. But instead of using the command palette I paired my notebooks using a jupytext.toml file.

File structure of this directory:

.
├── jupytext.toml
├── file1.py
├── file2.py
├── file3.py
└── other_directory

Contents of jupytext.toml:

notebook_metadata_filter="-all"
cell_metadata_filter="-all"
formats="ipynb,py:percent"

Current version:

$ pip freeze | grep jupytext
jupytext==1.16.4

Situation

After cloning a fresh copy of my repo onto the machine, jupytext doesn't work immediately. Instead, I run:

jupytext --sync file1.py file2.py file3.py

The output of that command was:

[jupytext] Reading /home/jupyter/file1.py in format py
[jupytext] Updating /home/jupyter/file1.ipynb
[jupytext] Updating /home/jupyter/file1.py
[jupytext] Reading /home/jupyter/file2.py in format py
[jupytext] Updating /home/jupyter/file2.ipynb
[jupytext] Updating /home/jupyter/file2.py
[jupytext] Reading /home/jupyter/file3.py in format py
[jupytext] Updating /home/jupyter/file3.ipynb
[jupytext] Updating /home/jupyter/file3.py

Problem
My problem is that when I continue to make edits in, say, /home/jupyter/file3.ipynb and save, those changes are not saving. I added just the text test into some markdown and it didn't sync, even waiting many minutes. Am I doing something wrong here?

@mwouts
Copy link
Owner

mwouts commented Sep 28, 2024

Hey @nathaniellarson , how did you install Jupytext on that machine?

Can you check that Jupytext is available in the environment that you use to launch Jupyter Lab / how do the Jupyter logs look like?

You can tell whether Jupytext is active in Jupyter Lab by looking at the icons for .py and .md files - they have a notebook icon when Jupytext is active.

@nathaniellarson
Copy link
Author

Ah, interesting. Yes, and now I see that is in the docs here. It looks like the icons indicate that jupytext is not active. I'll check in with my admin, it looks like it is not enabled just in our latest image.

@nathaniellarson
Copy link
Author

I was going to open another issue, but perhaps I'll just continue here. It's odd, it looks like the extension is enabled, but the icons aren't all the "notebook" icons that you said should indicate it's working. Unfortunately, I don't have my Jupyter logs, but I have this:

(myenv) nathaniel_larson bash $ jupyter labextension list
`sys_prefix` level settings are read-only, using `user` level for migration to `lockedExtensions`
JupyterLab v4.2.5
/usr/local/miniconda/envs/myenv/share/jupyter/labextensions
        jupyterlab-jupytext v1.4.3 enabled OK (python, jupytext)
        jupyterlab-plotly v5.24.1 enabled  X
        jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
        @jupyter-notebook/lab-extension v7.2.2 enabled OK

From this section of the docs, it seems that I shouldn't have to install anything additional for JupyterLab 4.X.

@mwouts
Copy link
Owner

mwouts commented Oct 5, 2024

Hey @nathaniellarson , well this jupyterlab-jupytext extension is part of jupytext, so that's fine. It seems like you do have jupytext installed in the myenv environment indeed.

Now the question is, what environment do you use to launch Jupyter? It's in that environment that you need to install Jupytext.

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