SlideShare a Scribd company logo
1 of 32
Launchpad
   The good, the bad, and
the OMG how does that work?

                                  Tim Penhey
                              tim@penhey.net
                                 IRC: thumper
                                       #nzpug

                                Kiwi PyCon 2009
Launchpad? WTF is Launchpad?
●   Python based web application
●   ~350k lines of python
●   ~25k tests
●   Uses Zope 3 and Twisted libraries
●   Developed primarily by Canonical
●   AGPL3 now
●   https://launchpad.net

                                        Kiwi PyCon 2009
Kiwi PyCon 2009
Learn From Others
●   Been in development for over five years
●   Made lots of mistakes
●   Found many ways not to do things
●   Nuggets hidden in the depths
●   Here to share




                                              Kiwi PyCon 2009
Testing is Essential
●   All types of tests throughout the code
●   Unit tests
●   Doc tests
●   Acceptance level tests
●   Windmill Javascript tests
●   Run your tests automatically


                                             Kiwi PyCon 2009
Slow Tests are Bad
●   Complete test suite run takes around four hours
●   Cannot run all tests for every landing now
    ●   Buildbot, devel and stable branches
●   Sample data for tests causes problems
    ●   tearDown needs to reset DB state
●   Zope test layers proliferate
●   Run the test in the lowest layer possible

                                                Kiwi PyCon 2009
Code Reviews Are Good
●   All changes are reviewed by at least one other
    developer
●   New team members went through a mentoring
    process to learn from other reviewers
●   Extra eyes on code can spot issues that the
    developer misses
●   Reviewer makes sure new code has tests
●   Have a coding standard
                                           Kiwi PyCon 2009
Multiple Environments are Good
●   Production – updated every four weeks
    ●   https://launchpad.net
●   Edge – updated nightly
    ●   https://edge.launchpad.net
    ●   Beta testers are automatically redirected here
●   Staging – updated nightly with production copy
    ●   https://staging.launchpad.net
    ●   Test area for people to mess around with
                                                   Kiwi PyCon 2009
Can lead to many branches
●   devel – primary development branch
●   stable – devel with all tests passed
    ●   Rolled to edge nightly
●   db-devel – database patches + devel
●   db-stable – db-devel with all the tests passed
    ●   Rolled to staging nightly
●   production – what we rolled out + cherry picks

                                            Kiwi PyCon 2009
Bazaar makes it all workable
●   Bazaar is a distributed revision control system
    (DVCS)
●   Merging just works
●   Develop in branches
●   Merge into devel (or db-devel)




                                            Kiwi PyCon 2009
Object-Relational Mappers
●   Mixed blessing
●   Originally used SQLObject
●   Moved to Storm
    ●   http://storm.canonical.com




                                     Kiwi PyCon 2009
Branches
●   Represent bazaar branches in Launchpad
●   Have owners
●   Most belong to a project or source package
●   Branches can be linked to be “official”
    ●   lp:bzr
    ●   lp:ubunutu/jaunty/gwibber
    ●   lp:~thumper/launchpad/fix-branch-layout


                                                  Kiwi PyCon 2009
Branch Listings
●   Shows up to 100 branches on a page
●   Primary text is the “bazaar identity”
●   For any single branch it can effectively traverse
    across 8 tables
●   Naïve approach would mean 800 queries to
    show a listing



                                             Kiwi PyCon 2009
Branch Listing Solution
●   Utility class – BranchListingQueryOptimiser
●   lazr.delegates
    ●   Wraps real object but can override specific method
●   View class determines visible batch
●   Single queries executed for the “set” of visible
    branches



                                                  Kiwi PyCon 2009
Branch Collection Idiom
●   Global utility to get all branches
      >>> collection = getUtility(IAllBranches)
●   Filter methods return a new branch collection
      >>> collection = collection.inProject(foo)
      >>> collection = collection.ownedBy(eric)
●   Subclasses handle visibility based on privacy
      >>> collection = collection.visibleBy(user)
      >>> collection = collection.visibleBy(None)


                                           Kiwi PyCon 2009
Branch Collection Idiom
●   Accessor methods return result sets
        >>> branches = collection.getBranches()
        >>> branches.order_by(Branch.name)


