Agnoris Logo Blog

CI/CD fbprophet on AWS Lambda using CircleCI
About a year ago I was trying to figure out how to get fbprophet forecasting work on a AWS Lambda and eventually got it working. Since then the need for serverless forecasting matured, and more people got interested in making the tech seamless, leading to some very helpful stuff, like an fbprophet assembler for AWS Lambda by Marc Metz. A natural evolution from just getting the package working is to make it part of your CI/CD process. I had a need to deploy my forecasting code frequently — was integrating a forecasting microservice into other apps — and manually generating and uploading zips was not an option. I’m gonna share how I solved it for CircleCI. Hope you’ll find it useful and reusable for other CI/CD solutions. The foundation for consistent deploys is this Docker image with fbprophet pre-installed into AWS Lambda Python 3.6 environment. It has full, unedited fbprophet, so that customization is possible on the CI/CD side. For example, you may or may not want to uninstall matplotlib from the Docker. Feel free to use he image at your discretion. Below is the Dockerfile for it (built off Marc Metz’s) and here’s the whole repo. Below is the CircleCI config.yml code I use. It leverages the path to the virtualenv set up in Docker to prepare fbprophet for deploy. Next time will share a bit more about how we use fbprohet at scale at Agnoris. Cheers!
Main article preview
Main article preview
Getting Python's requests-html running on AWS Lambda
TL;DR If you're deploying python with Zappa to AWS Lambda and getting: Make sure you have the latest tdqm (tqdm>=4.32.2) in your requirements.txt installed AFTER Zappa in your deployment - Zappa defaults to tqdm>=4.19 which won't work on AWS Lambda. The Details A big part of our job at Agnoris is getting lots of different data from lots of different sources (some public, some less) under one roof to give our customers what they need to know fast. Sometimes the raw data isn't so pretty so we need to use some great tools to get it and clean it up. Python is our language of choice and AWS's Lambdas are our prefered infrastructure for these tasks. We mostly ship these specific functions with Zappa through a CI system to save deployment time. Yesterday we broke stuff. We deployed a function that used requests-html through Zappa and got swamped with these kinds of errors: Turns out on the AWS Lambda Linux images multiple processes for python are turned off by default. Specifically that means that the tqdm library bundled nested within the requests-html depedency causes breaks - if it's not up to date! See Parallel Processing in Python with AWS Lambda Fortunately this issue was fix by some great folks in the tqdm repo (you can checkout the PR). We added tqdm>=4.32.2 to our requirements.txt and updated our CI to install Zappa BEFORE installing other requirements so that Zappa don't uninstall the latest tqdm in favor of it's default version that doesn't work on Lambda. Problem solved - back to collecting!
Read More
Main article preview
Point of Sale - from business anchor to just another app
The Point of Sale (aptly referred to as the PoS) has traditionally been the anchor of brick & mortar businesses in general but even more so for restaurants. In restaurants the PoS is the main communication channel between the servers, the kitchen and the bar. Every item ordered goes into the system and the PoS has to spit out the right ticket at the right station at the right time so the kitchen and bar know what to make and when. If the PoS goes down or acts wonky, all hell breaks loose. That's why for many years the PoS acted as the anchor for the business. Opening a new restaurant meant first choosing what the PoS would be (probably Micros) and laying down the network and printers around that. It was such a core decision that almost no one switched systems once they were setup - it was such an expensive decision that would need to have serious benefits to consider. In fact most restaurants still won't even consider switchin - my favorite quote from an Agnoris customer when asked why he wouldn't move to a modern system: "I'd rather have needles jammed in my eye". See PoS were traditionally big computer setups that handle the money. They were expensive and complicated and abhorently hard to use. But a few years ago something big changed - the iPad. Forward thinking companies realized that iPad and cloud were so much better suited for doing the PoS job (hey - working for Amazon so why not the corner coffee shop?). And companies like Square, Toast and Salido (to name just a few) were born. The barrier for developing a PoS became so low that more and more competitors jumped in the game. Today there are over 100 different PoS options in the US market just for restaurants! And naturally the differences between them are getting less and less clear. All of them try to do more parts of the restaurant business but over time they look more and more alike. So where is all this going? Traditionally in fragmented markets eventually 2 or 3 players end up buying their way to owning the vast majority of the market (either through buying competitiors or outspending them until they shut down). We're seeing some of this today with Toast raising crazy amounts of money and Square creating a restaurant specific play on their solid foundations. But there's another force at play - credit card processors. See PoS is first and foremost a payment terminal. But processing credit cards (which from what we see is well over 75% of transactions) is a complicated task the PoS companies…
Read More
Main article preview
On-demand Food Delivery - Who Wins In the Zero-Sum Game
Just recently PitchBook reported a new $600M round for DoorDash at $12.6B valuation. And Amazon put $575M into DeliveryHero. Venture capitalists predict cloud kitchens will take over restaurants. Investors and early employees of delivery companies open up interesting public discussions on the future of the industry. And pundits are concerned our society will become even more atomized. So much attention to a relatively old service — getting prepared food to your door. Why? What is actually going on? And who benefits most from all this hype? Let’s take a closer look to better understand the dynamics of the industry and to see where it’s all headed. There’s few key stakeholders in the game: delivery companies themselves, their investors, their employees, their customers and their restaurant partners. We’ll talk about all of them and pay a closer attention to the last group — restaurants — that are affected by the phenomena in a few non-trivial ways. Delivery companies (marketplaces) like DoorDash are mostly business model and not technology innovations. They rely on a set of existing platforms, from cloud computing to GPS and mobile phones, and, as it often happens with business model innovations, disrupt business models of other players. The business innovation ideas revolve around creative ways to subsidize scaling efficiently. Efficient scaling is also the basis for fierce competition and rapid market share moves when one of the companies figures out a better way to do it. Venture capital is the major source of scaling subsidies, but also treating delivery employees as contractors and charging both consumers and restaurants for a match. This is essentially the Uber model, applied to an adjacent vertical. It’s no coincidence Uber Eats is a natural extension of the main Uber service. How is venture capital paid back for the subsidies? Scale delivers billion dollar valuations and hundreds of dollars in revenues. That opens doors to IPOs. Retail and professional investors buy out venture capital investors at a hefty premiums under a promise of further scale and valuation growth and even profitability (maybe). Amazon pioneered this model in early 2000s and it’s been working ever since for the ever-growing list of venture backed unicorns. How are delivery employees compensated? They aren’t, really. People get some income source, but they agree to a hard job with an underpayment compared to traditional jobs that have social security, pension and other benefits…
Read More