python experience in kkbox group

55
Python Experience in KKBOX Group Shuen-Huei (Drake) Guan #Taipei.py (It was originally planned for PyCon TW) 04/21/2016

Upload: shuen-huei-guan

Post on 13-Apr-2017

5.591 views

Category:

Technology


8 download

TRANSCRIPT

Page 1: Python Experience in KKBOX Group

Python Experience in KKBOX Group

Shuen-Huei (Drake) Guan

#Taipei.py (It was originally planned for PyCon TW)

04/21/2016

Page 2: Python Experience in KKBOX Group

Let’s conduct some surveys first.pyKKBOX? pyUIA? Mass?

Page 3: Python Experience in KKBOX Group

@drakeguan

- Technical Director, KKStream

- Sr. Principal Engineer, KKBOX

- Volunteer, PyCon Taiwan

Page 4: Python Experience in KKBOX Group

“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.”

Warning: it’s just our own experience, not suitable to yours!

Page 5: Python Experience in KKBOX Group

pyKKBOX, 2011

Page 6: Python Experience in KKBOX Group

KKBOX “一起聽”

Page 7: Python Experience in KKBOX Group

KKBOX “一起聽”

● An user can broadcast what he/she is listening to others.

● Multiple users are then able to subscribe to his/her station, listening to the

same song simultaneously.

● A major/highlighted KKBOX feature developed in 2011.

Page 8: Python Experience in KKBOX Group

Challenges by “一起聽”

● iOS (client) co-works with Windows (broadcaster) only.

● There is even no broadcasters to listen to!

● In academia, we may call this “ill-posed (optimization) problem”.

Page 9: Python Experience in KKBOX Group

pyKKBOX, https://github.com/KKBOX/pyKKBOX

Page 10: Python Experience in KKBOX Group

pyKKBOX

● It is a lite-weight, not fully functional client.

● It is initially just a bot, which can login, and do broadcasting.

● It should be easy because we are iOS client team, not server team.

● It’s a proof of concept.

Page 11: Python Experience in KKBOX Group

API Testing by pyKKBOX

● Now we have bots:○ A tool to do stress testing.

○ A tool to provide radio-like automatic service.

● And then, more APIs are in.

● Test cases for KKBOX API!

● Hourly testing on Jenkins CI.

Page 12: Python Experience in KKBOX Group

Playlist Auto-Sync

● CPL (Cloud PlayList) synchronization.

● The sync is not done based on data (playlist), but JSON-based commands!

● In 3 months, the API’s version changed 5 times.

● n-to-m synchronization makes it even worse.

● pyKKBOX is, again, used to prototype even though technical spec is not

finalized.

Page 13: Python Experience in KKBOX Group

Toy Project: Photomosaic by pyKKBOX

Page 14: Python Experience in KKBOX Group

Album covers by pyKKBOX

Yes. That’s me.

Page 15: Python Experience in KKBOX Group

Photomosaic

● It’s based on KKBOX 2014 workshop group photo.

● 1,500 album covers are used.

● Final photomosaic resolution: 14k x 6k.

● I didn’t read the official KKBOX API yet. Just self-introspection of pyKKBOX in

IPython is enough.

● Coding time: less than half hour.

Page 16: Python Experience in KKBOX Group

pyKKBOX facts

● Initiated in 2011, to ~2013.

● Two main contributors (Welly Liu and @zonble), but with ~10 contributors then.

● Just the builtin Python modules (including PyObjC) are used.

“Another weapon for app developers;

prototyping, or even trash-able code, is a great fit here;

being a glue, a common language among diversified developers if you’re doing

multi-platform product development;

Python speaks plain language.”

● Hmm, we have no further plans yet. :p

Page 17: Python Experience in KKBOX Group

pyUIA, 2013

Page 18: Python Experience in KKBOX Group

Testing Goals & Reports

Page 19: Python Experience in KKBOX Group

Testing for Playlist Auto-Sync

● Easy to manage and organize playlists across various devices.

● Multiple devices, mostly in different platforms, are involed.

Page 20: Python Experience in KKBOX Group

One Test Case (iOS > Android)

1. On iOS, create a new playlist.

2. On Android, check if the playlist

created in step 1 appears.

Page 21: Python Experience in KKBOX Group

A (Pseudo) Test Script that Works!

Page 22: Python Experience in KKBOX Group

Abstraction of Layers for Testing

Page 23: Python Experience in KKBOX Group

pyUIA, https://github.com/imsardine/pyuia

Page 24: Python Experience in KKBOX Group

pyUIA, https://github.com/imsardine/pyuia

Page 25: Python Experience in KKBOX Group

pyUIA facts

● Initiated in 2014 and it keeps evolving.

● It doesn’t take much time because it’s just simply works. v0.3 is released on