●   Look at the code:
    ●   lib/lp/code/model/branchcollection.py
    ●   lib/lp/code/interfaces/branchcollection.py



                                                Kiwi PyCon 2009
Interfaces are Good
●   zope.interface and zope.schema
    ●   schema contains field types


    class IFruit(Interface):
        name = Text(required=True)
        def throw(target):
          """No self defined for methods."""



                                               Kiwi PyCon 2009
Interfaces are Good
●   Model classes implement interfaces

    class Fruit(object):
      implements(IFruit)
      def __init__(self, name):
        self.name = name
      def throw(self, target):
        return target.hit_with(self)


                                         Kiwi PyCon 2009
Interfaces are Good
>>> apple = Fruit('apple')
>>> IFruit.providedBy(apple)
True
>>> from zope.interfaces.verify import (
...    verifyObject)
>>> verifyObject(IFruit, apple)
True




                                       Kiwi PyCon 2009
Zope Views and Pages
●   Path traversal is mostly object traversal
●   Views are associated with objects through
    interfaces
●   Resulting web pages are rendered views
●   Most views use a page template




                                                Kiwi PyCon 2009
Adapters Supercharge Interfaces
●   Adapters allow an object to be converted to a
    different interface in a defined way

    def branch_collection_for_product(project):
        """Adapt a project to a branch collection."""
        return getUtility(IAllBranches).inProject(project)


    >>> collection = IBranchCollection(project)




                                                   Kiwi PyCon 2009
Be Smart About Pages
●   Many different objects have branches
●   Simple branch listing registered against
    IHasBranches instead of individual interfaces
●   View adapts the objects to IBranchCollection
●   Each object that implements IHasBranches
    also has an IBranchCollection adapter



                                           Kiwi PyCon 2009
Launchpad API using lazr.restful
●   Annotations to the interface class allow the
    objects to be exposed over a ReST based API
●   This is still magic to me
●   lazr.restful and lazr.restfulclient are found on
    Launchpad
●   launchpadlib is a Python client API



                                               Kiwi PyCon 2009
Modules Matter
●   Initially all of Launchpad was in the
    canonical.launchpad module
    ●   .browser – contained the views
    ●   .interfaces – contained all the interfaces
    ●   .database – contained all the model code
    ●   .templates – contained all the page templates
    ●   .doc – documentation including doc tests
    ●   .ftests, .pagetests, .webapp, …
●   Became just too cumbersome
                                                     Kiwi PyCon 2009
The Module Move Apocalypse
●   Each team was responsible for moving code
●   New base module “lp” chosen
●   lp.registry – people, projects, distributions
●   lp.bugs – code related to the bug tracker
●   lp.services – code used by other applications
    ●   mail, jobs, testing, scripts
●   lp.codehosting, lp.blueprints, lp.translations

                                               Kiwi PyCon 2009
ZCML Is Not Fun
●   Zope Configuration Markup Language is an
    XML document
●   Defines content classes, security, adapters,
    utilities, views
●   Registration away from the actual code hinders
    discoverability
●   Ideally we'd like to bring in some of the ideas
    from Grok and Martian

                                              Kiwi PyCon 2009
Learn to use TAGS
●   TAGS are used describe the location of the
    function definition
●   Can be read by Emacs and Vi
●   Have a make target (or equivalent) to build your
    TAGS file




                                            Kiwi PyCon 2009
Databases Evolve
●   Your database schema will evolve
    ●   New tables and columns
    ●   Changing columns
    ●   With time comes complexity
●   Have a way to evolve your database schema
    ●   Launchpad uses SQL patch files to describe
        discrete changes
    ●   Production database is updated every 4 weeks

                                                Kiwi PyCon 2009
Share Common Components
●   lazr-js               ●   lazr.publisher
●   lazr.authentication   ●   lazr.restful
●   lazr.batchnavigator   ●   lazr.restfulclient
●   lazr.canonicalurl     ●   lazr.smtptest
●   lazr.config           ●   lazr.testing
●   lazr.delegates        ●   lazr.uri
●   lazr.enum             ●   storm
●   lazr.exportedfolder   ●   wadllib
●   lazr.lifecycle

                                                   Kiwi PyCon 2009
Eat Your Own Dog Food




                        Kiwi PyCon 2009
That's It



Questions?




             Kiwi PyCon 2009
