JAX 2017: Machine Learning and scaling web APIs

The JAX conference, in Mainz, Germany, is coming to an end. I was there with my colleagues Mete and Robert, and had the chance to cover two topics: Machine Learning and Scaling Web APIs. It's a pleasure to come back to this conference where the audience is always very focused, eager to learn, and is engaging in great and interesting conversations.

My first presentation was about Machine Learning, and in particular with the Google Cloud APIs, including Vision, Speech, Natural Language, Translate, and Video Intelligence. Although I'm not an expert in TensorFlow and the Cloud Machine Learning Engine, I got a chance to say a few words about these. I guess I'll have to play with both at some point to be able to tell even more!

Title: Machine Intelligence at Google Scale

Abstract: The biggest challenge of Deep Learning technology is the scalability. As long as using single GPU server, you have to wait for hours or days to get the result of your work. This doesn’t scale for production service, so you need a Distributed Training on the cloud eventually. Google has been building infrastructure for training the large scale neural network on the cloud for years, and now started to share the technology with external developers. In this session, we will introduce new pre-trained ML services such as Cloud Vision API and Speech API that works without any training. Also, we will look how TensorFlow and Cloud Machine Learning will accelerate custom model training for 10x – 40x with Google’s distributed training infrastructure.

My second session was about scaling web APIs, defined using the Open API specification, thanks to Kubernetes and Google Container Engine, for the scaling part of the story, and managing those APIs thanks to Google Cloud Endpoints.

TitleScale a Swagger-based Web API with Google Cloud Endpoints

AbstractWeb APIs are more often specified with API definition languages like Swagger (now named OpenAPI Spec), as it can help you generate nice interactive documentation, server skeletons, and client SDKs, mocks, and more, making it simpler to get started both producing and consuming an API. In this session, Guillaume will demonstrate how to define a Web API with Swagger/OpenAPI Spec, and scale it using Cloud Endpoints, on the Google Cloud Platform.

Videos (EN+FR): analyzing Groovy / Grails / Gradle source files from Github with BigQuery

Wether you're an English or a French speaker, 2 recent videos of my talk on the analysis of Groovy / Grails / Gradle source files from Github, thanks to BigQuery, have been released. The first one was recorded during Devoxx US, while the other was from BreizhCamp.

I've written several times about this topic, you can have a deeper look through the following articles:
And now... the videos!

In English, from Devoxx US:

And in French, from BreizhCamp:

A chatbox for the Devoxx conference agenda, with API.AI and Cloud Functions

That's Devoxx France this week, and I've had the pleasure of delivering today another talk on the theme of chatbots, using Cloud Functions for the business logic, API.AI for the bot cleverness, with a bonus of a demo through Google Home and the Google Assistant platform.

I'll post the YouTube video recording once it's online, but in the meantime, I wanted to share my slides here:

Testing Java 8 snippets on the new App Engine Java 8 runtime

A new Java 8 runtime for Google App Engine standard is coming soon, and is currently in alpha testing. You can request to join the alpha program, if you want to try it out for yourself. But I wanted to let anyone play with it, easily, to see how well the Java 8 APIs work, but also to try some Java 8 syntax too. So here's a web console where you can do just that!

But to be precise, it's actually my good old Groovy Web Console, where people can write, execute and save Apache Groovy snippets. It is a special version, in fact, as it's built on Java 8, uses the invoke dynamic flavor, and... drum roll... it's using the upcoming "Parrot" parser which adds the Java 8 syntax constructs to the Groovy grammar. So not only can you try Java snippets, but it's a great opportunity to try the future Groovy parser that's gonna be released in Apache Groovy 2.5 or 3.0 (still to be decided).

A meetup about Java 8 on Google App Engine standard

Also, for those who live in Paris and the area, we have the chance of having Ludovic Champenois, an engineer working on App Engine, that will be in France, and will be speaking at this GDG Cloud meetup hosted by Xebia, which takes places on Tuesday, April 4th, just on the even of Devoxx France! 

So if you want to learn more about Java 8 on App Engine, please sign up!

