How do I turn off the flymake, or alternativly find way to fix the warnings it shows me?

Here’s what I found about

  • Flymake to check format of the code, and make sure it adhears to python standards
  • Yapf is a package that reformat the code according to the standard.

To get Flymake to work, I needed to enable flymake-mode Then run C-c C-v to get the list of errors. I can go error by error and fix. But I can also do C-c C-r f to run auto refactoring. In this case Elpy is using the refactoring package (Yapf) to reformat the code.

At first I had an error, and although I had Yapf installed, Emacs kept telling me that it’s not. I found the solution in this issue: Elpy error: yapf not installed

I needed to restart the RPC process, by running M-x elpy-rpc-restart

Ok, with that out of the way, I need to get back to the code.



Back to working on the project. I want to add simple db support, so when I get a request from Alexa, I’ll check if the user is new or returned. If new – store the uuid in the db. If returning, give a returned user message.

Later I can also add context to the db, so I can manage contexts and states not only within session, but also accross sessions.

So, connecting to db – that’s something I did in the “My Clipboard” skill. I’ll go and look there how I did it.

Ok, I copied the set of functions from the clipboard app, but I now get an error when trying to call from Alexa – the entries table isn’t exsit… I remember that I had to do some manual creation of tables, but I don’t recall what exactly I needed to do.

Oh, I see what I’ve missed. I needed to create a schema.sql file, that defines the table I would like to create.

Here’s an article that is a good reference: Intro to Flask: Creating and Writing to Databases

And by the way, I’m moving to use Sublime for now… I spend too much time tinkering with Emacs, and not doing productive work… I will keep writing this in Emacs though, because it’s an org file.

Ok, back to Emacs. I guesse I’m more used to it than I thought…

I added the db support. I now want to check if a user is new or return. First time I see a user, I add the user to the db. Then I fetch from the db to check new or return. I had a problem with checking if I get a row from the db. Used this stack-overflow answer. The gist:

  • Excecute the query with count(*)
  • Grab the fetchone() with index 0
  • Test if I get 1 or 0. If 0, then there was no result from the query.
def launched():
    # check if the user is new or return
    db = get_db()    
    c = db.execute('select count(*) from users where user_id = ?',

    data = c.fetchone()[0]
    if data == 0:
        # new user - insert to db and play new user welcome
        db.execute('insert into users (user_id) values (?)',
        return question('Welcome to out brain! I will be your personal editor. To start, say headlines, sites, topics or categories')
        return question('Welcome back! What do topic are you interested in today?')


Yesterday I created the conversation flow to get topics. I need to add the recommendations from topic today, as well as to add the flows to sites and categories.

Oh, I had a problem to take a string that represent the user id in alexa, and convert it to a uuid, which I can then use with the outbrain endpoint. I searched, and didn’t find an answer yet. I’ll have to look into it later on.

I tried to implement the site’s flow. I spent most of the time of 2 pomodoros on getting Alexa to recognize and pass the name of a site or topic. I tried to use the AMZN:LITERAL type, assuming that alexa will recognize whatever the user said and pass it on to me. But it didn’t, and kept getting me into an infinit loop, recognizing only the GetTopic intent.

To over come this, I added two custom types:

  • ENTITY_TYPE – list the utterances for a type of recommendation (topic, site or category)
  • ENTITY_NAME – I added top sites and topics to that list, and added the slot with that type to the intent. This way I hope alexa will recognize the utterances better, and pass them along to the server, where I manage contexts and be able to tell if a user ment Yahoo site or Topic.


Started the Outbrain News skill for alexa.

For general reference, here’s the flow of creating a new app:

~/dev/sphere $ mkdir alexa-outbrain-news
~/dev/sphere $ cd alexa-outbrain-news/
~/dev/sphere/alexa-outbrain-news $ pyenv virtualenv 3.5.0 outbrain-news
Using base prefix '/Users/ygilad/.pyenv/versions/3.5.0'
New python executable in /Users/ygilad/.pyenv/versions/3.5.0/envs/outbrain-news/bin/python3.5
Also creating executable in /Users/ygilad/.pyenv/versions/3.5.0/envs/outbrain-news/bin/python
Installing setuptools, pip, wheel...done.
Ignoring indexes: https://pypi.python.org/simple
Requirement already satisfied (use --upgrade to upgrade): setuptools in /Users/ygilad/.pyenv/versions/3.5.0/envs/outbrain-news/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): pip in /Users/ygilad/.pyenv/versions/3.5.0/envs/outbrain-news/lib/python3.5/site-packages
(news-briefing) ~/dev/sphere/alexa-outbrain-news $ pyenv local outbrain-news
(outbrain-news) ~/dev/sphere/alexa-outbrain-news $ touch dlog.org
(outbrain-news) ~/dev/sphere/alexa-outbrain-news $ touch server.py
(outbrain-news) ~/dev/sphere/alexa-outbrain-news $ touch rest-client.org

And now in Emacs, I want to create the workspace for that project:

  • Open the 3 files that I’ve just created, and orginize the windows to my liking.
  • And now I have to save this view as a new workgroup:
    • C-c z c to create a new workgroup
    • Give the workgroup name

And here’s how my emacs window looks like, ready for me to start writing: creating-a-new-project.png

Initial design of the skill

Here’s a sequence diagram of the first interaction with the skill:



Setting up the environment

  • Installing some basic python packages in the new pyenv:

pip install jedi importmagic autopep8 flake8

  • Installing flask and flask-ask, which are more specific to the project.

pip install flask flask-ask

Start the flask application

I can run the server using python server.py, but the server won’t restart when I make changes. I need to run it with flask:
$ export FLASK_APP=server.py
$ flask run --reload