pavanagrawal123 / VSNotebooks

Jupyter Notebooks in Visual Studio Code
MIT License
63 stars 2 forks source link

Remote kernels/custom environments/better loading bars/Conda support #10

Closed pavanagrawal123 closed 5 years ago

pavanagrawal123 commented 5 years ago

Solves #9! Progress and almost completion for #6! Note: this has not been released to the VSCode store, so if you want to try it out you will need to pull this branch. Want to use this remote kernels? image ^ Add it in the configuration I couldn't really test this scenario so I would love it anyone could help out for testing this! Need to use a custom environment? image ^ This requires the awesome Python extension for VSCode. image Note: Python2 is not supported, will be done in the future! Let me know if you run into any issues!

Other notable changes: We have a progress bar for when kernels are started. image Timeout has been increased to 20 seconds because I have seen it fail frequently at 10 seconds.

benlindsay commented 5 years ago

I tried installing this to test it, but ran into some issues. I cloned it, checked out this branch, ran npm install, then vsce package, and got this error message:

(base) ╭─me@computer / (change-of-path*)
╰─$ vsce package
Executing prepublish script 'npm run vscode:prepublish'...
Error: Command failed: npm run vscode:prepublish
The build command requires to be run in an Angular project, but a project definition could not be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! src-frontend@1.0.1 build: `ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the src-frontend@1.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/benlindsay/.npm/_logs/2018-10-25T13_35_50_736Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! VSNotebooks@1.4.0 compile-frontend: `cd src-frontend && npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the VSNotebooks@1.4.0 compile-frontend script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/benlindsay/.npm/_logs/2018-10-25T13_35_50_929Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! VSNotebooks@1.4.0 publish: `npm run compile-frontend && npm run compile-backend`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the VSNotebooks@1.4.0 publish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/benlindsay/.npm/_logs/2018-10-25T13_35_51_251Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! VSNotebooks@1.4.0 vscode:prepublish: `npm run publish`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the VSNotebooks@1.4.0 vscode:prepublish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/benlindsay/.npm/_logs/2018-10-25T13_35_51_541Z-debug.log

I went through the steps here to make sure I had a Angular installed. Do you know how to fix this, or is there a different way I should be trying this out?

pavanagrawal123 commented 5 years ago

Hi @benlindsay thank you so much for trying it out!

Did you run npm-install in src-frontend? I think that's the issue here!

once you do this, you will need to follow the instructions here to install into VSCode: https://code.visualstudio.com/docs/extensions/example-hello-world#_installing-your-extension-locally

If you have any trouble, I can publish the extension in a beta version to make it easier to try!

pavanagrawal123 commented 5 years ago

If anybody tries this PR, please do let me know if it worked, after some confirmation, I'll merge this into master.

benlindsay commented 5 years ago

I tried running npm install in src-frontend, then the main folder, then vsce package, then I tried running npm install in all of the src-* folders and rerunning npm install then vsce package. I keep getting similar gross errors. If you could publish as a beta I would appreciate it.

pavanagrawal123 commented 5 years ago

Alright no worries, I'll publish a beta extension in a couple of hours. @benlindsay

pavanagrawal123 commented 5 years ago

@benlindsay I published the beta here: https://marketplace.visualstudio.com/items?itemName=pavan.VSNotebooksBeta I have no clue what's going to happen if you have both versions installed, so I would suggest uninstalling the stable build and installing the beta by itself. Also included some of the style improvements; there are just a couple of bugs I need to fix there, but I wanted to get it merged into the beta branch.

benlindsay commented 5 years ago

@pavanagrawal123 Thanks for publishing the beta! I tried it out under my base miniconda python, and unfortunately it couldn't find jupyter. As you can see in the terminal, I do have Jupyter installed. Any thoughts of how to fix this?

image

pavanagrawal123 commented 5 years ago

Hey @benlindsay, I see the issue, and will fix it in a couple of minutes. I was relying on the Scripts folder having Jupyter, but it looks like mini conda is handling it differently. I'm going to change the way where the environment "bin" is determined to be.

pavanagrawal123 commented 5 years ago

hey @benlindsay, I've fixed the issue (hopefully) in v 1.4.2 for beta.

PPBouquet commented 5 years ago

Hey @pavanagrawal123 , I've tested your fix with miniconda, it seems to work ok for now. Thanks for the fix, awesome work ! The procedure : -from the command palette (F1), I type 'Python: Select Interpreter' -I then choose my conda env (where Jupyter is installed) -I open the output pane ---> Working :)