June 2015. http://www.slideshare.net/jeremykao92/pyuia-03

● 3 developers contribute their talents.

● Python packages: selenium, robotframework and Appium-Python-Client.

“Somehow, we just want to implement automated tests in Pythonic way!”

● 120 Release Acceptance Test (RAT) are on pyUIA, ~20% cases.

Page 26: Python Experience in KKBOX Group

Video Encoding System, 2014

Page 27: Python Experience in KKBOX Group

Video Streaming Service

● KKBOX forms a team, Video Development, to build video streaming services

in Japan. They are Videopass and Animepass.

● More than 1,000,000 subscription users.

● More than 30,000 videos, not that many but resource-consuming.

Page 28: Python Experience in KKBOX Group

Challenges for Video Encoding System

● Given a couple of thousands of videos;

● given ~150 videos per day;

● given a scalable number of encoders on EC2 instances;

● assuming the workflow for each video can be different;

● how to make a robust system to handle this challenge in consideration of○ just 1.5 developer(s)

○ everything can be broken

○ computing resource is expensive (c3.8xlarge, c4.8xlarge, …)

○ it’s a vivid world~

Page 29: Python Experience in KKBOX Group

One Simplified Audio Encoding Workflow

Page 30: Python Experience in KKBOX Group

Another Simplified Encoding Workflow

Page 31: Python Experience in KKBOX Group

Render Farm Idea from VFX/Animation Industry

Ed Catmull, Pixar

Pixar’s Alfred

Page 32: Python Experience in KKBOX Group
Page 33: Python Experience in KKBOX Group

http://bit.ly/1rnR0Ht

Page 34: Python Experience in KKBOX Group

Mass, https://github.com/kkbox/mass

Page 35: Python Experience in KKBOX Group

Mass, https://github.com/kkbox/mass

● Job script as the central data to control the workflow, instead of fixed coding

logics in workers.

● Focus on data, the workflow and real work, than underneath system or

infrastructure.

● Leverage AWS SWF (or Apache Kafka, Mesos, or other message brokers) to

provide robust, fault-tolerant and fully automatic distributed system.

Page 36: Python Experience in KKBOX Group

Mass facts

● Initiated in 2014, and it keeps rocking~

● Just 2 mid-level Python developers (they both have presented in PyCon TW).

● Python packages: arrow, awscli, boto, click, clint, flask, filechunkio, flask,

fluent-logger, isodate, logbook, parmap, requests, sh.

“We hope to polish the open-sourced Mass much sexy and useful in near

future.”

● 3,000,000-minute videos got encoded through it.

● Mass once finished 3,000 videos encoding within one day without any issue

while 800 encoders on 100 c3.8xlarge instances were on duty.

Page 37: Python Experience in KKBOX Group

RDC Toolbox, 2015

Page 38: Python Experience in KKBOX Group

KKBOXers demands more data-driven facts/info

Page 39: Python Experience in KKBOX Group

One example of request ticket from production team

Page 40: Python Experience in KKBOX Group
Page 41: Python Experience in KKBOX Group
Page 42: Python Experience in KKBOX Group
Page 43: Python Experience in KKBOX Group
Page 44: Python Experience in KKBOX Group

Someone can learn from others’ queries!

Page 45: Python Experience in KKBOX Group

“透過Python你幾乎可以做到任何事情, 剩下的就只是

你不知道要這樣做而已, 但是用戶的使用方式會教你

這件事。”--- RDC Toolbox main developer

Page 46: Python Experience in KKBOX Group

RDC Toolbox facts

● Initiated in Oct 2015, still quite young.● 1.5 developer(s) with many contributes then.● Python packages: flask, pandas, psycopg2, redis, requests, slacker, sqlparse.

“python 的強大社群

想架站的時候有 flask 想處理資料的時候有 pandas 想用創意的方式來log有 slacker 切測試環境的時候有 virtualenv如果不使用python, 我應該沒辦法在一個人和這麼短的時間內完成 prototype”

● 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.

Page 47: Python Experience in KKBOX Group

AWS Lambda CI/CDIt would get shared in PyCon TW 2016

Page 48: Python Experience in KKBOX Group

Finally, let’s do some surveys again, but in KKBOX Group (just for fun).

Page 49: Python Experience in KKBOX Group

What programming languages have you used to contribute your talents in KKBOX Group?

Page 50: Python Experience in KKBOX Group
Page 51: Python Experience in KKBOX Group

What programming languages are you HAPPY to work with in KKBOX Group?

Page 52: Python Experience in KKBOX Group
Page 53: Python Experience in KKBOX Group

What programming languages are you planning to learn for future challenges in KKBOX Group?

Page 54: Python Experience in KKBOX Group
Page 55: Python Experience in KKBOX Group

Thank you!