-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Set JULIA_PROJECT="@." for kernel #820
Conversation
This seems sensible since starting a notebook in a directory already implicitly works in that directory. The reason that |
Yeah, I've also wanted this many times and I think it makes a lot of sense. 👍 |
Should this be done with a command line argument rather than an environment variable? |
I changed it to a command line argument. I think both versions would work identically, but I agree it is a little bit cleaner. |
Environment variables leak into subprocesses. |
What happens if there is a file named |
Would that be a problem? Maybe we would even want that?
As far as I can tell from the code in base it will never look for a directory (it would have to be a directory, not a file) with that name, because that string automatically triggers the case where it will look for a |
@StefanKarpinski and @KristofferC, is my characterization of what happens when there is a file named @stevengj Beyond that question, anything else we need to do before we can merge this? I'd love to get the whole Jupyter Binder story sorted out, but that is currently waiting for a decision here. |
If there's a file or directory named |
Thanks!
I think that would require a quite different approach from the two that I tried here: this PR here is changing the global kernel configuration, so we can't really write any absolute project path into that. I also actually really like that I think in light of all of this I would suggest that we just stick with the current approach in the PR here with a command line flag. If it turns out that this is causing trouble for sub-processes we can still revisit whether it would be better to use |
That makes sense to me! |
@davidanthoff should you remove |
Good point! @stevengj would be great if you could merge this, I think this is ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but would be good to document this in the README, and link to the section about installing additional kernels for users that want to override this.
Done, I updated the README. |
Thanks! Could we also tag a new release? |
The one thing that was unclear here was whether it was possible to also put a manifest.toml in there, instead of just a project.toml? |
If there is a |
So, one complication that we've seen because of this. We have IJulia in our project's Project.toml file, so when users do Our solution, for now, is that in our project intialization script we're going to also just make sure and install IJulia into the Before, we didn't have this problem because we were setting I'm not sure any of this is a problem, just wanted to report our observations! |
Maybe stick IJulia in the load path somewhere? |
That's an interesting idea. Is that something we could do in the kernel installation? Like add |
You can set environment variables in the kernel file. If |
Could the |
I think this is a great approach. It's also much more proactive than the WARNING that's currently in there: Lines 3 to 9 in aaa7bf4
The one issue I can see is that if you From what I understand, though, by putting it as the last entry of I like it. I'll open a PR with this plan! Thanks for the help everyone! :) |
Hmm, so I opened #834 which does indeed resolve loading IJulia. However, now it just errors when loading IJulia's dependencies, which in retrospect I should have seen coming...:
Maybe the right answer here is just better documentation / error messages so that it's clear from the error that the user just needs to also install IJulia in their top-level environment? |
I appreciate the motivation and the amount of discussion surrounding this, but just thought I'd offer my opinion on why I think this is a bad idea:
So although it does seem useful as an option, due to the above reasons I have this turned off, and IMO this shouldn't be a default. When needed, I can just use |
Perhaps even more to the point, I'd be closer to agreeing with @StefanKarpinski that
but that isn't what this PR does. Instead, it activates the nearest parent Project.toml of a given notebook, regardless of where you've launched the Jupyter server. My use pattern, which I'd guess is pretty typical, is I launch a single Jupyterlab server from my home directory which I use throughout my session (sometimes remote). In doing so I definitely did not mean to give any indication that I want the package activation behavior to be different than base Julia. |
I think this is a really good point that @marius311 makes. @davidanthoff, I think we made a mistake in the implementation of this PR. The reason we opened this PR was so that standard IJulia and MyBinder would have the same behavior, and in jupyterhub/repo2docker#612 we changed MyBinder to automatically start all notebooks with the Project.toml from the top-level of the repo. That is definitely not the behavior we implemented in this PR, as @marius311 points out: instead each notebook you open runs in its own local Project, irrespective of any "top-level" project. Another problem I've run into since we made this change is that the commandline flag I've been thinking about this some, and here are a couple solutions I see:
I actually think I would vote for a combination of proposals 2 and some version of 3 (I like 3.iii). I like 2, because it implements what I think is closer to the expected behavior: launching jupyter from a Project directory causes all kernels to run in that project directory (vs the behavior before this PR, where all kernels ran in |
I think my proposal for number 2 would look like removing the if !haskey(ENV, "JULIA_PROJECT")
# Activate the equivalent of jupyter notebook's `$(pwd)/@.`
Pkg.activate(Base.current_project(ENV["PWD"))
end |
Any further thoughts on this? I think proposals 1 or 2 would be fine. |
@NHDaly @davidanthoff could you or anyone else please revisit this and revert or fix it? Just spent an hour trying to figure out what was borked with a new Julia 1.2 IJulia install only to realize my notebook wasn't in the environment I thought it was because while I had fixed my 1.1 kernel, the new 1.2 install used
I'm happy to submit a revert PR instead of just complaining (although a proper "fix" is beyond me), but I figured this was the group that needed to approve it anyway, hence the post here. |
To be honest, I still think the behavior in this PR is the best solution we can get right now for supporting env in IJulia. Also, at least for me, it has been working great over the last couple of months. I'm not following the issues here on the repo, but I think one major determinant for any potential revert should be how many complaints we got. I count maybe 3-4 folks in this issue that would like to revert. Did we get any other complaints about the new behavior in the forms of issues or on discourse? My sense had been that this PR has been smooth sailing mostly and that there hasn't been much negative feedback, but I might have that wrong because I didn't specifically follow the issues here. Maybe a good process would be to open an issue here that proposes to revert things, then advertise that on discourse and slack and try to get thumbs up and down on the proposal and then decide based on that? I think a broader issue is still that it would be great if one could configure an env per notebook, and have a UI that shows the active env. That would all obviously require coordination with the Jupyter crowd, but I think that is essentially really the UI that would make sense. I don't think any approach based on the folder where Jupyter was started can work: while Jupyterlab for example shows a "root" folder, other clients like nteract don't even have any such concept. |
This is one way to handle #750.
What this would do is that whenever you open a notebook, if there is a
Project.toml
in the folder of the notebook, or in one of its parent folders, that environment will be the active environment for the kernel of that notebook.My understanding right now is that we are not going to somehow embed env info in the notebook itself, so this might be the next best thing to get around these annoying
using Pkg; pkg"activate ."
that one needs now at the top of each notebook if one is using environments.This issue came up in the context of binder and jupyterhub/repo2docker#612.
Pinging a couple of folks that I think should opine on this: @StefanKarpinski, @KristofferC and @stevengj.