Everyone I'm Jeffrey a PM at Microsoft for Python data
science, and AI tools in Visual Studio Code and in this video
we're going to be showcasing off some of our brand new
Jupyter notebooks features for the Python extension in
Visual Studio Code and also how you can leverage them to
Supercharge your own data Science Workflow with
notebooks.
So before we get started to access the Jupyter notebooks
features, you'll actually need to install the Python extension
for Visual Studio Code and you can do this really easily from
the extensions tab on the left side here and just click
extensions and search for the keyword Python and then from
here you can just click install. As you can see I've already pre
installed it for the sake of this video, so once you actually
have the Python extension installed to get to the Jupyter
notebook editor, you can either open up any existing notebook
you already have on your computer, or if you want to
create a new one, simply just open up the command palette so
you can use the.
If you're on a Windows computer you can use the shortcut control
shift P, but if you're on a Mac command shift P and once in
the command palette you'll want the search for the
command, create new blank Jupyter notebooks. You can see
here.
So this will now launch what we call our notebook editor. It's a
Jupyter Notebook UI interface within VS code so you have your
cell input, your cell output and all the things you get with
a traditional notebook, but you combine it with the power and
flexibility of VS code as editor and IDE so you get a lot
of things such as so if I do like import numpy as NP.
And then you get full intellisense support. So if I do np dot it
gives me suggestions on what are the top functions use with
numpy package so I can do like np dot array making an array let's
say 123. And I can set this to be some variable name X and then to
either run the cell. You can either click on the run cell
button above, or you can. Actually we fully support
Jupyter hotkeys, so you could actually do a hot key of control
enter and it will also run like here. I can also
print it so you can see the output do print x and do the same
thing. You'll see the output there
as well. So let's move on to another notebook. So here we can
see in this notebook I've already generated some plots
from Matlab plot. As you can see, a lot of times with plots it's
hard to notice things when it's like super small in the output
it's hard to really analyze your graph. So we have this really
cool feature called the plot viewer. Where if you just hover
over the graph you see this icon in the top left, and if you
click on it, open it and what we call it plot viewer and here you
can actually zoom in on the plot if you want to look at like your
data points more clearly or the other cool features, you can
actually save this plot. Different formats you can save
as PDF, different image files as well if you want to share this
plot with others. If we also go back to the notebook you'll see
below in this cell, we also have full support for standard and
custom IPyWidgets. So here you can see some, not really sure
this is maybe some molecules, but you can see like interactive
as interactive IPyWidget, which is all fully running within our
notebook editor. Another really cool feature we have is called
the variable Explorer, so often times, although notebooks are
really flexible where you can run cells out of order and
multiple times one of the biggest annoyances with this is that
you have to keep track of the state of all your variables and
what your variables are. So we made that really easy with just
the variable Explorer where you can access at the top. So if you
go to the top toolbar you can click on the variable explorer
icon and it will show you all of the current active variables in
your notebook. So here's all the variables that I have, at least in my
notebook. Um and I'll show you, like, it will show you other
useful information, such as like the type of the variable. So for
example, it's like a ND array. If it's a list will show like
this size of the list as well, and you can also look at the if
you want to take a look at what your variable is, you can click
on this icon on the right.
And opened up in what we call it data viewer.
So you'll notice this is an excel like format where you can
quickly look at your data and you can also do some data
filtering. So for example if I want to look at my data set and
do some sanity checking to see like let's say there's no
numbers less than zero, I can do that one. I can see all the
numbers are less than one, so these are some really useful
features that we think that will help a lot of data scientists.
Another feature we have added is we just close. This is called
the kernel Switcher, so we have multiple kernels on your machine
or environments and they each have their own packages or
different versions of packages and you want to set your
notebook to use one of them. All you can do is you go in the top
right corner of your screen in the toolbar. You can see this is
our kernel Selector. It tells the current kernel, the current
kernel you're using right now, but also
shows the status. You can open the kernels selector and you see
all the kernels in your system, and then if you just
want to change to another one, you can just click on it.
As a data scientist, you often want to leverage more compute
power for training job or you just want to work in the cloud.
We made it really easy to connect to remote Jupyter
servers. So to do this you just have you to go back to the
command palette so the control shift P or command ship P if you're on a
Mac and you can search for the command. Specify local or remote
Jupyter servers for connections so you click on this. By default it
is set to use your local machine of course, but if you just click
existing here we can now specify your remote server. So if you
have something on. Cloud running you can connect to that or if
you have something on your remote desktop you can connect
to that server as well.
Another thing I also want to point out is regarding remote is
we also have full support for the remote SSH VS code
extension. So if you do remote.
SSH. You see, we fully support this experience as
well with the notebook editor.
Another exciting feature that one of show off is something
that we call it gather, gather analyzes notebook's and code
dependencies as you run your code and it helps users extract
only the relevant code segments needed to recreate our
particular cell or particular cell output. It's an experimental
feature that hasn't been released to the public yet, but
it's going to come out soon, so I just want to showcase it off.
So let's just move on to another notebook I have called gather
demo and here I'm going to actually show off how gather
works. So as you run cells.
Gather will periodically keep track of all the dependencies
and code dependency, so here you can see I have two variables
x and y. I do some multiplications or additions and Subtractions. x and y
have some loops of some print statements, and then finally I
print out the value of X. So here we can see the value of X is 6.
Let's say I only wanted all the code required to generate the
cell, so just give me the X equals 6. I would just click on
this icon here, which is the gather icon and it will create a
new notebook for me that has.
Only the relevant code cells that are needed to generate that
notebook. So you can see here it only pulled the relevant code.
Cells are left out all the Y variables and left side of the
print statements, and only if I run this notebook again, you can
see you'll get the value of 6.
And although this is a trivial example, you can see how this
could apply for more complex examples. So let's say you have
like a big training job. You only want the code that
generates the final output, which is the model or the
correct training job with the correct parameters. All you need to
do is just click on you gather icon for that cell, and it would
generate, analyze the dependencies in your notebook and
generate just the code required to create that cell.
And finally, when you're done with your notebook and are ready
to turn your, turn it into Python code to productionize
it, rather than just having to copy and paste all these
cells and put into another Python. We made this easy
with this convert and save as Python script function.
So this is in the top toolbar. If you click it, it will
automatically convert your code from this notebook format into a
Python file and it actually opens up in what we call our
Python interactive window. So you can think of this as like a
hybrid between the notebook editor like what we saw previously
and a Python file. So from the interactive window you can still
do things such as run sells like you would with the regular
notebook. Or you can just run the entire file like a regular
Python file and also being in the interactive window brings a
lot of other cool features such as debugging, so you can
actually debug your Jupyter notebooks now, you can
do things such as extracting methods, go to definition,
renaming variables, many more
things. One last thing I want to point out is that there's a
new service from the VS code team. It's in preview right
now, but it's called a Visual Studio online and it gives you
the same VS code interface and the same user experience the
same features and functionality that I just showed in this video,
but all within your browser. So as a data scientist or software
engineer. If I'm working with notebooks, I don't actually
need to install anything on my machine and I can just go into
the browser, go to online.visualstudio.com, and
just access all the same notebook features and edit my
notebook just as if I was in VS code.
You can actually try out the notebook editor today and all
the features and functionality that showed you in this video.
All you need to do is to download vscode, the Python
extension and all you need to do is just create or open an existing
Jupyter Notebook. You can find all the information in the link
on the screen below. So just aka.ms/notebooks. Super
easy to remember. Yeah, thank you everyone for watching this video.