>> You're not going to want to miss this episode
of the AI show where we talk about how
to use Notebooks directly in Visual Studio Code.
It's pretty amazing, make sure you tune in.
[MUSIC]
Hello and welcome to this special episode of
the AI Show where we have a special guest,
tell us who you are and what you do, buddy.
>> Yeah. My name is Jeffrey Mew,
so I'm a Program Manager here at Microsoft and I work
on the data science and AI for Python and VS Code.
>> So VS code,
tell us about what's cool for
data scientists in there and then I want to dive into Notebooks.
So let's start with what's cool.
>> For sure. So we just released
a new feature or I guess a new product in VS code.
So we released data science features
last October since Jupyter Notebooks for all the range and we
want to offer a first-class support
for Jupyter Notebooks inside VS Code.
>> Fantastic. So let's get into it because I'd rather
show people what's in there instead of just talking about it.
>> Yeah.
>> So tell us what's the experience like for those that
have Jupyter Notebooks. Let's dive in.
>> Sure. So I'm on VS Code right now and I have
the latest version of the Python extensions
installed since that's where the data science features are.
We have a new feature, so if you open up the command palette
with "Control+Shift+P" or a "Command Shift+P" if you're on Mac.
I can type in this new command called "Create
New Blank Jupyter Notebook". So you can see here.
Cool.
Once I run it, it'll create a new Notebook
and you can see now this is what we call,
this is the new feature, what we call a Notebook Editor.
So we can see it's like a really familiar Jupyter Notebook UI.
We have cells or cell actions or global actions as well.
So I can quickly go through some of
the actions that might be really useful.
So you can see like in individual cells we have the run buttons,
we can change the markdown, we can move cells up and down.
Cells also have full IntelliSense.
So if I do something like print,
you can see it gives IntelliSense and then also it has
docstrings as well as you can see what these functions do.
So we once can basically combine the power of
Jupyter Notebooks for experimentation with
data science with the power
of VS Code as an editor and the Python extension as well.
>> So does the output come out in the same place as well?
Because I know we used to have this thing
where it put it somewhere else.
>> Yeah.
So we used to have something called the interactive window,
which we still do as well,
which I'll go into a little bit later.
But now this is more like a Jupyter Notebook UI.
So everything is in line and it's more
as readable and more familiar for data scientists.
>> I see.
>> So if I do something like prints like hi here,
it'll start running Jupyter server
and then once you can see the output is right there.
>> Awesome. So it's basically the same thing
but all now embedded into Visual Studio Code?
>> Yes.
>> Okay. It doesn't look like the Jupyter Notebook actual.
It looks a little different. Can you
tell us what's actually built in there?
>> For sure. So we wanted to give it a familiar new Notebook UI,
so people that are coming from other Notebook tools
they can come over here real easily and get started.
But there's some additional features we added so
I can go through some things on the top.
So this top-level toolbar for
like more of global Notebook actions.
Your first ones that are like runs.
So you have like run all, run above, and run below.
Next we have some of our kernel actions.
So we can do restarting your kernel and interrupting your kernel.
Next we have adding or inserting cells anywhere.
Next we have clearing all output in your Notebook.
The next feature is something that we
added that's pretty cool for Notebooks.
So we have a Variable Explorer.
So what that means is it'll show,
again it's a little bit more late as well,
but right now I know how many variables,
but it'll show all your
current active variables in your Notebooks.
So you can actually see what variables are what value,
and that's one of the common annoyances that data scientists
have with Jupyter Notebooks
because you can run cells out of orders.
You don't really know what the most up-to-date state
of your variable is, that's really useful.
The last two are saves.
So just to save your Notebook and the last one is converting save
to Python script which
basically just converts your Notebook into a Python file,
but I'll against that and why that's useful a little bit later.
>> So this is cool.
We see it in, we made a new Notebook.
Do you have to create a new Notebook in
Visual Studio Code for it to
work or can you use existing Notebooks?
>> For sure.
Yeah. So we want to make the experience really easy for people
to bring their own existing Notebooks
from the other Notebook editors.
So for example, if I have
this other Notebook, data science is cool,
you can see I have a Notebook already with code,
and again I can just run the code with Jupyter hotkeys.
So you can see there I ran
"Shift+Enter" and it just runs it as well.
So don't have to click these run buttons.
Like I mentioned before, I'll once again
some more of the details that we have.
So now that I have
this sleek of code just like this variable called P,
and now I can show you how the Variable Explorer works.
So if I run this,
you can see that these are
all the variables I guess in this notebook that I've run.
>> That's cool.
>> You can see this is P,
so you can see what the type of the variable is
that's in the array and it tells you the size of it.
So here I just made the size
a hundred and then finally I can also go into,
if you go to the far right you'll see the Data Explorer.
If you click on this,
you're going to the Data Viewer and you can actually look at
the entire variable and
I guess it more familiar like Excel format.
So you can see what each variable is and what it looks like.
>> That's cool. So now
because previously when I'm doing "Shift," I
always have to make a new cell and put like
P and then "Shift+Enter" and see what's in there.
>> Yeah.
>> Now we have the ability to actually look at it.
You can see if you look at the screen right now,
you can see the actual rows of what was, that's really cool.
Look, I have a hard time knowing what I "Shift+Entered" on.
>> Yeah
>> What's it's actually a memory and
so that's really cool as well.
Any other features with existing Jupyter Notebook?
>> For sure. So another thing we can
do is what we call a Plot Viewer.
So you can see here, let me just
close the Variable Explorer real quick.
You can see I ran a plot right here and if I hover over the plot,
you'll see on the top left just like this plot icon.
Usually when you run a Jupyter Notebook in plots,
the plots are really small and especially if you
have a lot of data like this one right here,
it's hard to see specifically where your data points are.
So we have this thing called a Plot Viewer.
So we can do is you can click on this and it'll open up in
a much bigger screen and here you can
actually just zoom in on your plot to see for example,
if you want to see where it crosses the x-axis.
Also another really cool feature is
that you can actually save these plots.
So I can save as a PNG or JPEG and then you can actually
export them and use them in
your presentations or show them to whoever.
>> That's really cool. So existing Notebooks.
Now here's the other thing that I
struggle with whenever I use Notebooks.
We got into this a little bit with looking at variables
but how do I debug stuff?
The debug experience is basically, I put something in,
hit "Shift+Enter" and then I'm like that's not right and then,
is something better available in VS Code?
>> Like I mentioned earlier,
we have that interactive window and like I
mention also earlier that we have
this feature called Convert and Save to Python Scripts.
So this is more like when you're done
your Jupyter Notebook and you want
to productionize it and one way of
doing that is you want to go through and debug your code,
all you have to do is click this button and it will
automatically convert
all this Jupyter Notebook code into Python files.
So you can see here, this is the exact same code.
So you can see the first cell was hello world,
the first cell here was hello world as well.
This is what we call interactive window.
So what makes it different from
a regular Python file window or
a Jupyter Notebook window is you
can think of it like a hybrid of both.
So you can see this is your traditional Python file but you also
have some overlays because
it knows it came from a Jupyter Notebooks.
You can see these run cells.
So you can actually run these cells and you actually
get your output on side-by-side.
So this is our traditional Python interactive window.
Like I mentioned for debugging,
if I just save this file real quick, is untitled.
If I want to debug this cell for example,
I can just set break points here as well,
but I can just click this and then click
"Debug Cell" and it'll actually start debugging the cell as well.
You can see it's a full debugger.
So you can see our variables, you can
see our call stack and everything.
>> That's cool. So basically if I'm understanding right,
the workflow for a data scientist would be just like it is now,
try a bunch of stuff in a Notebook,
once you've got something that's semisolid,
you export it using that one button,
then you continue to make it more
refined with the debugging and then you
have something that's hopefully good at the end.
>> Also another thing I want to mention also
is usually when you're doing,
data scientists' big problem
is that they want to leverage compute power.
Oftentimes if you're just running on
like let's say your local machine,
it's probably really not that powerful.
>> Yeah.
>> It might take like a training job,
might take like 10 days or something,
whereas if you had really powerful computer might take an hour.
So to leverage that,
we have a feature that lets you connect to remote servers.
So what you can actually do, is you can see on the
top right right now it says Jupyter Service Local,
so it's running on my local machine.
But there's this command,
so if I do "Control+Shift+P" again to open up the command palette,
I can do specify local or remote Jupyter server for connections.
So I can actually click on this
and right now it's using the localhost,
so on my local machine but I can actually go to existing
and then I can type in my remote servers.
So let's say I'm working in a company and
we wanted to leverage and share compute power,
we can just go in and type in
the URL for this Jupyter server as well.
>> That's cool. So basically you can use not just local resources,
but remote resources as well.
>> In addition, we also support
the remote SSH Extension from VS Code.
So you have this option to connect to a remote Jupyter server,
if you can't install VS Code on your remote server or you can have
the full-fledged VS Code experience
with the remote SSH server as well.
With this we have access to,
if I just exit out of this, we have
access to a kernel selection as well.
So if you're connected to a remote server,
you can click on this and it'll show all your remote kernels.
If you want to share kernels as well, you can do that as well.
>> Holy. Now when you're doing the kernels,
does it have something,
like let's just say I'm using
virtual environments or kernel environments,
does it have some notion of that as well?
>> Yeah, it does. So you can see here it can tell you that,
for example I've kernel environments here,
it'll tell you which ones the kernel
environment and which ones are like,
for example global and it'll tell you
where is Python, where these kernels are.
>> That's awesome. Well cool.
Where can people go to find out
more and start to download these things?
>> For sure.
So to get this entire experience it's completely free,
you just need Visual Studio Code and then
you also need the Python extension for Visual Studio Code.
Since Python is like the main data science language,
so we want to put that data science experience
in the Python extensions.
So as long as you have those two things,
then just bringing your existing Jupyter Notebook
or open and create
a new Notebook and you'll have this
entire experience yourself too.
>> It's just VS Code plus one extension.
>> Yes.
>> This is amazing.
Well thanks so much for spending some time with us.
>> I thank you so much for having me.
>> Thank you so much for watching and
learning all about how to use
Notebooks directly inside of Visual Studio Code.
A ton of amazing features.
Thank you for being with us.
Thank you so much for watching
and we'll see you next time. Take care.
[MUSIC]