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

refactor: use jupyter_server ExtensionApp #492

Conversation

maartenbreddels
Copy link
Member

A 'reboot' of #270 with a single clean commit to avoid merge conflicts with other PR's.

@Zsailer I took out many code reformatting changes, since they confused the diff-er, and me, and with large outstanding PR's it will lead to many more merge conflicts and a polluted history. I hope you don't hold it against me :)

Replaces #270

@Zsailer
Copy link
Member

Zsailer commented Dec 4, 2019

This is great! Thank you, @maartenbreddels.

@Zsailer
Copy link
Member

Zsailer commented Dec 4, 2019

We're rolling back jupyter_server to support Python 3.5 for a new release (0.2) with the ExtensionApp. This should be done by Friday.

Then, we'll likely drop Python 3.5 in a jupyter_server 0.3 release. The new Kernel Provider work from @kevin-bates that we're hoping to land in master this next month requires Python 3.6 and above.

@kevin-bates
Copy link

Just to be clear, we can easily fix the 3.5 support issue in kernel provider stuff. There was a recent change that unexpectedly introduced a syntax error only on 3.5 - and we had cut the 0.5.0 release just prior to that discovery (thus the hesitancy to fix it for something that we thought was more near to its EOL). Of course, by the time jupyter-server 0.3.0 is developed, 3.5 may be deprecated, but we shouldn't let this hold up use of JKM. It's relatively easy to produce a patch release (0.5.1) that restores 3.5 support in JKM if necessary.

@SylvainCorlay
Copy link
Member

Note: we have a constraint to support Python 3.5 for a little bit more in Voilà. Having jupyter_server be compatible with python 3.5 would be great!

@Zsailer
Copy link
Member

Zsailer commented Dec 4, 2019

Ok, we've reverted jupyter_server to support 3.5 in jupyter-server/jupyter_server#150.

@maartenbreddels
Copy link
Member Author

Thanks @kevin-bates , @Zsailer and @echarles for correcting this before I even had time to reply 👏

Related:
jupyter-server/jupyter_server#150
jupyter-server/jupyter_server#142

@maartenbreddels maartenbreddels force-pushed the refactor_extension_app branch 4 times, most recently from 2d3cb87 to 4262d57 Compare December 6, 2019 11:01
@Zsailer
Copy link
Member

Zsailer commented Dec 19, 2019

Just release Jupyter Server 0.2.0.

Still supports Python 3.5 and includes all the ExtensionApp work (with tests, finally). Let us know if you run into any issues. I'm happy to help with this PR too, if you'd like.

setup.py Outdated Show resolved Hide resolved
voila_app.initialize(voila_args + ['--no-browser'])
voila_config(voila_app)
voila_app.start()
def voila_app(server_config, voila_config, voila_args):
Copy link
Member

Choose a reason for hiding this comment

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

I released jupyter_server 0.2.1 (see changelog) today, which includes a pytest-plugin for jupyter_server.

Inside this plugin, we've added a serverapp fixture and a configurable_serverapp fixture that handle the creation + teardown of a jupyter server instance between each test so you don't have to.

You can see an example using this plugin here in nbclassic.

@@ -14,8 +14,8 @@


@pytest.mark.gen_test
def test_hello_world(http_client, base_url):
response = yield http_client.fetch(base_url)
def test_hello_world(http_client, default_url):
Copy link
Member

Choose a reason for hiding this comment

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

The jupyter server pytest-plugin we added in jupyter_server 0.2.1 drastically improves this syntax.

  • You can now use async/await syntax.
  • we over a fetch fixture—a function for making requests to the jupyter server API and extension handlers.

To see an example, check out this simple unit test in Jupyter Server.

@Zsailer
Copy link
Member

Zsailer commented Jan 10, 2020

I mentioned in my comments, I released Jupyter Server 0.2.1 today. This includes a pytest-plugin for jupyter server extensions (like future Voila).

This significantly improves the syntax when writing extension tests:

  • Can now use async/await syntax when writing tests (see example here).
  • serverapp fixture that handles setup/teardown.
  • fetch fixture for asynchronous/awaitable requests to the serverapp+extension APIs.
  • other helpful fixtures, see summary list here.
  • Extend the serverapp fixture with a voila_app fixture easily. See example from nbclassic.

To start using today, pip install jupyter_server>=0.2.1 and add pytest_jupyter_server to your top-level conftest.py.

@jtpio
Copy link
Member

jtpio commented Jan 27, 2020

This looks great!

Just tried locally with jupyter_server 0.2.1. It looks like some minor adjustments are required to take into account the latest changes (getting a KeyError: 'extension_name' at the moment).

.github/workflows/main.yml Outdated Show resolved Hide resolved
@jtpio
Copy link
Member

jtpio commented Jan 28, 2020

Opened jupyter-server/jupyter_server#175 for the extension_name default value and validation.

@jtpio
Copy link
Member

jtpio commented Jan 28, 2020

I think we also need this change: jupyter-server/jupyter_server#172

@jtpio
Copy link
Member

jtpio commented Jan 28, 2020

Also, this issue seems to prevent using Voila as a server extension at the moment: jupyter-server/jupyter_server#74.

self.serverapp.log.debug("using template: %s", self.template)
self.serverapp.log.debug("nbconvert template paths:\n\t%s", "\n\t".join(self.nbconvert_template_paths))
self.serverapp.log.debug("template paths:\n\t%s", "\n\t".join(self.template_paths))
self.serverapp.log.debug("static paths:\n\t%s", "\n\t".join(self.static_paths))

jenv_opt = {"autoescape": True} # we might want extra options via cmd line like notebook server
env = jinja2.Environment(loader=jinja2.FileSystemLoader(self.template_paths), extensions=['jinja2.ext.i18n'], **jenv_opt)
Copy link
Member

Choose a reason for hiding this comment

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

@davidbrochart
Copy link
Member

I'm trying to sync this PR with master, I opened a PR in @maartenbreddels's refactor_extension_app branch: maartenbreddels#1

@stonebig
Copy link

stonebig commented Sep 19, 2020

hello,

I'm experimenting Jupyter-server-1.0.1, and pip warns me voila is not compatible yet.

voila 0.2.2 requires jupyter-server<0.4.0,>=0.3.0, but you'll have jupyter-server 1.0.1 which is incompatible.

Is there an ongoing set of pull request that resolves this ?

image

@trungleduc
Copy link
Member

Closing as the proposed changes are not applicable anymore to the next release of Voila

@trungleduc trungleduc closed this Aug 1, 2023
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 this pull request may close these issues.

8 participants