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

Debugger slows down Jupyterlab #77

Open
Michael-ljn opened this issue Apr 9, 2024 · 4 comments
Open

Debugger slows down Jupyterlab #77

Michael-ljn opened this issue Apr 9, 2024 · 4 comments

Comments

@Michael-ljn
Copy link

Hi,

First of all, thank you for this awesome extension. I just installed the latest version V1.0.0 and somehow the extension is considerably slowing down my JupyterLab server. Sometimes it makes it freeze. The following lines are in the terminal log which indicates that some sort of debugger is on.

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

I am certain it is from this extension, as I do not experience this problem when the extension is disabled. Not sure what causes this but wonder if we can disable it, at a software level. Maybe downgrading to a more stable version?

I am a mac user, on M1pro chip.

@krassowski
Copy link
Owner

This extension (citation-manager) has nothing to do with the debugger. However, I know how to resolve the warning you are seeing:

  1. Upgrade to ipykernel 6.29.4
  2. Run python -m ipykernel install --sys-prefix (assuming you have the ipykernel installed in a virtual environment; if not, you need to pass appropriate --prefix argument)

Note, this does not mean that the debugger is on. However, from the warning I can say that you are running Python 3.11+. If you do not see the warning, nor slowness in another environment you have either created it recently with the update ipykernel, or have an older Python version.

considerably slowing down my JupyterLab server

Can you share the full logs after running jupyter lab --debug?

@krassowski
Copy link
Owner

If anything is slowing down the startup that would likely be the scanning for citation style files:

def _scan_for_styles(data_path, log: logging.Logger):
p = Path(data_path)
style_files = list(p.glob('*.csl'))
styles = []
# TODO: prevent files with the same name but in different config directories from conflicting (how?)
for style_path in style_files:
try:
info = _extract_info(style_path)
except Exception as e:
log.warning(
f"Could not extract style info for {style_path}:"
f" {e}."
)
continue
styles.append({
# ID for retrieving from server; should be same as path on GitHub CSL repo (if present in there)
'id': str(style_path.relative_to(p)),
# path used internally to point to the resource
'path': str(style_path),
# information extracted from XML
'info': info
})
return styles

It should be possible to make all the logic async so that it does not block the server startup.

@Michael-ljn
Copy link
Author

  • Upgrade to ipykernel 6.29.4
  • Run python -m ipykernel install --sys-prefix (assuming you have the ipykernel installed in a virtual environment; if not, you need to pass appropriate --prefix argument)

Updating ipykernel effectively removed the debugger lines in the terminal. I think you are right, the huge lag comes from the Zotero sync or at least from what I understand. It's very laggy and freezes the server when you have multiple notebooks open, and you switch between them. Is that because of the _scan_for_styles()?

I will try to dive a bit more in this in the coming weeks.

@Michael-ljn
Copy link
Author

There is also a bunch of non-citable content that is being fetched from the API. I can see annotations from pdf and notes and have to carefully select the good zotero item. Could that be also a reason why the sync is so slow? Is there a way to return only the citable content?

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