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

nixos/jupyter: migrate service to jupyter 7 setup #367106

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

b-m-f
Copy link
Contributor

@b-m-f b-m-f commented Dec 21, 2024

The current implementation has problems after the jupyter project introduced changes: https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

This MR:

  • changes the location of the config file for the password setting
  • links to the official docs for hashed password generation
  • uses jupyter notebook command
  • allows adding extra packages to the jupyter runtime environment
  • allows setting extra environment variables

The last 2 changes come with an example in order to add export to WebPDF.

Closes #355046

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab labels Dec 21, 2024
@b-m-f
Copy link
Contributor Author

b-m-f commented Dec 21, 2024

@aborsu

@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 21, 2024
@GaetanLepage
Copy link
Contributor

Thanks for this.
Can you clean the commit history and prefix all commit messages with nixos/jupyter: ?

@b-m-f b-m-f force-pushed the master branch 2 times, most recently from c306cf1 to 672818d Compare December 21, 2024 14:12
@b-m-f
Copy link
Contributor Author

b-m-f commented Dec 21, 2024

@GaetanLepage Updated. Thanks for the guidance

@GaetanLepage
Copy link
Contributor

@GaetanLepage Updated. Thanks for the guidance

The current commit message is Updates jupyter notebook config to work correctly with current versions.
It should start with nixos/jupyter: .....

@b-m-f
Copy link
Contributor Author

b-m-f commented Dec 22, 2024

Updated 🫡

@b-m-f b-m-f force-pushed the master branch 2 times, most recently from 1d673a5 to e842be7 Compare December 23, 2024 09:22
@JohnRTitor JohnRTitor changed the title Migrate jupyter notebook service to jupyter 7 setup nixos/jupyter: migrate service to jupyter 7 setup Dec 23, 2024
Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Blocked until the above comments are resolved

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Please add a release notes too.

@b-m-f
Copy link
Contributor Author

b-m-f commented Dec 25, 2024

I’ll implement the changes either on the 31st or in the new year.
Thanks for the input

@b-m-f
Copy link
Contributor Author

b-m-f commented Jan 2, 2025

@JohnRTitor MR is updated

@b-m-f b-m-f force-pushed the master branch 2 times, most recently from 1151605 to 4368108 Compare January 3, 2025 16:26
@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog labels Jan 3, 2025
@b-m-f
Copy link
Contributor Author

b-m-f commented Jan 3, 2025

@JohnRTitor I have added the change into the release-notes. I hope that is the correct place. Notebook config is now included again.

@JohnRTitor JohnRTitor dismissed their stale review January 3, 2025 16:59

changes addressed

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Should be backported to 24.11 as notebook 7 exists there too. Please add a release-notes for 24.11 as well.

Diff LGTM, will merge after testing.

nixos/doc/manual/release-notes/rl-2505.section.md Outdated Show resolved Hide resolved
@JohnRTitor JohnRTitor added the backport release-24.11 Backport PR automatically label Jan 3, 2025
@b-m-f b-m-f force-pushed the master branch 2 times, most recently from 5b4a927 to 9775de7 Compare January 3, 2025 17:10
JohnRTitor added a commit to JohnRTitor/nix-conf that referenced this pull request Jan 4, 2025
Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Did some minor nitpicks.

And tested the module like this JohnRTitor/nix-conf@b6c504a

Lets me login now (with a previously generated password). But when I tried to generate a new one it showed an error. Could you investigate?

image

I am using a pretty basic config. https://github.com/JohnRTitor/nix-conf/blob/b6c504ab5ad36af2e4e0191fa4ca9fa67e04efa4/dev-environment/jupyter.nix

The above code snippet works if I use the server from

nix-shell -p 'python3.withPackages (ps: with ps; [jupyter])' --run 'jupyter notebook'

@b-m-f
Copy link
Contributor Author

b-m-f commented Jan 5, 2025

@JohnRTitor Thanks for the attention to detail!

As for the error with password generation it looks like expected behaviour to me.

The code in the notebook will run within its own execution environment, the kernel, this is isolated from the execution environment that the server itself runs within. https://docs.jupyter.org/en/latest/projects/kernels.html

jupyter-server is not included there by default.

You could try the following kernel to get it to work:

    kernels = {
      jupyter =
        let
          env = (
            pkgs.python3.withPackages (
              ps: with ps; [
                ipykernel
                jupyter
              ]
            )
          );
        in
        {
          displayName = "Python 3 jupyter env";
          argv = [
            "${env.interpreter}"
            "-m"
            "ipykernel_launcher"
            "-f"
            "{connection_file}"
          ];
          language = "python";
          extraPaths = {
            "cool.txt" = pkgs.writeText "cool" "cool content";
          };
        };
    };

When the kernel is set up this way it will be selectable in the UI.

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Nice, thanks.

Let me just rebase so we remove the merge conflict here.

… current versions

Signed-off-by: Maximilian Ehlers <[email protected]>
Signed-off-by: John Titor <[email protected]>
@JohnRTitor JohnRTitor merged commit f199d57 into NixOS:master Jan 5, 2025
15 of 16 checks passed
@nix-backports
Copy link

nix-backports bot commented Jan 5, 2025

Backport failed for release-24.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-24.11
git worktree add -d .worktree/backport-367106-to-release-24.11 origin/release-24.11
cd .worktree/backport-367106-to-release-24.11
git switch --create backport-367106-to-release-24.11
git cherry-pick -x f199d57ad67ebebf001f50db0f6f823ad1cf0835

@JohnRTitor JohnRTitor added 8.has: port to stable A PR already has a backport to the stable release. and removed backport release-24.11 Backport PR automatically labels Jan 5, 2025
JohnRTitor pushed a commit to JohnRTitor/nixpkgs that referenced this pull request Jan 5, 2025
Signed-off-by: Maximilian Ehlers <[email protected]>
Signed-off-by: John Titor <[email protected]>
(partially cherry picked from commit f199d57)
yechielw pushed a commit to yechielw/nixpkgs that referenced this pull request Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: port to stable A PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jupyter notebook package is broken and service does not work
3 participants