Skip to content

Commit

Permalink
Merge branch 'main' into authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk authored Jan 20, 2022
2 parents 4a693d6 + d201529 commit 4a7da00
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 101 deletions.
72 changes: 0 additions & 72 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.

<!-- <START NEW CHANGELOG ENTRY> -->

## 1.13.3

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v1.13.2...ee01e1955c8881b46075c78f1fbc932fa234bc72))

### Enhancements made

- More updates to unit tests for pending kernels work [#662](https://github.com/jupyter-server/jupyter_server/pull/662) ([@Zsailer](https://github.com/Zsailer))

### Bugs fixed

- bump traitlets dependency [#663](https://github.com/jupyter-server/jupyter_server/pull/663) ([@Zsailer](https://github.com/Zsailer))

### Contributors to this release

([GitHub contributors page for this release](https://github.com/jupyter-server/jupyter_server/graphs/contributors?from=2022-01-12&to=2022-01-14&type=c))

[@Zsailer](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3AZsailer+updated%3A2022-01-12..2022-01-14&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 1.13.2

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v1.13.1...362d100ff24c1da7ef4cbd171c213e9570e8c289))
Expand Down Expand Up @@ -31,8 +51,6 @@ All notable changes to this project will be documented in this file.

[@adamjstewart](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Aadamjstewart+updated%3A2021-12-09..2022-01-12&type=Issues) | [@blink1073](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Ablink1073+updated%3A2021-12-09..2022-01-12&type=Issues) | [@ccw630](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Accw630+updated%3A2021-12-09..2022-01-12&type=Issues) | [@codecov-commenter](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Acodecov-commenter+updated%3A2021-12-09..2022-01-12&type=Issues) | [@davidbrochart](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Adavidbrochart+updated%3A2021-12-09..2022-01-12&type=Issues) | [@echarles](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Aecharles+updated%3A2021-12-09..2022-01-12&type=Issues) | [@fcollonval](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Afcollonval+updated%3A2021-12-09..2022-01-12&type=Issues) | [@kevin-bates](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Akevin-bates+updated%3A2021-12-09..2022-01-12&type=Issues) | [@op3](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Aop3+updated%3A2021-12-09..2022-01-12&type=Issues) | [@welcome](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3Awelcome+updated%3A2021-12-09..2022-01-12&type=Issues) | [@Wh1isper](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3AWh1isper+updated%3A2021-12-09..2022-01-12&type=Issues) | [@Zsailer](https://github.com/search?q=repo%3Ajupyter-server%2Fjupyter_server+involves%3AZsailer+updated%3A2021-12-09..2022-01-12&type=Issues)

<!-- <END NEW CHANGELOG ENTRY> -->

## 1.13.1

([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v1.13.0...affd5d9a2e6d718baa2185518256f51921fd4484))
Expand Down
18 changes: 9 additions & 9 deletions jupyter_server/nbconvert/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def get(self, format, path):
# Exporting can take a while, delegate to a thread so we don't block the event loop
try:
output, resources = await run_sync(
exporter.from_notebook_node(nb, resources=resource_dict)
lambda: exporter.from_notebook_node(nb, resources=resource_dict)
)
except Exception as e:
self.log.exception("nbconvert failed: %s", e)
Expand Down Expand Up @@ -154,22 +154,22 @@ class NbconvertPostHandler(JupyterHandler):

@web.authenticated
@authorized
def post(self, format):
async def post(self, format):
exporter = get_exporter(format, config=self.config)

model = self.get_json_body()
name = model.get("name", "notebook.ipynb")
nbnode = from_dict(model["content"])

try:
output, resources = exporter.from_notebook_node(
nbnode,
resources={
"metadata": {
"name": name[: name.rfind(".")],
output, resources = await run_sync(
lambda: exporter.from_notebook_node(
nbnode,
resources={
"metadata": {"name": name[: name.rfind(".")]},
"config_dir": self.application.settings["config_dir"],
},
"config_dir": self.application.settings["config_dir"],
},
)
)
except Exception as e:
raise web.HTTPError(500, "nbconvert failed: %s" % e) from e
Expand Down
41 changes: 24 additions & 17 deletions jupyter_server/tests/services/sessions/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ async def cleanup(self):
time.sleep(0.1)


@pytest.fixture
def session_is_ready(jp_serverapp):
"""Wait for the kernel started by a session to be ready.
This is useful when working with pending kernels.
"""

async def _(session_id):
sm = jp_serverapp.session_manager
mkm = jp_serverapp.kernel_manager
session = await sm.get_session(session_id=session_id)
kernel_id = session["kernel"]["id"]
kernel = mkm.get_kernel(kernel_id)
await kernel.ready

return _


@pytest.fixture
def session_client(jp_root_dir, jp_fetch):
subdir = jp_root_dir.joinpath("foo")
Expand Down Expand Up @@ -169,7 +187,9 @@ def assert_session_equality(actual, expected):
assert_kernel_equality(actual["kernel"], expected["kernel"])


async def test_create(session_client, jp_base_url, jp_cleanup_subprocesses, jp_serverapp):
async def test_create(
session_client, jp_base_url, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
):
# Make sure no sessions exist.
resp = await session_client.list()
sessions = j(resp)
Expand Down Expand Up @@ -210,7 +230,6 @@ async def test_create(session_client, jp_base_url, jp_cleanup_subprocesses, jp_s
assert_session_equality(got, new_session)

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -231,7 +250,6 @@ async def test_create_bad(
await session_client.create("foo/nb1.ipynb")

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand Down Expand Up @@ -269,7 +287,6 @@ async def test_create_bad_pending(
assert "non_existent_path" in session["kernel"]["reason"]

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -279,7 +296,6 @@ async def test_create_file_session(session_client, jp_cleanup_subprocesses, jp_s
newsession = j(resp)
assert newsession["path"] == "foo/nb1.py"
assert newsession["type"] == "file"
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -290,7 +306,6 @@ async def test_create_console_session(session_client, jp_cleanup_subprocesses, j
assert newsession["path"] == "foo/abc123"
assert newsession["type"] == "console"
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -302,7 +317,6 @@ async def test_create_deprecated(session_client, jp_cleanup_subprocesses, jp_ser
assert newsession["type"] == "notebook"
assert newsession["notebook"]["path"] == "foo/nb1.ipynb"
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand Down Expand Up @@ -334,7 +348,6 @@ async def test_create_with_kernel_id(
got = j(resp)
assert_session_equality(got, new_session)
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -345,14 +358,15 @@ async def test_create_with_bad_kernel_id(session_client, jp_cleanup_subprocesses
# TODO
assert newsession["path"] == "foo/nb1.py"
assert newsession["type"] == "file"
await session_client.cleanup()
await jp_cleanup_subprocesses()


async def test_delete(session_client, jp_cleanup_subprocesses, jp_serverapp):
async def test_delete(session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready):
resp = await session_client.create("foo/nb1.ipynb")

newsession = j(resp)
sid = newsession["id"]
await session_is_ready(sid)

resp = await session_client.delete(sid)
assert resp.code == 204
Expand All @@ -365,7 +379,6 @@ async def test_delete(session_client, jp_cleanup_subprocesses, jp_serverapp):
await session_client.get(sid)
assert expected_http_error(e, 404)
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -379,7 +392,6 @@ async def test_modify_path(session_client, jp_cleanup_subprocesses, jp_serverapp
assert changed["id"] == sid
assert changed["path"] == "nb2.ipynb"
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -393,7 +405,6 @@ async def test_modify_path_deprecated(session_client, jp_cleanup_subprocesses, j
assert changed["id"] == sid
assert changed["notebook"]["path"] == "nb2.ipynb"
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -407,7 +418,6 @@ async def test_modify_type(session_client, jp_cleanup_subprocesses, jp_serverapp
assert changed["id"] == sid
assert changed["type"] == "console"
# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand All @@ -432,7 +442,6 @@ async def test_modify_kernel_name(session_client, jp_fetch, jp_cleanup_subproces
assert kernel_list == [after["kernel"]]

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand Down Expand Up @@ -464,7 +473,6 @@ async def test_modify_kernel_id(session_client, jp_fetch, jp_cleanup_subprocesse
assert kernel_list == [kernel]

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()


Expand Down Expand Up @@ -527,5 +535,4 @@ async def test_restart_kernel(
assert model["connections"] == 1

# Need to find a better solution to this.
await session_client.cleanup()
await jp_cleanup_subprocesses()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install_requires =
pyzmq>=17
argon2-cffi
ipython_genutils
traitlets>=4.2.1
traitlets>=5
jupyter_core>=4.6.0
jupyter_client>=6.1.1
nbformat
Expand Down

0 comments on commit 4a7da00

Please sign in to comment.