From 8698e80304815353ec52be1b16f96483ebe559a0 Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Tue, 21 May 2024 13:35:21 -0700 Subject: refactor(jupyter): use runtimelib for Jupyter structures and directory paths (#23826) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings in [`runtimelib`](https://github.com/runtimed/runtimed) to use: ## Fully typed structs for Jupyter Messages ```rust let msg = connection.read().await?; self .send_iopub( runtimelib::Status::busy().as_child_of(msg), ) .await?; ``` ## Jupyter paths Jupyter paths are implemented in Rust, allowing the Deno kernel to be installed completely via Deno without a requirement on Python or Jupyter. Deno users will be able to install and use the kernel with just VS Code or other editors that support Jupyter. ```rust pub fn status() -> Result<(), AnyError> { let user_data_dir = user_data_dir()?; let kernel_spec_dir_path = user_data_dir.join("kernels").join("deno"); let kernel_spec_path = kernel_spec_dir_path.join("kernel.json"); if kernel_spec_path.exists() { log::info!("✅ Deno kernel already installed"); Ok(()) } else { log::warn!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up"); Ok(()) } } ``` Closes https://github.com/denoland/deno/issues/21619 --- tests/integration/jupyter_tests.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/integration') diff --git a/tests/integration/jupyter_tests.rs b/tests/integration/jupyter_tests.rs index 3c4efbdac..c7b2712e8 100644 --- a/tests/integration/jupyter_tests.rs +++ b/tests/integration/jupyter_tests.rs @@ -10,6 +10,8 @@ use test_util::DenoChild; use test_util::TestContext; use test_util::TestContextBuilder; +use chrono::DateTime; +use chrono::Utc; use deno_core::anyhow::Result; use deno_core::serde_json; use deno_core::serde_json::json; @@ -119,7 +121,7 @@ impl Default for JupyterMsg { struct MsgHeader { msg_id: Uuid, session: Uuid, - date: String, + date: DateTime, username: String, msg_type: String, version: String, @@ -136,7 +138,7 @@ impl Default for MsgHeader { Self { msg_id: Uuid::new_v4(), session: Uuid::new_v4(), - date: utc_now().to_rfc3339(), + date: utc_now(), username: "test".into(), msg_type: "kernel_info_request".into(), version: "5.3".into(), @@ -517,7 +519,7 @@ async fn jupyter_kernel_info() -> Result<()> { "mimetype": "text/x.typescript", "file_extension": ".ts", "pygments_lexer": "typescript", - "nb_converter": "script" + "nbconvert_exporter": "script" }, }), ); @@ -612,7 +614,7 @@ async fn jupyter_store_history_false() -> Result<()> { json!({ "silent": false, "store_history": false, - "code": "console.log(\"asdf\")" + "code": "console.log(\"asdf\")", }), ) .await?; -- cgit v1.2.3