diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 539273eb6e..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# ******** NOTE ******** - -name: "CodeQL" - -on: - push: - branches: ["main"] - pull_request: - # The branches below must be a subset of the branches above - branches: ["main"] - schedule: - - cron: "25 18 * * 4" - -permissions: - security-events: write - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: ["python"] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - queries: security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 63993c4cdd..1ab07dd765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. +## 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) + + + ## 1.13.2 ([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v1.13.1...362d100ff24c1da7ef4cbd171c213e9570e8c289)) @@ -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) - - ## 1.13.1 ([Full Changelog](https://github.com/jupyter-server/jupyter_server/compare/v1.13.0...affd5d9a2e6d718baa2185518256f51921fd4484)) diff --git a/jupyter_server/nbconvert/handlers.py b/jupyter_server/nbconvert/handlers.py index 2d1dbde1d5..20b278aa76 100644 --- a/jupyter_server/nbconvert/handlers.py +++ b/jupyter_server/nbconvert/handlers.py @@ -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) @@ -154,7 +154,7 @@ 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() @@ -162,14 +162,14 @@ def post(self, format): 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 diff --git a/jupyter_server/tests/services/sessions/test_api.py b/jupyter_server/tests/services/sessions/test_api.py index 7fb7807782..e1d77a81c6 100644 --- a/jupyter_server/tests/services/sessions/test_api.py +++ b/jupyter_server/tests/services/sessions/test_api.py @@ -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") @@ -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) @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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 @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/setup.cfg b/setup.cfg index 5f6cc64116..fe0bbc86aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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