benlindsay commented 5 years ago

Seems to be working with a quick test for me too! I'll keep trying this out and let you know if I run into any issues. Thanks for the great work!

vogt4nick commented 5 years ago

I configured my env correctly (as indicated by the "Starting a Jupyter Kernel at location ...). I also have jupyter installed on that environment. But I'm still having trouble. I can’t put anything in the output pane. Looks like it’s just spinning its wheels.

image

For context, I'm trying to use the fibonacci example:

def fib(n):
    if n == 0:
        return 0
    if n == 1:
        return 1
    return fib(n-1) + fib(n-2)

print("Hello! The first 100 fibonacci numbers are:")
print(', '.join([str(fib(n)) for n in range(10)]))
pavanagrawal123 commented 5 years ago

@vogt4nick I see one bug that will casue it to spin forever, but it shouldn't have failed in that way anyway.

Are you connecting to a remote kernel? Are you using Python 2?

Thanks

fdanieluk commented 5 years ago

@pavanagrawal123 Hey, I've found a little issue with current state of the extension. I work with both 32Bit and 64Bit miniconda. Thing is that it looks only in 64Bit dir (probably the first it found), any walkarounds?

image

Notice difference in paths, ...\AppData\Local\Continuum32 vs \Continuum64.

pavanagrawal123 commented 5 years ago

@imintogoodmusic are you sure you are using VSNotebooks? That doesn't look like the way VSNotebooks handles it... you might be using the default VSCode python extension... That is different from thi

fdanieluk commented 5 years ago

I have VSNotebooksBeta 1.4.4 installed and enabled. I run command 'IPE: Open Output Pane', in bottom right corner appears following pop up: image

Notice in bottom left corner VS recognizes my current conda env, 32bit with jupyter installed. My previous screenshot of cmd prompt was from after I click 'Install' on the pop up. What I believe that happens is that the extensions looks for my env in 64bit miniconda installation.

benlindsay commented 5 years ago

you might be using the default VSCode python extension

@pavanagrawal123 Along these lines, I'm curious, are there use cases for this extension that don't overlap with how the default VSCode python extension handles interactivity?

pavanagrawal123 commented 5 years ago

@benlindsay Not right now. Some of the UI IMO is a little bit better than the default experience. But pretty soon, I'm gonna be working on some fancy things here: #28 and variable exploration will built into this. I have some pretty good ideas for this and I am working on something that I will be publishing as a blog post soon!

pavanagrawal123 commented 5 years ago

@imintogoodmusic thanks for letting me know, I will be fixing this soon :)

benlindsay commented 5 years ago

@pavanagrawal123 I don't know how different the implementation of your extension is to the default python one, but if you add cool features not seen in the default implementation, is there any chance you will make pull a pull request to add it?

pavanagrawal123 commented 5 years ago

@benlindsay I can definitely try, but the change I want to make fundamentally changes the structures of notebooks so I am not sure how willing MS would be to accepting it...

benlindsay commented 5 years ago

@pavanagrawal123 Gotcha, makes sense. Interested to see what that looks like once you implement it! Thanks for your time on this extension

pavanagrawal123 commented 5 years ago

@imintogoodmusic Can you see what it shows in the python interpreter selection screen?

Can you possibly take an screenshot of it?

fdanieluk commented 5 years ago

@pavanagrawal123 There it goes 1

yraaj commented 4 years ago

I am still getting the error that VS Notebooks cannot find Jupyter. I definitely have Jupyter in my path. i am even able to launch it via the vscode terminal. what gives!

pavanagrawal123 commented 4 years ago

@yraaj I would suggest that you use the native VSCode Notebook integration done by Microsoft themselves. This extension is very out of date now!

yraaj commented 4 years ago

How do i do that?

pavanagrawal123 commented 4 years ago

@yraaj I think your best bet would be to post on StackOverflow or read this tutorial here: https://code.visualstudio.com/docs/python/jupyter-support

yraaj commented 4 years ago

I've gone through the tutorial. I am able to launch Jupyter within VSCode. The issue is, it is unable to see any of the variables I have running on a local debugger within VSCode. Is it possible for the variables in the debugger to be shared with Jupyter in VS Code?

pavanagrawal123 commented 4 years ago

@yraaj, I am not sure, I am not associated with the development of the main Microsoft extension.