Python Experience in KKBOX Group

Download Python Experience in KKBOX Group

Post on 13-Apr-2017




8 download

Embed Size (px)


<ul><li><p>Python Experience in KKBOX Group</p><p>Shuen-Huei (Drake) Guan</p><p> (It was originally planned for PyCon TW)</p><p>04/21/2016</p></li><li><p>Lets conduct some surveys first.pyKKBOX? pyUIA? Mass?</p></li><li><p>@drakeguan</p><p>- Technical Director, KKStream</p><p>- Sr. Principal Engineer, KKBOX</p><p>- Volunteer, PyCon Taiwan</p><p></p></li><li><p>This talk is about a compilation of tasks and projects, done in Python, in KKBOX Group. Each project has its own challenges and context to deal with. What you can take home are some stories and experience.</p><p>Warning: its just our own experience, not suitable to yours!</p></li><li><p>pyKKBOX, 2011</p></li><li><p>KKBOX </p></li><li><p>KKBOX </p><p> An user can broadcast what he/she is listening to others.</p><p> Multiple users are then able to subscribe to his/her station, listening to the </p><p>same song simultaneously.</p><p> A major/highlighted KKBOX feature developed in 2011.</p></li><li><p>Challenges by </p><p> iOS (client) co-works with Windows (broadcaster) only.</p><p> There is even no broadcasters to listen to!</p><p> In academia, we may call this ill-posed (optimization) problem.</p></li><li><p>pyKKBOX,</p><p></p></li><li><p>pyKKBOX</p><p> It is a lite-weight, not fully functional client.</p><p> It is initially just a bot, which can login, and do broadcasting.</p><p> It should be easy because we are iOS client team, not server team.</p><p> Its a proof of concept.</p></li><li><p>API Testing by pyKKBOX</p><p> Now we have bots: A tool to do stress testing.</p><p> A tool to provide radio-like automatic service.</p><p> And then, more APIs are in.</p><p> Test cases for KKBOX API!</p><p> Hourly testing on Jenkins CI.</p></li><li><p>Playlist Auto-Sync</p><p> CPL (Cloud PlayList) synchronization.</p><p> The sync is not done based on data (playlist), but JSON-based commands!</p><p> In 3 months, the APIs version changed 5 times.</p><p> n-to-m synchronization makes it even worse.</p><p> pyKKBOX is, again, used to prototype even though technical spec is not </p><p>finalized.</p></li><li><p>Toy Project: Photomosaic by pyKKBOX</p></li><li><p>Album covers by pyKKBOX</p><p>Yes. Thats me.</p></li><li><p>Photomosaic</p><p> Its based on KKBOX 2014 workshop group photo.</p><p> 1,500 album covers are used.</p><p> Final photomosaic resolution: 14k x 6k.</p><p> I didnt read the official KKBOX API yet. Just self-introspection of pyKKBOX in </p><p>IPython is enough.</p><p> Coding time: less than half hour.</p></li><li><p>pyKKBOX facts</p><p> Initiated in 2011, to ~2013.</p><p> Two main contributors (Welly Liu and @zonble), but with ~10 contributors then.</p><p> Just the builtin Python modules (including PyObjC) are used.</p><p>Another weapon for app developers;</p><p>prototyping, or even trash-able code, is a great fit here;</p><p>being a glue, a common language among diversified developers if youre doing </p><p>multi-platform product development;</p><p>Python speaks plain language.</p><p> Hmm, we have no further plans yet. :p</p></li><li><p>pyUIA, 2013</p></li><li><p>Testing Goals &amp; Reports</p></li><li><p>Testing for Playlist Auto-Sync</p><p> Easy to manage and organize playlists across various devices.</p><p> Multiple devices, mostly in different platforms, are involed.</p></li><li><p>One Test Case (iOS &gt; Android)</p><p>1. On iOS, create a new playlist.</p><p>2. On Android, check if the playlist </p><p>created in step 1 appears.</p></li><li><p>A (Pseudo) Test Script that Works!</p></li><li><p>Abstraction of Layers for Testing</p></li><li><p>pyUIA,</p><p></p></li><li><p>pyUIA,</p><p></p></li><li><p>pyUIA facts</p><p> Initiated in 2014 and it keeps evolving.</p><p> It doesnt take much time because its just simply works. v0.3 is released on </p><p>June 2015.</p><p> 3 developers contribute their talents.</p><p> Python packages: selenium, robotframework and Appium-Python-Client.</p><p>Somehow, we just want to implement automated tests in Pythonic way!</p><p> 120 Release Acceptance Test (RAT) are on pyUIA, ~20% cases.</p><p></p></li><li><p>Video Encoding System, 2014</p></li><li><p>Video Streaming Service</p><p> KKBOX forms a team, Video Development, to build video streaming services </p><p>in Japan. They are Videopass and Animepass.</p><p> More than 1,000,000 subscription users.</p><p> More than 30,000 videos, not that many but resource-consuming.</p></li><li><p>Challenges for Video Encoding System</p><p> Given a couple of thousands of videos;</p><p> given ~150 videos per day;</p><p> given a scalable number of encoders on EC2 instances;</p><p> assuming the workflow for each video can be different;</p><p> how to make a robust system to handle this challenge in consideration of just 1.5 developer(s)</p><p> everything can be broken</p><p> computing resource is expensive (c3.8xlarge, c4.8xlarge, )</p><p> its a vivid world~</p></li><li><p>One Simplified Audio Encoding Workflow</p></li><li><p>Another Simplified Encoding Workflow</p></li><li><p>Render Farm Idea from VFX/Animation Industry</p><p>Ed Catmull, Pixar</p><p>Pixars Alfred</p></li><li><p></p><p></p></li><li><p>Mass,</p><p></p></li><li><p>Mass,</p><p> Job script as the central data to control the workflow, instead of fixed coding </p><p>logics in workers.</p><p> Focus on data, the workflow and real work, than underneath system or </p><p>infrastructure.</p><p> Leverage AWS SWF (or Apache Kafka, Mesos, or other message brokers) to </p><p>provide robust, fault-tolerant and fully automatic distributed system.</p><p></p></li><li><p>Mass facts</p><p> Initiated in 2014, and it keeps rocking~</p><p> Just 2 mid-level Python developers (they both have presented in PyCon TW).</p><p> Python packages: arrow, awscli, boto, click, clint, flask, filechunkio, flask, </p><p>fluent-logger, isodate, logbook, parmap, requests, sh.</p><p>We hope to polish the open-sourced Mass much sexy and useful in near </p><p>future.</p><p> 3,000,000-minute videos got encoded through it.</p><p> Mass once finished 3,000 videos encoding within one day without any issue </p><p>while 800 encoders on 100 c3.8xlarge instances were on duty.</p></li><li><p>RDC Toolbox, 2015</p></li><li><p>KKBOXers demands more data-driven facts/info</p></li><li><p>One example of request ticket from production team</p></li><li><p>Someone can learn from others queries!</p></li><li><p>Python, , </p><p>--- RDC Toolbox main developer</p></li><li><p>RDC Toolbox facts</p><p> Initiated in Oct 2015, still quite young. 1.5 developer(s) with many contributes then. Python packages: flask, pandas, psycopg2, redis, requests, slacker, sqlparse.</p><p>python flask pandas log slacker virtualenvpython, prototype</p><p> 10,000,000,000 metering data to deal with. 10,000 queries conducted by (mostly) non-developers. Lots of future plan. We are building music streaming specific BI tools.</p></li><li><p>AWS Lambda CI/CDIt would get shared in PyCon TW 2016</p></li><li><p>Finally, lets do some surveys again, but in KKBOX Group (just for fun).</p></li><li><p>What programming languages have you used to contribute your talents in KKBOX Group?</p></li><li><p>What programming languages are you HAPPY to work with in KKBOX Group?</p></li><li><p>What programming languages are you planning to learn for future challenges in KKBOX Group?</p></li><li><p>Thank you!</p></li></ul>