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
580
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
68
Is Your Open-source LLM Really Open?
marcobonzanini
0
80
Perambulations in Football Analytics
marcobonzanini
0
62
Natural Language Processing Expert Briefing @ PyData Global 2022
marcobonzanini
0
110
Natural Language Processing Expert Briefing @ PyData Global 2021
marcobonzanini
0
130
Getting into Data Science @ HisarCS 2021
marcobonzanini
0
290
Mining topics in documents with topic modelling and Python @ London Python meetup
marcobonzanini
1
230
Topic Modelling workshop @ PyCon UK 2019
marcobonzanini
2
120
Lies, Damned Lies, and Statistics @ PyCon UK 2019
marcobonzanini
0
150
Other Decks in Programming
See All in Programming
Geminiの機能を調べ尽くしてみた
naruyoshimi
0
200
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
210
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
0
210
メタプログラミングで実現する「コードを仕様にする」仕組み/nikkei-tech-talk43
nikkei_engineer_recruiting
0
160
猫の手も借りたい!ので AIエージェント猫を作って社内に放した話 Claude Code × Container Lambda の Slack Bot "DevNeko"
naramomi7
0
240
今、アーキテクトとして 品質保証にどう関わるか
nealle
0
200
あなたはユーザーではない #PdENight
kajitack
4
300
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
160
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
210
Codex の「自走力」を高める
yorifuji
0
250
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
120
Event Storming
hschwentner
3
1.3k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
6k
Fireside Chat
paigeccino
42
3.8k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
96
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
310
Color Theory Basics | Prateek | Gurzu
gurzu
0
230
The Mindset for Success: Future Career Progression
greggifford
PRO
0
270
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Thoughts on Productivity
jonyablonski
75
5.1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
60
51k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
67
37k
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