I will also be presenting about Google Home, the Google Assistant, API.AI, and Google Cloud Functions to host the logic of your very own bots and agents. It's based on the presentation I gave at Cloud Next 2017 in San Francisco. If you want to learn more about 

Happy Pi Day! Google Home helps you learn the digits of Pi

You know what? It's Pi Day today! Well, if you follow the American date standard, it's 3.14 today, a nice approximation of Pi. Last year, in a past life, I had played with Pi already, but this year, my awesome colleagues (Ray, Sandeep, Francesc, Ian) have been working on some very cool demos around Pi, with the "Pi delivery", at https://pi.delivery/

You can transform the Pi digits in a nice melody, show a D3.js based visualisation of the transitions between digits, you can stream the Pi digits, and more. And you can learn about how it's been developed on the Google Cloud Platform.

Ray pinged me to see if we could also create an assistant you can invoke on Google Home, to ask for digits of Pi, as I recently played with Google Home, API.AI and Cloud Functions! And I played with the idea: created a new Cloud Function that invokes the Pi's Web API, designed an assistant in API.AI, and submitted this assistant to the Google Assistant.

You'll be able to ask your Google Home:
Ok Google, talk to Pi Digit Agent.
What is the 34th digit of Pi?
And it will tell you that it's 2.

How did I do that, let's first have a look at the Cloud Function, implemented in JavaScript / Node.js:
  "name": "pi-assistant",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node index.js",
    "deploy": "rm -rf node_modules; gcloud alpha functions deploy digit --project digit-of-pi-2017-assistant  --trigger-http --stage-bucket gs://digit-of-pi-2017-assistant/"
  "description": "Ask for the n-th digit of Pi!",
  "main": "index.js",
  "repository": "",
  "author": "Guillaume Laforge",
  "dependencies": {
    "actions-on-google": "^1.0.7",
    "node-fetch": "^1.6.3"
The key things here are the dependencies: I'm using the actions-on-google Node module to interact more easily with API.AI and the Assistant, and I'm using node-fetch to interact with the Pi Delivery's REST API. 

Let's now have a look at the code of our exported digit function in index.js:
const ApiAiAssistant = require('actions-on-google').ApiAiAssistant;
const fetch = require('node-fetch');

function nthDigit(assistant) {
    let rank = parseInt(assistant.getArgument('rank').replace(/,/g, ''));
    console.log(`${rank}nth digit`);

    // 0 -> 3, 1 -> ., 2 -> 1, 3 -> 4, 4 -> 1, ...
    // let's return 3 for 0th / 1st, and the digit otherwise, 
    // to follow natural human numbering and the fact the dot is accounted

    let start = rank < 2 ? 0 : rank;

        .then(response => response.json())
        .then(data => {
            assistant.ask(`Digit ${rank} of Pi is ${data.content}. Do you want to know a different digit of Pi? Or say cancel to exit.`);
        }).catch(err => {
            assistant.ask('The ways of Pi are mysterious... Try again, or with another digit? Or say cancel to exit.');

exports.digit = function (request, response) {
    let assistant = new ApiAiAssistant({request, response});
    let actionMap = new Map();
    actionMap.set('nth-digit-intent', nthDigit);
It's pretty straightforward, we export a digit function, that creates an API.AI assistant, to which we feed an action map pointing at our main intent, for asking for digits. I extract the parameter (ie. the rank of the digit I'm interested in), I call the REST API with a fetch() call, and then I return the result with the assistant.ask() call.

In a nutshell, on API.AI's side, my welcome intent greets you, telling you how to use the assistant:
And then the main intent, whose webhook points at my Cloud Function, does the heavy lifting:

You can try it in the emulator:

After that, once the webhook is properly configured, I published my action, through the integrations pane, and the cloud API console. I'll skip the details here, but you can read more on how to distribution your actions.

So again, Happy Pi Day! And hopefully, if you have a Google Home device and when my assistant is officially published, you'll be able to learn more about the digits of Pi!

And let's finish with a video of the assistant running live on my Google Home!

© 2012 Guillaume Laforge | The views and opinions expressed here are mine and don't reflect the ones from my employer.