jupyterhub / repo2docker

Turn repositories into Jupyter-enabled Docker images
https://repo2docker.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.62k stars 362 forks source link

Julia Buildpack: Unconsistent behaviour of Julia Project selection. #894

Open axsk opened 4 years ago

axsk commented 4 years ago

Hey all, I'd like to start with saying that all this here is really great!

I stumbled across the following problem though: When having a Julia package with the following structure

MyPkg.jl
- notebooks
 - mynotebook.ipynb
 - Project.toml
- src
-- (source files)
- Project.toml

and I open the mynotebook.ipynb in Jupyter, it usually (local Jupyter installation) uses the notebooks-local Project.toml file. (Defaulting to @., c.f. https://github.com/JuliaLang/IJulia.jl/pull/820)/ When using repo2docker though, the behaviour is different. It now reads the Packages' Project.toml.

I think this is due to: https://github.com/jupyter/repo2docker/blob/bbc3ee02c0755b15ea456f9ae18dd76b904568e7/repo2docker/buildpacks/julia/julia_project.py#L139

With the default IJulia behaviour it is possible to publish a Julia package, which contains only the necessary dependencies whilst still having an example environment (notebooks) with additional dependencies (e.g. PyPlot.jl). (This still leaves the problem that the requirements.txt for the matplotlib dependency is still in projects' main directory though)

A hotfix would be prepending ]activate . but would that be the intended way?

Pinging @davidanthoff

davidanthoff commented 4 years ago

Yes, this is a good point.

I think in general we might want to tweak what we have right now in the following way:

  1. Instead of adding IJulia.jl to the project in the root, we should modify this line to create a new project somewhere outside of the user folder and add IJulia.jl to that project. We would then have to set JULIA_LOAD_PATH to make sure this new env always gets loaded as a stacked environmnt. The main benefit of this change would be that a) we don't modify the users project, and b) the IJulia.jl stuff is also available for other projects.
  2. We scan the whole directory tree of the user repo for Manifest.tomls (with accompaning Project.tomls) and instantiate and precompile all of the environments we find during the build phase, not just the one in the root as we do right now.
  3. We remove the special casing of how projects are selected and just move to the IJulia.jl default.

@NHDaly, does that make sense to you?