-
-
Save thomcc/707ae437e034f319ae68c561704a5a76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"from moztelemetry import get_pings" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"pings = get_pings(sc, doc_type='sync', fraction=1.0, submission_date='20160717')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"2131613" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"pings.count()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[{u'application': {u'architecture': u'x86-64',\n", | |
" u'buildId': u'20160714030208',\n", | |
" u'channel': u'nightly',\n", | |
" u'displayVersion': u'50.0a1',\n", | |
" u'name': u'Firefox',\n", | |
" u'platformVersion': u'50.0a1',\n", | |
" u'vendor': u'Mozilla',\n", | |
" u'version': u'50.0a1',\n", | |
" u'xpcomAbi': u'x86_64-msvc'},\n", | |
" u'creationDate': u'2016-07-16T23:59:54.279Z',\n", | |
" u'id': u'1d875e87-d208-4ffc-9848-4b1f23ef7773',\n", | |
" 'meta': {u'Date': u'Sat, 16 Jul 2016 23:59:54 GMT',\n", | |
" u'Host': u'incoming.telemetry.mozilla.org',\n", | |
" 'Hostname': u'ip-172-31-45-139',\n", | |
" u'Size': 651.0,\n", | |
" 'Timestamp': 1468713600725154048L,\n", | |
" 'Type': u'telemetry',\n", | |
" u'appBuildId': u'20160714030208',\n", | |
" u'appName': u'Firefox',\n", | |
" u'appUpdateChannel': u'nightly',\n", | |
" u'appVendor': u'Mozilla',\n", | |
" u'appVersion': u'50.0a1',\n", | |
" u'creationTimestamp': 1.468713594279e+18,\n", | |
" u'docType': u'sync',\n", | |
" u'documentId': u'1d875e87-d208-4ffc-9848-4b1f23ef7773',\n", | |
" u'geoCity': u'Syracuse',\n", | |
" u'geoCountry': u'US',\n", | |
" u'normalizedChannel': u'nightly',\n", | |
" u'sourceName': u'telemetry',\n", | |
" u'sourceVersion': u'4',\n", | |
" u'submissionDate': u'20160717'},\n", | |
" u'payload': {u'engines': [{u'name': u'clients', u'took': 125},\n", | |
" {u'name': u'prefs', u'took': 16},\n", | |
" {u'name': u'passwords'},\n", | |
" {u'name': u'tabs', u'took': 15},\n", | |
" {u'name': u'bookmarks', u'took': 16},\n", | |
" {u'name': u'addons', u'took': 63},\n", | |
" {u'name': u'forms'},\n", | |
" {u'name': u'history', u'took': 15}],\n", | |
" u'took': 359,\n", | |
" u'uid': u'f2a5e939b52747d9844b443568367f7d',\n", | |
" u'version': 1,\n", | |
" u'when': 1468713593916L},\n", | |
" u'type': u'sync',\n", | |
" u'version': 4}]" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"pings.take(1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def is_empty_engine_ping(e):\n", | |
" return ((\"failureReason\" not in e) and\n", | |
" (\"status\" not in e) and\n", | |
" (\"incoming\" not in e) and\n", | |
" (\"outgoing\" not in e))\n", | |
"\n", | |
"\n", | |
"def is_empty_ping(ping):\n", | |
" return ((\"status\" not in ping) and\n", | |
" (\"failureReason\" not in ping) and\n", | |
" all(is_empty_engine_ping(e) for e in ping[\"engines\"]))\n", | |
"\n", | |
"# probably a better way to do this ...\n", | |
"empty_pings = pings.filter(lambda p: is_empty_ping(p[\"payload\"]))\n", | |
"full_pings = pings.filter(lambda p: not is_empty_ping(p[\"payload\"]))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(2049769, 81844)" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"(empty_pings.count(), full_pings.count())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.03839533723992113" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"81844.0 / (2049769.0 + 81844.0)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.11" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment