Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Firefly - Deploying functions made easy
Search
Anand Chitipothu
July 10, 2017
Programming
0
750
Firefly - Deploying functions made easy
Lightning talk given at EuroPython 2017
Anand Chitipothu
July 10, 2017
Tweet
Share
More Decks by Anand Chitipothu
See All by Anand Chitipothu
Machine Learning as a Service
anandology
0
180
DevOps for Data Science
anandology
0
80
Managing Machine Learning Models in Production - Strata Singapore 2017
anandology
0
690
Real World Challenges in Deploying Machine Learning Applications
anandology
0
390
Deploying ML apps in minutes
anandology
1
430
Recreational Programming
anandology
4
510
Managing Machine Learning Models in Production
anandology
1
520
Distributed Machine Learning - Challenges & Opportunities
anandology
0
270
Writing Beautiful Code - EuroPython 2017
anandology
3
1.3k
Other Decks in Programming
See All in Programming
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
340
Jakarta EE meets AI
ivargrimstad
0
250
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
Refactor your code - refactor yourself
xosofox
1
260
命名をリントする
chiroruxx
1
410
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
testcontainers のススメ
sgash708
1
120
선언형 UI에서의 상태관리
l2hyunwoo
0
160
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
190
Recoilを剥がしている話
kirik
5
6.7k
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
270
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Invisible Side of Design
smashingmag
298
50k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Visualization
eitanlees
146
15k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Statistics for Hackers
jakevdp
796
220k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Transcript
Firefly Deploying functions made easy!
Who is speaking? Anand Chitipothu @anandology • building a data
science platform at @rorodata • advanced programming courses at @pipalacademy
The problem How to expose a function as an API
for others to use?
Why? • To use it in a different environment •
Loose coupling
Use cases • Deploy a machine learning model • preprocess
an image • live price check
Challenges • Requires writing a web application • What about
authentication? • How to do data validation? • How I need write a client library too?
Welcome to Firefly Deploying functions made easy!
Code Write your function: # sq.py def square(n): return n*n
Run Start web service: $ firefly sq.square [INFO] Starting gunicorn
19.7.1 [INFO] Listening at: http://127.0.0.1:8000 ...
Use And use it with a client. >>> from firefly.client
import Client >>> client = Client("http://127.0.0.1:8000") >>> client.square(n=4) 16
Behind the scenes, it is a RESTful API. $ curl
-d '{"n": 4}' http://127.0.0.1:8000/square 16 And supports any JSON-friendly datatype.
More practical example Deploying a machine learning model. # model.py
import pickle model = pickle.load('model.pkl') def predict(features): result = model.predict(features]) return int(result[0])
Run the server using: $ firefly model.predict ... And use
it in the client: >>> remote_model = Client("http://localhost:8080/") >>> remote_model.predict(features=[5.9, 3, 5.1, 1.8])) 2
Authentication Firefly has built-in support for autentication. $ firefly --token
abcd1234 sq.square ... The client must pass the same token to autenticate it. >>> client = Client("http://127.0.0.1:8000", auth_token="abcd1234") >>> client.square(n=4) 16
Upcoming Features... • supporting other input and output content-types in
addition to json. (for example, a function to resize an image) • validation using type annotations • caching support
It's open source! https://github.com/rorodata/firefly To install: pip install firefly-python
Questions? • https://firefly-python.readthedocs.io/ • https://github.com/rorodata/firefly