Hi I’m Philip from the HANA Academy. In
this series of videos were looking at
the External Machine Learning Library
which was introduced with HANA 2 SPS
02. In this video we're going to get
started with HANA 2.0 SPS02. We’ll be
using HANA Express in the Google Cloud
Platform. Now the first thing you'll want
to know when you're working with the
EML is where to find the
documentation, the reference guide. So for
that we'll go there first. We go to help
SAP.com / HANA _
platform and we can see on the right
it's the version 2.0 SPS02 and then to
find the EML reference guide we need to
go to the reference section down here on
the right. Click on view all and then
we'll see in the full list
we'll get there it'll actually be
quite close to the predictive library so
the HANA External Machine Learning
Library. So click on there we've got the
full reference guide that explains how
to get started. Talks about the models
and call signatures with examples talks
about deploying in mapping models in
your landscape. Now you can either use
the online version of the reference
guide like this or if you want you can
download it as PDF for offline usage. Now
if you want to follow along with the
examples that are in this in the next
few videos then you should also go to
the GitHub repository from the HANA
Academy. So to find that go to github.com
/ SAP HANA Academy and then look in
the repositories section where you'll
find EML External Machine Learning
Library and in there we've got both
source data and code snippets. So this
particular video we're on EML 06
getting started with HANA
2.0 SPS02. So we can see there's some
code that we're going to want to
actually run there. Now in order to work
with the External Machine Learning
Library you need to make sure you've
done two things. One is that you've
actually installed it and secondly that
you need to do some configuration on
your HANA machine as the system user to
actually make it available and usable. So
as I'm using HANA Express
just going to go and show you that in
the download manager and I'll go to the
binary installer version you can see
that one of the download options is the
HANA External Machine Learning Library.
So make sure to check that if you're
installing the binary version and then
you'll get the option when you actually
install the rest of the HANA Express
that it will also install the External
Machine Learning Library for you. So it's
not necessarily installed by default. So
let's connect to our HANA system. Now
I've got it here I've actually set it up
using HXE host as the host name which is
pretty much a standard when we're
working with HANA Express. We’ve used the
default settings for installation so
it's called HXE, that's the
system name and also its installed in
instance number ninety, 90. So you can see
that to actually get to our main end
point we would go to HTTPS and then
HXE host, your hostname, : and
then 3 then the instance number 90
and then 30. This basically gets
you to the point where you can see that
your system is up and running. It’s the
full version so server plus Apps because
that means we've got the database
Explorer available on the web.
We don't need Eclipse or HANA Studio.
You'll see that you've got URLs here
that allow you to do different
things.
Now what we want to do is to go to Web
IDE so that we can access the database
Explorer. Normally you'll find it on port
53075 but it's often a good idea
to come here and just to be sure then
you get a link. So I'm going to log in as
the XS advanced developer user which is
delivered by HANA express. The very first
time you're going to get a tips and
tricks video. I'm going to just say I
don't need that anymore.
Of course you can watch that. Now to
access the Database Explorer what we
need to do is go to the left and on that
pane we can see there's a Database
Explorer option and it will prompt us
the first time if you want to add a
connection. Basically add a database in
our HANA system. So the way we're going
to connect to the database is to use the
SAP HANA multi-tenant database option.
The name of our host while we've seen it
up here is HXC host that's how we'll
connect to
the HANA system. Instance number 90
90 and first of all connect to the
system database. Now you will set that up
already when you configure to HANA
Express you'll know what that password
is going to be. I'm going to choose to
save it. I'm using the system user. So
we're now connected. We got the catalog
diagnostic files. Now what I want to do
is run some SQL. So having selected or
it's already selected the system user
for the system database on our hosts I’m
gonna hit the SQL button and now I
can paste in some code. So we're gonna
find that code in GitHub we were there a
moment ago. See we need to run the first
few statements against the system DB
database. So let's copy and paste those
statements from line 5 to 14 inclusive.
What this is actually going to do is a
couple of things. Firstly we're going to
check that the EML has actually been
installed. So to do that we can just run
some select statements to select them
and run and if we get rows back then
everything should be good. So you can see
that for the first select we get a row
for the EML area name, the second set we
get a row again for the EML EML lib
package name and the third row we get a
number of different functions. These are
the functions that are provided as part
of the External Machine Learning Library.
If you get no rows back it probably
means you forgot to install the EML. So
you'll need to go ahead and do that on
your system. Now the second thing we'd
want to do is check our tenant databases.
Now normally with HANA Express you've
got a tenant database which is the same
as the system name. So in our case HXE.
You can see that the tenant database is
there and it's up and running. So you
need to make sure your tenants up and
running and what we need to do is to
start the script server service in that
tenant database because that's where the
EML is actually going to run. So we can
do that with an alter database statement.
So we're going to add the script server
to our HXE tenant database and this
will take maybe about 40 seconds.
So that's now completed and we can see
in the messages that the statement was
executed. Okay so we're good as far as
the system database is concerned but now
we also need to do some configuration in
our HXE tenant database where the EML is
actually going to be running. So let's
close that window. We’re going to make a
connection to our HXE tenant as the
system user of that HXE tenant. So the
same process we saw a moment ago
Multi database tenant, the hostname
HXE host, instance number 90 but
this time tenant database with the name
HXE and again the user with system and
whatever password you used when you set
up in this case HANA Express. So let's go.
So now we can see we've got our
connection to the HXE tenant. Again
we'll open up a SQL window. Make sure
that you've connected to the correct
database. It’s not the system database
this time it's the HXE tenant and we'll
go back to our coding GitHub and you'll
see that from basically line 17 to the
end is script that I'm going to copy and
paste in which we need to run against
our tenant database. Now what are we
actually doing here. Well the first thing
is we can just check that the script
server has actually been set up and is
running in the tenant and you can do
that with the select star from the SYS M
_ services view and that will
give you a list of services and if we
scroll down and you may need to click
inside and use the down arrow to get to
the last one in the list which should be
script server and if you scroll across
then you should see that it's actually
active up and running. So we're looking
good. That script server has been started.
Now when we want to work with the
External Machine Learning Library we
need a set of authorizations. We need to
authorize the administration side and
usage side. So the easy way to do that is
to create a user which we're going
to do. We’ll call it EML user and then
we'll do the authorizations on that user
and we'll log in as that user later to
do the work we need to do. So I'm going
to create a user called EML user with
a very simple default password. Now it
may be that you lose this little run
button so you sometimes have to be
careful. Just click. You may well just get
it back. So that's the user created. Now
what we need to do are add the following
roles. We need to grant monitoring to the
EML user and we need to grant the
ability to create remote sources
because we're going to configure
TensorFlow models through remote sources
and then you need to grant full rights
to actually a table for EML model
configuration which is in the _
SYS _ AFL schema. So I'm
going to grant select update insert
delete so we can actually make changes
on that table. It’s a central table. Let's
go ahead and run that if you've worked
with the Predictive Analysis Library in
the past you'll probably be familiar
with the creator eraser execute role
which allows you to use the rapid
generator function which will generate
stored procedures for you on your behalf
and in fact the EML uses the same
process in order to allow you to work
with TensorFlow models. So we're going to
authorize that on this user and also
once these stored procedures have been
built you want to be able to run them
and there's a specific role for that as
well.
So we're also going to grant the AFL
_ _ SYS _ AFL _
_ EML _ execute
role to our user and this you would need
to grant to any user that's actually
going to run stored procedures that would
access TensorFlow
models. Let's go ahead and run those
authorizations. So now we've got our EML
user the next thing would be just to log
on as that user. So let's go ahead and do
the same process we've been through
already. We’re going to go to the
multi-tenant option choose our host and
our instance number. We’re going to login
to the tenant database called HXE in my
case with HANA Express and login as the
EML user with that initial password
and of course it's going to ask us to
change that password on first login. So
we're now logged in as our EML user and
we should have the rights we need to
actually do what we'll be doing later. We
can see we've got our own
schema. So we can close that SQL
window. So that finishes the initial
configuration basically getting started
when we want to work with the EML. What
we've seen in this video is where we can
find the reference guide. We’ve seen
where we can get the code snippets in
GitHub for this video series and we've
also used the Web IDE for HANA and the
database Explorer to connect as the
system and the HXE tenants and we've
actually built ourselves an EML user.
We've given all the roles and rights we
started the script server we did the
configuration that was needed. You can
find more HANA video tutorials on our
YouTube channel. If you'd like to be
informed as soon as new video tutorials
are published please subscribe to the
channel. You can also connect with us on
LinkedIn, follow us on Twitter and we
have pages on Facebook and Google+. Code
snippets and demo data for all of our
tutorials are published to GitHub. Thanks
for watching.