Lunch!




         Kiwi PyCon 2009

More Related Content

What's hot

GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28Jorge Hidalgo
 
Eclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in EclipseEclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in EclipseMiles Sabin
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyelliando dias
 
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?Miles Sabin
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerKoichi Sakata
 
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?Miles Sabin
 
The OpenEuropa Initiative
The OpenEuropa InitiativeThe OpenEuropa Initiative
The OpenEuropa InitiativeNuvole
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOULucas Jellema
 
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeJava 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeNikita Lipsky
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devopsRob Kinyon
 
Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.jsJustin Reock
 
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)Igalia
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerJohn Anderson
 
Deploying PHP Application Using Bitbucket Pipelines
Deploying PHP Application Using Bitbucket PipelinesDeploying PHP Application Using Bitbucket Pipelines
Deploying PHP Application Using Bitbucket PipelinesDolly Aswin Harahap
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Clark Everetts
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
DEVNET-2006 Coding 210: Parsing JSON in C++
DEVNET-2006	Coding 210: Parsing JSON in C++DEVNET-2006	Coding 210: Parsing JSON in C++
DEVNET-2006 Coding 210: Parsing JSON in C++Cisco DevNet
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in osGenchiLu1
 

What's hot (20)

GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
Eclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in EclipseEclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in Eclipse
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
 
The OpenEuropa Initiative
The OpenEuropa InitiativeThe OpenEuropa Initiative
The OpenEuropa Initiative
 
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOUHOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
HOW AND WHY GRAALVM IS QUICKLY BECOMING RELEVANT FOR YOU
 
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall DeposeJava 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
 
Getting Started with Node.js
Getting Started with Node.jsGetting Started with Node.js
Getting Started with Node.js
 
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
Deploying PHP Application Using Bitbucket Pipelines
Deploying PHP Application Using Bitbucket PipelinesDeploying PHP Application Using Bitbucket Pipelines
Deploying PHP Application Using Bitbucket Pipelines
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
DEVNET-2006 Coding 210: Parsing JSON in C++
DEVNET-2006	Coding 210: Parsing JSON in C++DEVNET-2006	Coding 210: Parsing JSON in C++
DEVNET-2006 Coding 210: Parsing JSON in C++
 
Understanding how concurrency work in os
Understanding how concurrency work in osUnderstanding how concurrency work in os
Understanding how concurrency work in os
 

Similar to Understanding Launchpad: A Deep Dive into the Open Source Project Management Platform

MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and ProfitJoshua Ballanco
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinatingAntonio Goncalves
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplateStanislav Petrov
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodeKris Buytaert
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with FabricJonas Nockert
 
Golang @ Tokopedia
Golang @ TokopediaGolang @ Tokopedia
Golang @ TokopediaQasim Zaidi
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?Charlie Gracie
 
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.Ohad Basan
 
Cloud Native Practice
Cloud Native PracticeCloud Native Practice
Cloud Native PracticePhilip Zheng
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索Mu Chun Wang
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with serverEugene Yokota
 
Repository Management with JFrog Artifactory
Repository Management with JFrog ArtifactoryRepository Management with JFrog Artifactory
Repository Management with JFrog ArtifactoryStephen Chin
 
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...CodiLime
 
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...DynamicInfraDays
 
Odo improving the developer experience on OpenShift - hack & sangria
Odo   improving the developer experience on OpenShift - hack & sangriaOdo   improving the developer experience on OpenShift - hack & sangria
Odo improving the developer experience on OpenShift - hack & sangriaJorge Morales
 

Similar to Understanding Launchpad: A Deep Dive into the Open Source Project Management Platform (20)

MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and Profit
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinating
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 
Golang @ Tokopedia
Golang @ TokopediaGolang @ Tokopedia
Golang @ Tokopedia
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?JavaOne2015-What's in an Object?
JavaOne2015-What's in an Object?
 
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
 
Cloud Native Practice
Cloud Native PracticeCloud Native Practice
Cloud Native Practice
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Repository Management with JFrog Artifactory
Repository Management with JFrog ArtifactoryRepository Management with JFrog Artifactory
Repository Management with JFrog Artifactory
 
