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(jupyter): use runtimelib for Jupyter structures and directory paths #23826

Merged
merged 4 commits into from
May 21, 2024

Conversation

rgbkrk
Copy link
Contributor

@rgbkrk rgbkrk commented May 15, 2024

This brings in runtimelib to use:

Fully typed structs for Jupyter Messages

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.

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 #21619

I tested this out across all the notebooks in https://github.com/rgbkrk/denotebooks, which was also a great chance for me to switch them all to jsr: wherever possible. Update: anywidget is also working (cc @manzt)!

@rgbkrk rgbkrk force-pushed the jupyter-runtimelib branch 7 times, most recently from 8e886da to 6747162 Compare May 15, 2024 21:06
@rgbkrk rgbkrk marked this pull request as ready for review May 15, 2024 21:08
@rgbkrk rgbkrk force-pushed the jupyter-runtimelib branch 8 times, most recently from 78b41de to d573de6 Compare May 16, 2024 16:50
@rgbkrk rgbkrk changed the title refactor(jupyter): use runtimelib for Jupyter structs refactor(jupyter): use runtimelib for Jupyter structures and directory paths May 16, 2024
Cargo.lock Outdated Show resolved Hide resolved
Cargo.lock Show resolved Hide resolved
cli/Cargo.toml Show resolved Hide resolved
cli/ops/jupyter.rs Show resolved Hide resolved
cli/ops/jupyter.rs Show resolved Hide resolved
cli/tools/jupyter/install.rs Show resolved Hide resolved
cli/tools/jupyter/jupyter_msg.rs Outdated Show resolved Hide resolved
tests/integration/jupyter_tests.rs Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, we went through this PR during a call and clarified all the details.

This PR moves a lot of code related to zeromq handling to a separate library and opens up a possibility for several refactors that would unblock even more features in the Jupyter kernel.

@bartlomieju bartlomieju merged commit 8698e80 into denoland:main May 21, 2024
17 checks passed
bartlomieju pushed a commit that referenced this pull request May 21, 2024
…y paths (#23826)

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 #21619
bartlomieju pushed a commit that referenced this pull request May 21, 2024
…y paths (#23826)

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 #21619
@rgbkrk rgbkrk deleted the jupyter-runtimelib branch May 22, 2024 12:42
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.

Improve deno jupyter installation DX
3 participants