Slide 1

Slide 1 text

Building Data 
 Pipelines with Python Data  Engineer  @  TY
 @mfcabrera
 [email protected] Miguel  Cabrera
 PyCon  Deutschland  30.10.2016

Slide 2

Slide 2 text

Agenda

Slide 3

Slide 3 text

Agenda Context   Data  Pipelines  with  Luigi   Tips  and  Tricks   Examples

Slide 4

Slide 4 text

Data Processing Pipelines

Slide 5

Slide 5 text

cat  file.txt  |  wc  -­‐  l  |  
 mail  -­‐s  “hello”  [email protected]

Slide 6

Slide 6 text

ETL

Slide 7

Slide 7 text

ETL • Extract  data  from  a  data  source   • Transform  the  data   • Load  into  a  sink  

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Feature 
 Extraction Parameter Estimation Model Training Feature 
 Extraction Model Predict Visualize/ Format

Slide 10

Slide 10 text

Steps  in  different  technologies

Slide 11

Slide 11 text

Steps  can  be  run  in  parallel

Slide 12

Slide 12 text

Steps  have    complex   dependencies  among  them

Slide 13

Slide 13 text

Workflows • Repeat     • Parametrize     • Resume   • Schedule  it

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

“A Python framework for data flow definition and execution” Luigi

Slide 17

Slide 17 text

Concepts

Slide 18

Slide 18 text

Concepts Tasks   Parameters   Targets   Scheduler  &  Workers

Slide 19

Slide 19 text

Tasks

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

1

Slide 22

Slide 22 text

2

Slide 23

Slide 23 text

3

Slide 24

Slide 24 text

4

Slide 25

Slide 25 text

WordCountTask file.txt wc.txt

Slide 26

Slide 26 text

WordCountTask file.txt wc.txt ToJsonTask wc.json

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Parameters

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Parameters Used  to  idenNfy  the  task     From  arguments  or  from  configuraNon   Many  types  of  Parameters  (int,  date,   boolean,  date  range,  Nme  delta,  dict,   enum)

Slide 31

Slide 31 text

Targets

Slide 32

Slide 32 text

Targets Resources  produced  by  a  Task   Typically  Local  files  or  files  distributed  file   system  (HDFS)   Must  implement  the  method  exists()   Many  targets  available

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Scheduler  &  Workers

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Source:  h@p:/ /www.arashrouhani.com/luigid-­‐basics-­‐jun-­‐2015

Slide 37

Slide 37 text

BaVeries  Included

Slide 38

Slide 38 text

Batteries Included Package  contrib  filled  with  goodies   Good  support  for  Hadoop     Different  Targets   Extensible

Slide 39

Slide 39 text

Task Types Task  -­‐  Local   Hadoop  MR,  Pig,  Spark,  etc   SalesForce,  ElasNcsearch,  etc.   ExternalProgram   check  luigi.contrib  !

Slide 40

Slide 40 text

Target LocalTarget   HDFS,  S3,  FTP,  SSH,    WebHDFS,  etc.   ESTarget,  MySQLTarget,  MSQL,  Hive,   SQLAlchemy,  etc.

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Tips  &  Tricks

Slide 43

Slide 43 text

Separate  pipeline  and  logic

Slide 44

Slide 44 text

Extend  to  avoid  boilerplate  code

Slide 45

Slide 45 text

DRY

Slide 46

Slide 46 text

Conclusion Luigi  is  a  mature,  baVeries-­‐included   alternaNve  for  building  data  pipelines   Lacks  of  powerful  visualizaNon  of  the   pipelines   Requires  a  external  way  of  launching  jobs   (i.e.  cron).   Hard  to  debug  MR  Jobs

Slide 47

Slide 47 text

Lear More hVps:/ /github.com/spoNfy/luigi   hVp:/ /luigi.readthedocs.io/en/stable/

Slide 48

Slide 48 text

Thanks!

Slide 49

Slide 49 text

Credits • pipe  icon  by  Oliviu  Stoian  from  the  Noun  Project   • Photo  Credit:  (CC)  h@ps:/ /www.flickr.com/photos/ 47244853@N03/29988510886  from  hb.s  via  Compfight     • Concrete  Mixer:  (CC)    h@ps:/ /www.flickr.com/photos/ 145708285@N03/30138453986  by  MasLabor  via   Compfight