Python Bytes   /     #29 Responsive Bar Charts with Bokeh, Flask, and Python 3

Description

Python Bytes 29Brought to you by Rollbar! http://rollbar.com/pythonbytesBrian #1: Responsive Bar Charts with Bokeh, Flask and Python 3by Matt Makai at fullstackpython.comA walkthrough example of putting together a flask app that uses Bokeh bar charts to visualize data.All steps included, no previous experience with Flask or Bokeh required.Nice explanation of what the code does without going into too much detail.Good jumping off point for further learning, but complete enough to be useful right away.Michael #2: Zappa Serverless Python Web ServicesZappa makes it super easy to build and deploy all Python WSGI applications on AWS Lambda + API GatewayThink of it as "serverless" web hosting for your Python apps. That means infinite scaling, zero downtime, zero maintenance - and at a fraction of the cost of your current deployments!Better still, with Zappa you only pay for the milliseconds of server time that you use, so it's many orders of magnitude cheaper than VPS/PaaS hosts and in most cases, it's completely free. Plus, there's no need to worry about load balancing or keeping servers online ever again.Asynchronous Task Execution: from flask import Flask from zappa.async import task app = Flask(__name__) @task def make_pie(): """ This takes a long time! """ ingredients = get_ingredients() pie = bake(ingredients) deliver(pie) @app.route('/api/order/pie') def order_pie(): """ This returns immediately! """ make_pie() return "Your pie is being made!" Brian #3: Using a local cache for pip packagesIn https://pythonbytes.fm/24, Local package store, we talked about using pip to cache pypi projects to allow offline installation: $ pip download --cachedir <somePackage>$ pip install --no-index --find-links=/tmp/wheelhouse somePackageWell, Dominic does us one better by wrapping these commands in a couple of aliases. However, his version uses pip install --``download, which has been deprecated. Here’s a version with the new syntax: alias pipcache='pip download --cachedir ${HOME}/.pip-packages'alias pipinstall='pip install --no-index --find-links=file://${HOME}/.pip-packages/'Michael #4: Building game AI using ML: Working with TensorFlow, Keras, and the Intel MKL in PythonFrom the ActivePython guysa classic arcade space shooter game that features enemies powered by machine learningwe decided to build a Neural Network to drive the behaviour of the enemies in the gameFor the game part of things, we’re using PyGameIn the training mode, the enemies fire randomly, and then each shot taken by the enemy is recorded as a hit or a miss along with its initial relative position/velocity values. Every one of these shots becomes a row in the training matrix and the network is trained in “realtime” after every row is added so you can see the network build and develop as you train.LESSONS LEARNED Choosing the right data to train your network is important.“Prepping” your data is key.Experiment with network topology.Visualization is important.Brian #5: Debug Test Failures With Pdbby Raphael PierzinaDebugging code with pytest, using: --pdb to jump into the debugger at the point of failure-x to stop after first failure--lf to re-run all the tests that failed last timeNote: Yes. All this and more is covered in Python Testing with pytest. Shameless plug for my book. Raphael is one of the technical reviewers. Thank you, Raphael!Michael #6: Monitoring my VOIP provider with Home AssistantIntegrating it into Home Assistant: Use home-assistant.io as a home automation platform in my house. It’s written in Python, open source, and has a large community surrounding it. Unfortunately, there wasn’t anything already built for my Cisco ATA.Decided to write, an open source my first python module called pyciscsospa you can download it and use it for your own ATA as well.Receive a push notification on my phone when the phone lines go down and come back up

Subtitle
Duration
00:23:04
Publishing date
2017-06-08 08:00
Link
https://pythonbytes.fm/episodes/show/29/responsive-bar-charts-with-bokeh-flask-and-python-3
Contributors
  Michael Kennedy
author  
Enclosures
https://pythonbytes.fm/episodes/download/29/responsive-bar-charts-with-bokeh-flask-and-python-3.mp3
audio/mpeg