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

pythonPackages.jupyterhub: Fix running locally #58542

Merged
merged 1 commit into from Mar 31, 2019

Conversation

infinisil
Copy link
Member

Motivation for this change

Fixes #58540

Ping @jluttine

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after) 277.8MB -> 325.1MB (+17%)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@dotlambda
Copy link
Member

@infinisil
Copy link
Member Author

@dotlambda Hmm it is in dev-requirements.txt

@infinisil
Copy link
Member Author

I did find jupyterhub/jupyterhub@0414a0be which removed ipython[notebook] from requirements.txt, not sure if that's related

@infinisil
Copy link
Member Author

Ah yeah, they mention it in the readme:

If you plan to run notebook servers locally, you will need to install the Jupyter notebook package

So it's only an optional dependency for local servers

@jluttine
Copy link
Member

Why it doesn't work by adding notebook to the same nix-shell environment as I did in #58540?

@infinisil
Copy link
Member Author

@jluttine Because it gets wrapped with a PYTHON_PATH that contains exactly the packages that were declared in the build.

@jluttine
Copy link
Member

Ok. So one should write an overlay to modify the build inputs if running the notebook servers locally? That sounds like something that should perhaps be made a bit simpler because it's probably a typical usecase. Not sure how though.

@infinisil
Copy link
Member Author

@jluttine Well this PR fixes it, so if this gets merged you don't have to do anything to get it running.

If you want to get it running without this PR, you can use the following overlay, which looks totally ridiculous, but actually is the "proper" way to override stuff like that:

self: super: {
  python3 = super.python3.override (old: {
    packageOverrides = super.lib.composeExtensions (old.packageOverrides or (pself: psuper: {}))
      (pself: psuper: {
        jupyterhub = psuper.jupyterhub.overrideAttrs (old: {
          propagatedBuildInputs = old.propagatedBuildInputs or [] ++ [
            pself.notebook
          ];
        });
      });
  });
}

@jluttine
Copy link
Member

Thanks! That's what I thought that proper overriding is probably a bit tedious for the typical usecase. But in a way this pull request isn't the "correct" fix either because notebook is just an optional dependency, not required by JupyterHub except in some cases. I have no idea what would be the correct fix..

@dotlambda
Copy link
Member

Alright, seems sensible. Could we add a comment on why notebook is there so that it isn't removed in the future?

@dotlambda
Copy link
Member

dotlambda commented Mar 29, 2019

But in a way this pull request isn't the "correct" fix either because notebook is just an optional dependency, not required by JupyterHub except in some cases.

We usually include optional dependencies if it's requested.
Alternatively, we could add a top-level attribute using toPythonApplication and override the jupyterhub derivation used. Then, people won't have the optional dependency of they only use it as a library.

@jluttine
Copy link
Member

To me, adding notebook to build inputs seems like the best practical solution, yes. Probably not much harm to include it there even if it's not always strictly necessary.

I tested and it indeed fixes the issue and now Jupyter Hub is running fine.

About the alternative, if I understand correctly, the dependency of notebook seems orthogonal to the question of whether Hub is used as an application or a library. People could use it as an application without running the notebook servers locally.

@jluttine
Copy link
Member

I've sometimes seen some optional arguments to derivations, something like: useCoolThing ? false. Not sure if that would be useful here. For instance, includeNotebook ? true. Then, I guess, it could be relatively easily disabled (although I'm not familiar how those arguments are overwritten).

@infinisil
Copy link
Member Author

@jluttine These arguments would be overwritten with jupyterhub.override { includeNotebook = true; }, but I don't think we need to add such an argument if nobody minds having it included by default. The only disadvantage is a 17% increase in closure size and the advantage is that it just works by default. I think the advantage far outweighs the disadvantage.

@jluttine
Copy link
Member

Sounds good.

@infinisil infinisil changed the title pythonPackages.jupyterhub: Fix pythonPackages.jupyterhub: Fix running locally Mar 29, 2019
@infinisil
Copy link
Member Author

Ping @FRidh and @costrouc

@dotlambda
Copy link
Member

About the alternative, if I understand correctly, the dependency of notebook seems orthogonal to the question of whether Hub is used as an application or a library.

It isn't since when used as a library, withPackages can be used.

@jluttine
Copy link
Member

@dotlambda Ah, true! Thanks for clarifying!

I would merge this either as it is now, or add withNotebook ? true optional argument so that it is explicit that notebook isn't required but is just for convenience added by default. But as said, probably nobody ever cares so much about the slightly larger closure size that they'd set it to false..

@infinisil infinisil merged commit 6705421 into NixOS:master Mar 31, 2019
@infinisil
Copy link
Member Author

Backported to 19.03 in a05b0cf

@jluttine
Copy link
Member

jluttine commented Apr 1, 2019

A bit related issue I now encountered: #58662

@infinisil infinisil deleted the fix/jupyterhub branch September 17, 2021 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JupyterHub broken (ModuleNotFoundError)
4 participants