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
540
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
Is Your Open-source LLM Really Open?
marcobonzanini
0
17
Perambulations in Football Analytics
marcobonzanini
0
9
Natural Language Processing Expert Briefing @ PyData Global 2022
marcobonzanini
0
69
Natural Language Processing Expert Briefing @ PyData Global 2021
marcobonzanini
0
94
Getting into Data Science @ HisarCS 2021
marcobonzanini
0
180
Mining topics in documents with topic modelling and Python @ London Python meetup
marcobonzanini
1
180
Topic Modelling workshop @ PyCon UK 2019
marcobonzanini
2
90
Lies, Damned Lies, and Statistics @ PyCon UK 2019
marcobonzanini
0
96
Lies, Damned Lies and Statistics @ PyLondinium 2019
marcobonzanini
1
130
Other Decks in Programming
See All in Programming
Namespace on read
tagomoris
2
370
Microservices rules (July 2024) : what good looks like
cer
PRO
0
1.6k
20240706_CDKConf
takuyay0ne
0
1.2k
Exploring the Gradually Lost Technical Skills in the Cloud Native Era
hwchiu
2
3.9k
Activities at Cairo Library
cairolibrary720
0
1.2k
CSC307 Lecture 06
javiergs
PRO
0
360
[After Kotlin Fest 2024 LT Night @ Sansan] もっともっとKotlinを好きになる!K2 Compiler Pluginで遊んでみよう!
kitakkun
2
260
さきがけから振り返るアーキテクチャ刷新 / Reflecting on the Architectural Renewal from the Vanguard
nrslib
2
770
DDDを志して3年経ったら「DDDの皮を被ったクリーンアーキテクチャ」になった話【デブサミ2024夏】
texmeijin
1
620
AWS CDKにおける「再利用性」を考える / aws-cdk-reusability
gotok365
6
1.3k
大規模マルチテナントを解決するYugabyteDBという選択肢
nnaka2992
1
250
Javaの現状2024夏 / Java current status 2024 summer
kishida
4
1.4k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
423
64k
5 minutes of I Can Smell Your CMS
philhawksworth
200
19k
How to Think Like a Performance Engineer
csswizardry
4
590
Optimizing for Happiness
mojombo
373
69k
Docker and Python
trallard
37
2.9k
StorybookのUI Testing Handbookを読んだ
zakiyama
15
4.9k
What the flash - Photography Introduction
edds
65
11k
[RailsConf 2023] Rails as a piece of cake
palkan
35
4.4k
The World Runs on Bad Software
bkeepers
PRO
63
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
52k
Making Projects Easy
brettharned
111
5.7k
Testing 201, or: Great Expectations
jmmastey
33
6.9k
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