Slide 1

Slide 1 text

Writing Python Code to Decide an Election Peter Lubell-Doughtie

Slide 2

Slide 2 text

http://www.ly.undp.org/etc/designs/ UNDPIndiaDesign/img/home/logo- undp.png

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

the problem • tally many votes from many districts in many elections !

Slide 7

Slide 7 text

the problem • tally many votes from many districts in many elections • elections may span multiple district

Slide 8

Slide 8 text

the problem • tally many votes from many districts in many elections • elections may span multiple district • each ballot has a 7-stage verification process

Slide 9

Slide 9 text

Intake

Slide 10

Slide 10 text

Intake Data Entry

Slide 11

Slide 11 text

Intake Data Entry Corrections

Slide 12

Slide 12 text

Intake Data Entry Corrections Quality Control

Slide 13

Slide 13 text

Intake Data Entry Corrections Quality Control Archiving

Slide 14

Slide 14 text

…the other problem • we had 3 weeks

Slide 15

Slide 15 text

…the other problem • we had 3 weeks

Slide 16

Slide 16 text

only the essentials

Slide 17

Slide 17 text

only the essentials • what functionality must exist? !

Slide 18

Slide 18 text

only the essentials • what functionality must exist? • what tools already do some of that?

Slide 19

Slide 19 text

only the essentials • what functionality must exist? • what tools already do some of that? • what if we miss something?

Slide 20

Slide 20 text

a schema as a tool

Slide 21

Slide 21 text

a schema as a tool • decide how data is organized ! !

Slide 22

Slide 22 text

a schema as a tool • decide how data is organized • shared reference !

Slide 23

Slide 23 text

a schema as a tool • decide how data is organized • shared reference • scopes possible relationships

Slide 24

Slide 24 text

a schema as a tool • decide how data is organized • shared reference • scopes possible relationships • it’s updatable

Slide 25

Slide 25 text

issues and milestones

Slide 26

Slide 26 text

issues and milestones • convert discussion to issues !

Slide 27

Slide 27 text

issues and milestones • convert discussion to issues • decide prioritization through milestones

Slide 28

Slide 28 text

issues and milestones • convert discussion to issues • decide prioritization through milestones • communicate to what will get done when

Slide 29

Slide 29 text

do it

Slide 30

Slide 30 text

do it 1. assign an issue ! ! ! ! !

Slide 31

Slide 31 text

do it 1. assign an issue 2. write tests for the issue ! ! ! !

Slide 32

Slide 32 text

do it 1. assign an issue 2. write tests for the issue 3. write code for the tests ! ! !

Slide 33

Slide 33 text

do it 1. assign an issue 2. write tests for the issue 3. write code for the tests 4. issue a pull request ! !

Slide 34

Slide 34 text

do it 1. assign an issue 2. write tests for the issue 3. write code for the tests 4. issue a pull request 5. review the code !

Slide 35

Slide 35 text

do it 1. assign an issue 2. write tests for the issue 3. write code for the tests 4. issue a pull request 5. review the code 6. pass the CI

Slide 36

Slide 36 text

do it 1. assign an issue 2. write tests for the issue 3. write code for the tests 4. open a pull request 5. review the code 6. pass the CI 7. merge and go to step (1.)

Slide 37

Slide 37 text

automate speed

Slide 38

Slide 38 text

automate speed • anything that is done twice gets a script

Slide 39

Slide 39 text

automate speed • anything that is done twice gets a script • anything that breaks once gets a test

Slide 40

Slide 40 text

we used south

Slide 41

Slide 41 text

we used postgres

Slide 42

Slide 42 text

we used postgres

Slide 43

Slide 43 text

nose, flake8, and coverage

Slide 44

Slide 44 text

travis for ci

Slide 45

Slide 45 text

do not write code

Slide 46

Slide 46 text

do not write code • unless you really really have to ! ! !

Slide 47

Slide 47 text

guardian for permissions

Slide 48

Slide 48 text

enumfield state machines

Slide 49

Slide 49 text

enumfield state machines

Slide 50

Slide 50 text

reversion for data purity

Slide 51

Slide 51 text

fabric for remote execution

Slide 52

Slide 52 text

plan to handle what you have not planned for

Slide 53

Slide 53 text

plan to handle what you have not planned for • elections can span multiple districts

Slide 54

Slide 54 text

plan to handle what you have not planned for • elections can span multiple districts • did not know until the first day of live testing

Slide 55

Slide 55 text

plan to handle what you have not planned for

Slide 56

Slide 56 text

plan to handle what you have not planned for • we changed the data model => south ! !

Slide 57

Slide 57 text

plan to handle what you have not planned for • we changed the data model => south • we wrote tests => django-nose !

Slide 58

Slide 58 text

plan to handle what you have not planned for • we changed the data model => south • we wrote tests => django-nose • we changed the code => travis-ci

Slide 59

Slide 59 text

plan to handle what you have not planned for • we changed the data model => south • we wrote tests => django-nose • we changed the code => travis-ci • we deployed => fabric

Slide 60

Slide 60 text

sage advice • “simplicity is prerequisite for reliability” - Dijkstra

Slide 61

Slide 61 text

references • http://south.readthedocs.org/ • https://github.com/5monkeys/django-enumfield • http://www.fabfile.org/ • https://flake8.readthedocs.org/ • https://bitbucket.org/ned/coveragepy

Slide 62

Slide 62 text

thank you! • https://github.com/onaio/tally-ho • http://company.ona.io/ • http://peet.ldee.org/

Slide 63

Slide 63 text