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

Support use with jupyter_server by decoupling notebook dependencies #193

Merged
merged 13 commits into from
Aug 17, 2021

Conversation

GeorgianaElena
Copy link
Member

@GeorgianaElena GeorgianaElena commented Jul 8, 2021

Fixes #177, and (edit by Erik) fixes #176, and fixes 2i2c-org/upstream#28

Not sure how to test this though 👀 (Situation fixed, thanks to Yuvi :D)

@yuvipanda
Copy link
Contributor

You can just start jupyter server and try a nbgitpuller URL there - that should use jupyter server rather than notebookserver

@GeorgianaElena
Copy link
Member Author

Thanks @yuvipanda! I tried it and observed the following behavior:

nbgitpuller-error-jupyter-server

From my understanding, all these files that are reported as "missing" when using jupyter_server, exist in the classic Notebook Server package. Which makes sense, since they are "fronted-related".
However, I don't know how to fix this 😕 Should we change nbgitpuller implementation to not use these notebookserver specific files?

@manics
Copy link
Member

manics commented Jul 12, 2021

Could it be that you need to change some imports from notebook to jupyter_server, and maybe require jupyter_server in setup.py?

@yuvipanda
Copy link
Contributor

Should we change nbgitpuller implementation to not use these notebookserver specific files?

Yep, that's the way forward. Re-using xterm.js from where we do is definitely a notebook-specific implementation detail - see 3714d00 and #4 for other times it needed updating.

Unfortunately, we are also using a template from notebook server to render our page, so this might not be the simplest operation.

@yuvipanda
Copy link
Contributor

The way to do this is to not inherit from page.html. https://github.com/jupyter/notebook/blob/master/notebook/templates/page.html is the source, so we can copy that in and remove our dependency on the notebook package.

In addition, we'll need to make our JS work without the dependencies we inherit from the page.html in the notebook package. I think xterm and jquery are the only ones we need. We could either just copy in the .js files now, although I think this is a great time to introduce webpack here! We couldn't use webpack before because the JS from the notebook page use requirejs...

@GeorgianaElena
Copy link
Member Author

Thanks for the pointers @yuvipanda. I wasn't sure where to start. I'll update this PR once I have something/questions.

@GeorgianaElena
Copy link
Member Author

I've realized that I pushed some commits without saying anything, sorry about that :(

I managed to get this working locally, yay 🎉 I still need to update the CI to actually use this version and then update the docs/README. But I would love some feedback about the implementation.

Copy link
Contributor

@yuvipanda yuvipanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestion about removing extra js stuff in the template, but otherwise great! I haven't tested it at all though.

How do you think we can test this against jupyter-server? We need to make sure this still works on both jupyter-server and classic notebook...

