nixos/jupyter: init service#33673
nixos/jupyter: init service#33673aborsu wants to merge 3 commits intoNixOS:masterfrom aborsu:jupyter
Conversation
|
Related issue: #10713 |
There was a problem hiding this comment.
I think it is better to keep this out of the store. Maybe you can point to a path and read that during runtime?
There was a problem hiding this comment.
I made a compromise on that, that I think should be agreeable to all.
There was a problem hiding this comment.
ipykernel should be sufficient as the notebook should already be offered by this service
|
I think the logic of creating a |
|
@FRidh I agree, but it was a bit more work. |
|
@FRidh @globin |
FRidh
left a comment
There was a problem hiding this comment.
I think it is good to have a separate derivation for the kernel config, and having a new top level item for Jupyter. However, instead of making it a derivation that needs to be overriden, I suggest making jupyter a function:
kernelDefinitions: { the, other, args }: derivation
There was a problem hiding this comment.
let
...
in with python3.pkgs; toPythonModule (notebook.override {
makeWrapperArgs = ["--set JUPYTER_PATH ${jupyterPath}"];
});
toPythonModule (buildPythonPackage {...}) is basically the same as buildPythonApplication. In this case I would go for the former, because the current approach requires keeping up with required attributes.
There was a problem hiding this comment.
let
defaultKernelDefinitions = {
...
};
in {python3, lib, kernelDefinitions ? defaultKernelDefinitions }:
There was a problem hiding this comment.
this is then defaultKernelDefinitions
|
@FRidh I'm not convinced making the top package jupyter a function is such a great idea. Even if I give a default argument, the function still needs to be called. It seems to me that override is a standard way of providing customizability to packages and will avoid a lot of pain while imo not reducing understandability or ease of use. As always I'm ready to discuss this further. And thank you for your helpfull corrections. |
|
@FRidh ping? |
| @@ -0,0 +1,16 @@ | |||
| { pkgs | |||
There was a problem hiding this comment.
pkgs is not used, adding jupyterKernels is better
|
|
||
| in | ||
|
|
||
| kernelDefinitions: ( |
There was a problem hiding this comment.
{ kernelDefinitions ? defaultKernelDefinitions
}: | in { | ||
| displayName = "Python 3"; | ||
| argv = [ | ||
| "${env}/bin/python" |
| @@ -0,0 +1,88 @@ | |||
| {pkgs, lib}: | |||
There was a problem hiding this comment.
@FRidh I'm not certain this is better.
Now I'm exporting a set instead of exporting a function so I can re-use the default value in all the packages that might use it.
There was a problem hiding this comment.
I've basically had to move the null check here now.
I though of passing the pkgs.jupyterKernels.defaultKernelConfig as the default value for jupyter.kernels, but the it complains that it contains a reference to a derivation. (I can understand that having to build a derivation to create the doc is not the greatest).
|
@FRidh opinion? |
schneefux
left a comment
There was a problem hiding this comment.
compiles and runs basic examples
|
Mind providing an example of how to get Jupyter installed with these changes? |
|
Here is my configuration (the password is "test", change it): services.jupyter = {
enable = true;
port = 8123;
notebookDir = "/var/www/jupyter";
password = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'";
}; |
| env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ | ||
| ipykernel | ||
| pandas | ||
| scikitlearn |
There was a problem hiding this comment.
Are these Jupyter dependencies or just nice to have packages?
There was a problem hiding this comment.
ipykernel is needed, the others are just basic packages used for data science.
I was thinking of getting something inline with the jupyter dockerimages.
Base python, base data-science, data-science + spark
There was a problem hiding this comment.
Keep the default as minimal as possible.
|
I plan to draft a sort of RFC issue for Nixpkgs where we could coordinate data science infrastructure work. I would like to provide an overview or stuff related to the Jupyter ecosystem, Python data science ecosystem and Haskell data science ecosystem; perhaps other stuff too, but scoping this is a little tricky, so I think that is an okay start.
I plan to make a script to query nix search (which can return JSONs now) for a package list. datahaskell.org provides a nice overview of interesting Haskell stuff but I would still need to find a decent Python list.
|
|
@ixxie for python, using the packages used by the jupyter docker images would be a good start https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook |
|
@aborsu thanks for the tip Sorry everybody about that offtopic-ish post; I didn't realize I could reply to an email in my mail client and it would post to GitHub! |
|
I have been using this for the last few weeks and it works nicely 👍 |
|
I got this working on my machine, except setting |
|
I have set |
|
@phile314-fh - looks like you did it manually. With @cleverca22's help I managed to resolve this by adding: and to @aborsu - its probably easiest if you add it yourself to the PR? |
|
Hello, sorry, I've been a bit busy. |
|
@aborsu I think I will soon use this as a template to create a Jupyterlab service and it occurred to me that if that would go in Alternatively we can have: or is this a bit awkward? |
FRidh
left a comment
There was a problem hiding this comment.
I don't really have the time to review this any further, so please ask also other maintainers if they can help it forward / get it in.
| env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ | ||
| ipykernel | ||
| pandas | ||
| scikitlearn |
There was a problem hiding this comment.
Keep the default as minimal as possible.
|
|
||
| wantedBy = [ "multi-user.target" ]; | ||
|
|
||
| path = [ pkgs.bash ]; # needed for sh in cell magic to work |
There was a problem hiding this comment.
Have you considered patching notebook to hardcode bash?
|
|
||
| let | ||
|
|
||
| jupyterPath = (jupyterKernels.create { kernelDefinitions = kernelDefinitions; }); |
| argv = mkOption { | ||
| type = types.listOf types.str; | ||
| example = [ | ||
| "{customEnv}/bin/python" |
| logo32 = mkOption { | ||
| type = types.nullOr types.path; | ||
| default = null; | ||
| example = "{env}/lib/python3.6/site-packages/ipykernel/resources/logo-32x32.png"; |
| in | ||
|
|
||
| with python3.pkgs; toPythonModule ( | ||
| notebook.overrideAttrs(oldAttrs: { |
| @@ -0,0 +1,76 @@ | |||
| { lib, pkgs, stdenv}: | |||
| meta = { | ||
| description = "Wrapper to create jupyter notebook kernel definitions"; | ||
| homepage = http://jupyter.org/; | ||
| # NIXOS license as this is a nixos meta package. |
|
|
||
| src = "/dev/null"; | ||
|
|
||
| unpackCmd ="mkdir jupyter_kernels"; |
|
|
||
| unpackCmd ="mkdir jupyter_kernels"; | ||
|
|
||
| installPhase = '' |
|
@dotlambda perhaps you have time to have a look? |
|
Not until Sunday or even next week, sadly. |
|
I was wondering if you could provide a sequence of recent PRs some context and have a Nixpkgs data science workgroup so I made a data science workgroup page on the wiki and #nixos-data on freenode. |
|
@ixxie Please fix the things FRidh mentioned. I'll then take a look. However, I've never worked with Jupyter on NixOS so I might need some time to read through it. |
|
@dotlambda well this is @aborsu's PR really and I believe he is on it; if he doesn't have time eventually I can take over, but this is great work and I would hate to steal the credit ;) I am working on the Jupyterlab module (no PR for that yet). |
|
Really looking forward to this. Keep up the good work @aborsu :D |
|
I've made some minor changes and pushed to master 4d3ce5c. |
|
I'll try to give some feedback on the feature, has anyone tried it with an haskell kernel already ? |
|
In #51030 I add jupyter support for sage. I've added it so that |
Motivation for this change
I believe that having a configurable service for jupyter with a template to write new kernels is a wanted feature.
cfr
https://www.reddit.com/r/NixOS/comments/7oujo4/getting_all_the_jupyter_kernels/
#10713
Things done
build-use-sandboxinnix.confon non-NixOS)nix-shell -p nox --run "nox-review wip"./result/bin/)This pull requests brings a jupyter service to nixos.
It contains a default bare python3 kernel and a literal example on how to define multiple kernels.