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
Building Data Pipelines in Python
Search
Marco Bonzanini
April 16, 2016
Programming
2
550
Building Data Pipelines in Python
Slides of my talk at PyCon7 in Florence (April 2016)
Marco Bonzanini
April 16, 2016
Tweet
Share
More Decks by Marco Bonzanini
See All by Marco Bonzanini
Pitfalls in Data Science Projects (and how to avoid them)
marcobonzanini
0
14
Is Your Open-source LLM Really Open?
marcobonzanini
0
29
Perambulations in Football Analytics
marcobonzanini
0
18
Natural Language Processing Expert Briefing @ PyData Global 2022
marcobonzanini
0
72
Natural Language Processing Expert Briefing @ PyData Global 2021
marcobonzanini
0
95
Getting into Data Science @ HisarCS 2021
marcobonzanini
0
220
Mining topics in documents with topic modelling and Python @ London Python meetup
marcobonzanini
1
190
Topic Modelling workshop @ PyCon UK 2019
marcobonzanini
2
92
Lies, Damned Lies, and Statistics @ PyCon UK 2019
marcobonzanini
0
99
Other Decks in Programming
See All in Programming
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
30
11k
ARA Ansible for the teams
kksat
0
150
Software Architecture
hschwentner
6
2.1k
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
210
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.8k
Compose でデザインと実装の差異を減らすための取り組み
oidy
1
300
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
4
1.3k
TokyoR116_BeginnersSession1_環境構築
kotatyamtema
0
110
Amazon Bedrock Multi Agentsを試してきた
tm2
1
280
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
10
1.8k
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
480
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
KATA
mclloyd
29
14k
Gamification - CAS2011
davidbonilla
80
5.1k
Thoughts on Productivity
jonyablonski
69
4.5k
Become a Pro
speakerdeck
PRO
26
5.1k
4 Signs Your Business is Dying
shpigford
182
22k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Scaling GitHub
holman
459
140k
Speed Design
sergeychernyshev
25
780
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
A Philosophy of Restraint
colly
203
16k
Transcript
Building Data Pipelines in Python Marco Bonzanini ! PyCon Italia
- Florence 2016
Nice to meet you • @MarcoBonzanini • “Type B” Data
Scientist • PhD in Information Retrieval • Book with PacktPub (July 2016) • Usually at PyData London
R&D ≠ Engineering R&D results in production = high value
None
Big Data Problems vs Big Data Problems
Data Pipelines Data ETL Analytics • Many components in a
data pipeline: • Extract, Clean, Augment, Join data
Good Data Pipelines Easy to reproduce Easy to productise
Towards Good Pipelines • Transform your data, don’t overwrite •
Break it down into components • Different packages (e.g. setup.py) • Unit tests vs end-to-end tests Good = Replicable and Productisable
Anti-Patterns • Bunch of scripts • Single run-everything script •
Hacky homemade dependency control • Don’t reinvent the wheel
Intermezzo Let me rant about testing Icon by Freepik from
flaticon.com
(Unit) Testing • Unit tests in three easy steps: •
import unittest • Write your tests • Quit complaining about lack of time to write tests
Benefits of (unit) testing • Safety net for refactoring •
Safety net for lib upgrades • Validate your assumptions • Document code / communicate your intentions • You’re forced to think
Testing: not convinced yet?
Testing: not convinced yet?
Testing: not convinced yet? f1 = fscore(p, r) min_bound,
max_bound = sorted([p, r]) assert min_bound <= f1 <= max_bound
Testing: I’m almost done • Unit tests vs Defensive Programming
• Say no to tautologies • Say no to vanity tests • Know the ecosystem: py.test, nosetests, hypothesis, coverage.py, …
</rant>
Intro to Luigi GNU Make + Unix pipes + Steroids
• Workflow manager in Python, by Spotify • Dependency management • Error control, checkpoints, failure recovery • Minimal boilerplate • Dependency graph visualisation $ pip install luigi
Luigi Task: unit of execution class MyTask(luigi.Task): ! def requires(self):
pass # list of dependencies def output(self): pass # task output def run(self): pass # task logic
Luigi Target: output of a task class MyTarget(luigi.Target): ! def
exists(self): pass # return bool Off the shelf support for local file system, S3, Elasticsearch, RDBMS (also via luigi.contrib)
Not only Luigi • More Python-based workflow managers: • Airflow
by Airbnb • Mrjob by Yelp • Pinball by Pinterest
When things go wrong • import logging • Say no
to print() for debugging • Custom log format / extensive info • Different levels of severity • Easy to switch off or change level
Who reads the logs? You’re not going to read the
logs, unless… • E-mail notifications • built-in in Luigi • Slack notifications $ pip install luigi_slack # WIP
Summary • R&D is not Engineering: can we meet halfway?
• Prototypes vs. Products • Automation and replicability matter • You need a workflow manager • Good engineering principles help: • Testing, logging, packaging, …
Vanity Slide • speakerdeck.com/marcobonzanini • github.com/bonzanini • marcobonzanini.com • @MarcoBonzanini