{% endif %}
baseUrl: '{{static_url("", include_version=False)}}',
paths: {
'auth/js/main': 'auth/js/main.min',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the ones we don't need? I think we can get rid of a lot of these!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cheated and copied the page.html file from jupyter_server which should have only the things we need. I'm not sure if I'm right though 😬

@GeorgianaElena
Copy link
Member Author

How do you think we can test this against jupyter-server? We need to make sure this still works on both jupyter-server and classic notebook...

@yuvipanda, I parametrized the existing tests in test_api.py to run both with jupyter-notebook and jupyter-server. What do you think?

I have to note one thing though, because I had some troubles making the tests pass on the CI and locally there were no issues.

Without installing a front-end jupyter_server extension (nbclassic or jupyterlab) the GET request to retrieve the repo (GET /git-pull/api?token=secret&repo=https%3A//github.com/binder-examples/jupyter-extension&branch=master) returned a 302 and then a 404 (locally). I'm not very sure of the nbgitpuller internals, but I guess this is expected since jupyter_server has only the backend part, right?

302+404

@nibheis
Copy link

nibheis commented Aug 16, 2021

Hi @GeorgianaElena and @yuvipanda,

We migrated our school infra to jupyterlab 3.1.4 during the summer and now we just realized that nbgitpuller no longer works (arrg, how could we miss that!).

Looks like you've done the hard work to get nbgitpuller to work with jupyter_server... how can we help to get this pull request applied and released ?

@yuvipanda
Copy link
Contributor

@nibheis if you can try this out patch in your setup and tell us any problems you encounter, that will be a big help :)

@yuvipanda
Copy link
Contributor

Without installing a front-end jupyter_server extension (nbclassic or jupyterlab) the GET request to retrieve the repo (GET /git-pull/api?token=secret&repo=https%3A//github.com/binder-examples/jupyter-extension&branch=master) returned a 302 and then a 404 (locally). I'm not very sure of the nbgitpuller internals, but I guess this is expected since jupyter_server has only the backend part, right?

I think the 404 makes sense since it's done after the pulling is successful.

@nibheis
Copy link

nibheis commented Aug 17, 2021

@nibheis if you can try this out patch in your setup and tell us any problems you encounter, that will be a big help :)

Hi @GeorgianaElena and @yuvipanda,

So, I:

  • cloned @GeorgianaElena 's repo (branch "extension" where the commits have been made)
  • "pip -e ." installed it
  • activated the extension...

and it worked as expected. I could not see any warning in the jupyterlab logs. All looks good to me ; I hope it helps.

I will deploy this branch on all our servers until a release is made.

Many thanks!

@consideRatio
Copy link
Member

WIEEEEEEEEEEEE!!! Thank you @GeorgianaElena!!! 🎉 ❤️ 🌻!

Thank you @nibheis, @yuvipanda, and @manics as well!

@yuvipanda
Copy link
Contributor

I've deployed it and it mostly works. Terminal resizing seems awkward tho, and there is this error in the js console:

image

@manics
Copy link
Member

manics commented Aug 18, 2021

@yuvipanda Could be related to the xtermjs 4 upgrade(?), since the way addons worked was changed. See for example https://github.com/cs01/pyxtermjs/pull/18/files

@nibheis
Copy link

nibheis commented Aug 18, 2021

I've deployed it and it mostly works. Terminal resizing seems awkward tho, and there is this error in the js console:

image

Upgraded to jupyterlab 3.1.7, still using the patched nbgitpuller: I don't see any terminal related issues here.

However, I can report a small bug regarding the final redirection (once nbgitpuller has done its job) : if the saved workspace from the previous session has open tabs (i.e. is non-empty), then the final redirection will only happen in the case of a clone operation.

That is: if the repository had previously been cloned AND the saved workspace contains some opened notebooks (for the repo or other), then the final redirection is skipped (the URL visible in the browser changes).

NOTE: if don't think it's linked to nbgitpuller, as I had noticed a similar behavior while adding "next=" parameters.
It looks like a race between the requested redirection (by nbgitpuller - using the "next=..." mechanism) and the workspace state restoration mechanism. Which ever is last will sort of win the final redirection.

yuvipanda added a commit to yuvipanda/datahub that referenced this pull request Aug 18, 2021
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit 66f16fe.
@consideRatio consideRatio mentioned this pull request Aug 23, 2021
@consideRatio consideRatio changed the title Migrate nbgitpuller to use jupyter_server Support use with jupyter_server by decoupling notebook dependencies Sep 1, 2021
@GeorgianaElena GeorgianaElena deleted the extension branch September 2, 2021 12:06
shaneknapp pushed a commit to berkeley-dsep-infra/biology-user-image that referenced this pull request Sep 6, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/biology-user-image that referenced this pull request Sep 6, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit c4e8aeb.
shaneknapp pushed a commit to berkeley-dsep-infra/publichealth-user-image that referenced this pull request Sep 11, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/publichealth-user-image that referenced this pull request Sep 11, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit 8fafc4c.
shaneknapp pushed a commit to berkeley-dsep-infra/eecs-user-image that referenced this pull request Sep 11, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/eecs-user-image that referenced this pull request Sep 11, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit ba5ad18.
shaneknapp pushed a commit to berkeley-dsep-infra/julia-user-image that referenced this pull request Sep 12, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/julia-user-image that referenced this pull request Sep 12, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit cce2909.
shaneknapp pushed a commit to berkeley-dsep-infra/ischool-user-image that referenced this pull request Sep 24, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/ischool-user-image that referenced this pull request Sep 24, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit 598306b.
shaneknapp pushed a commit to berkeley-dsep-infra/datahub-user-image that referenced this pull request Sep 25, 2024
Brings in  jupyterhub/nbgitpuller#193,
to test if it works ok
shaneknapp pushed a commit to berkeley-dsep-infra/datahub-user-image that referenced this pull request Sep 25, 2024
Things mostly worked, but a couple small bugs
exist: jupyterhub/nbgitpuller#193 (comment)

This reverts commit fd355ff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants