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
530
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
Natural Language Processing Expert Briefing @ PyData Global 2022
marcobonzanini
0
62
Natural Language Processing Expert Briefing @ PyData Global 2021
marcobonzanini
0
89
Getting into Data Science @ HisarCS 2021
marcobonzanini
0
170
Mining topics in documents with topic modelling and Python @ London Python meetup
marcobonzanini
1
180
Topic Modelling workshop @ PyCon UK 2019
marcobonzanini
2
89
Lies, Damned Lies, and Statistics @ PyCon UK 2019
marcobonzanini
0
95
Lies, Damned Lies and Statistics @ PyLondinium 2019
marcobonzanini
1
120
Let the AI Do the Talk: Adventures with Natural Language Generation
marcobonzanini
1
180
Brewing Beer with Python
marcobonzanini
2
220
Other Decks in Programming
See All in Programming
phpunit/php-code-coverageって何をしてるんだ #phperkaigi
o0h
PRO
2
210
生成 AI の中身を覗いてみよう〜基礎から医療現場での応用まで〜
soh9834
2
760
GitHub Copilot Tips and Tricks
yuichielectric
26
7.4k
RubyVM を PHP で実装する 〜Hello World を出力するまで〜
memory1994
PRO
1
490
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
4
1.1k
WasmOS: Wasmを実行する自作Microkernel
riru
0
370
自作ソフト(VMagicMirror)がVRMA対応してる話+実装のTips
bakudreameater
0
110
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
WinUI 3デモ - "CommunityToolkit.Mvvm"NuGetパッケージ編
andrewkeepcoding
0
130
Creating Retro-Style Photos Using Swift
ski
1
340
Learning PHP and Static Analysis with PHP Parser
inouehi
1
250
Kotlinを用いたDSL的な設計手法と使用上の注意
kohii00
3
530
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
323
20k
Designing Experiences People Love
moore
135
23k
For a Future-Friendly Web
brad_frost
170
8.9k
How to Ace a Technical Interview
jacobian
272
22k
Visualization
eitanlees
135
14k
What the flash - Photography Introduction
edds
64
11k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
Fireside Chat
paigeccino
19
2.6k
Creatively Recalculating Your Daily Design Routine
revolveconf
209
11k
Navigating Team Friction
lara
177
13k
Building Effective Engineering Teams - LeadDev
addyosmani
25
1.8k
Ruby is Unlike a Banana
tanoku
95
10k
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