The Architect Way
The Architect WayThe Architect Way
The Architect Way
 
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
CodiLime Tech Talk - Dawid Trzebiatowski i Wojciech Urbański: Opening the Flo...
 
Pipeline as Code
Pipeline as CodePipeline as Code
Pipeline as Code
 
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
ContainerDays NYC 2015: "Easing Your Way Into Docker: Lessons From a Journey ...
 
Container Days
Container DaysContainer Days
Container Days
 
Odo improving the developer experience on OpenShift - hack & sangria
Odo   improving the developer experience on OpenShift - hack & sangriaOdo   improving the developer experience on OpenShift - hack & sangria
Odo improving the developer experience on OpenShift - hack & sangria
 

Recently uploaded

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Understanding Launchpad: A Deep Dive into the Open Source Project Management Platform

  • 1. Launchpad The good, the bad, and the OMG how does that work? Tim Penhey tim@penhey.net IRC: thumper #nzpug Kiwi PyCon 2009
  • 2. Launchpad? WTF is Launchpad? ● Python based web application ● ~350k lines of python ● ~25k tests ● Uses Zope 3 and Twisted libraries ● Developed primarily by Canonical ● AGPL3 now ● https://launchpad.net Kiwi PyCon 2009
  • 4. Learn From Others ● Been in development for over five years ● Made lots of mistakes ● Found many ways not to do things ● Nuggets hidden in the depths ● Here to share Kiwi PyCon 2009
  • 5. Testing is Essential ● All types of tests throughout the code ● Unit tests ● Doc tests ● Acceptance level tests ● Windmill Javascript tests ● Run your tests automatically Kiwi PyCon 2009
  • 6. Slow Tests are Bad ● Complete test suite run takes around four hours ● Cannot run all tests for every landing now ● Buildbot, devel and stable branches ● Sample data for tests causes problems ● tearDown needs to reset DB state ● Zope test layers proliferate ● Run the test in the lowest layer possible Kiwi PyCon 2009
  • 7. Code Reviews Are Good ● All changes are reviewed by at least one other developer ● New team members went through a mentoring process to learn from other reviewers ● Extra eyes on code can spot issues that the developer misses ● Reviewer makes sure new code has tests ● Have a coding standard Kiwi PyCon 2009
  • 8. Multiple Environments are Good ● Production – updated every four weeks ● https://launchpad.net ● Edge – updated nightly ● https://edge.launchpad.net ● Beta testers are automatically redirected here ● Staging – updated nightly with production copy ● https://staging.launchpad.net ● Test area for people to mess around with Kiwi PyCon 2009
  • 9. Can lead to many branches ● devel – primary development branch ● stable – devel with all tests passed ● Rolled to edge nightly ● db-devel – database patches + devel ● db-stable – db-devel with all the tests passed ● Rolled to staging nightly ● production – what we rolled out + cherry picks Kiwi PyCon 2009
  • 10. Bazaar makes it all workable ● Bazaar is a distributed revision control system (DVCS) ● Merging just works ● Develop in branches ● Merge into devel (or db-devel) Kiwi PyCon 2009
  • 11. Object-Relational Mappers ● Mixed blessing ● Originally used SQLObject ● Moved to Storm ● http://storm.canonical.com Kiwi PyCon 2009
  • 12. Branches ● Represent bazaar branches in Launchpad ● Have owners ● Most belong to a project or source package ● Branches can be linked to be “official” ● lp:bzr ● lp:ubunutu/jaunty/gwibber ● lp:~thumper/launchpad/fix-branch-layout Kiwi PyCon 2009
  • 13. Branch Listings ● Shows up to 100 branches on a page ● Primary text is the “bazaar identity” ● For any single branch it can effectively traverse across 8 tables ● Naïve approach would mean 800 queries to show a listing Kiwi PyCon 2009
  • 14. Branch Listing Solution ● Utility class – BranchListingQueryOptimiser ● lazr.delegates ● Wraps real object but can override specific method ● View class determines visible batch ● Single queries executed for the “set” of visible branches Kiwi PyCon 2009
  • 15. Branch Collection Idiom ● Global utility to get all branches >>> collection = getUtility(IAllBranches) ● Filter methods return a new branch collection >>> collection = collection.inProject(foo) >>> collection = collection.ownedBy(eric) ● Subclasses handle visibility based on privacy >>> collection = collection.visibleBy(user) >>> collection = collection.visibleBy(None) Kiwi PyCon 2009
  • 16. Branch Collection Idiom ● Accessor methods return result sets >>> branches = collection.getBranches() >>> branches.order_by(Branch.name) ● Look at the code: ● lib/lp/code/model/branchcollection.py ● lib/lp/code/interfaces/branchcollection.py Kiwi PyCon 2009
  • 17. Interfaces are Good ● zope.interface and zope.schema ● schema contains field types class IFruit(Interface): name = Text(required=True) def throw(target): """No self defined for methods.""" Kiwi PyCon 2009
  • 18. Interfaces are Good ● Model classes implement interfaces class Fruit(object): implements(IFruit) def __init__(self, name): self.name = name def throw(self, target): return target.hit_with(self) Kiwi PyCon 2009
  • 19. Interfaces are Good >>> apple = Fruit('apple') >>> IFruit.providedBy(apple) True >>> from zope.interfaces.verify import ( ... verifyObject) >>> verifyObject(IFruit, apple) True Kiwi PyCon 2009
  • 20. Zope Views and Pages ● Path traversal is mostly object traversal ● Views are associated with objects through interfaces ● Resulting web pages are rendered views ● Most views use a page template Kiwi PyCon 2009
  • 21. Adapters Supercharge Interfaces ● Adapters allow an object to be converted to a different interface in a defined way def branch_collection_for_product(project): """Adapt a project to a branch collection.""" return getUtility(IAllBranches).inProject(project) >>> collection = IBranchCollection(project) Kiwi PyCon 2009
  • 22. Be Smart About Pages ● Many different objects have branches ● Simple branch listing registered against IHasBranches instead of individual interfaces ● View adapts the objects to IBranchCollection ● Each object that implements IHasBranches also has an IBranchCollection adapter Kiwi PyCon 2009
  • 23. Launchpad API using lazr.restful ● Annotations to the interface class allow the objects to be exposed over a ReST based API ● This is still magic to me ● lazr.restful and lazr.restfulclient are found on Launchpad ● launchpadlib is a Python client API Kiwi PyCon 2009
  • 24. Modules Matter ● Initially all of Launchpad was in the canonical.launchpad module ● .browser – contained the views ● .interfaces – contained all the interfaces ● .database – contained all the model code ● .templates – contained all the page templates ● .doc – documentation including doc tests ● .ftests, .pagetests, .webapp, … ● Became just too cumbersome Kiwi PyCon 2009
  • 25. The Module Move Apocalypse ● Each team was responsible for moving code ● New base module “lp” chosen ● lp.registry – people, projects, distributions ● lp.bugs – code related to the bug tracker ● lp.services – code used by other applications ● mail, jobs, testing, scripts ● lp.codehosting, lp.blueprints, lp.translations Kiwi PyCon 2009
  • 26. ZCML Is Not Fun ● Zope Configuration Markup Language is an XML document ● Defines content classes, security, adapters, utilities, views ● Registration away from the actual code hinders discoverability ● Ideally we'd like to bring in some of the ideas from Grok and Martian Kiwi PyCon 2009
  • 27. Learn to use TAGS ● TAGS are used describe the location of the function definition ● Can be read by Emacs and Vi ● Have a make target (or equivalent) to build your TAGS file Kiwi PyCon 2009
  • 28. Databases Evolve ● Your database schema will evolve ● New tables and columns ● Changing columns ● With time comes complexity ● Have a way to evolve your database schema ● Launchpad uses SQL patch files to describe discrete changes ● Production database is updated every 4 weeks Kiwi PyCon 2009
  • 29. Share Common Components ● lazr-js ● lazr.publisher ● lazr.authentication ● lazr.restful ● lazr.batchnavigator ● lazr.restfulclient ● lazr.canonicalurl ● lazr.smtptest ● lazr.config ● lazr.testing ● lazr.delegates ● lazr.uri ● lazr.enum ● storm ● lazr.exportedfolder ● wadllib ● lazr.lifecycle Kiwi PyCon 2009
  • 30. Eat Your Own Dog Food Kiwi PyCon 2009
  • 31. That's It Questions? Kiwi PyCon 2009
  • 32. Lunch! Kiwi PyCon 2009