Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dexterp37/20d2631e0b0090494500 to your computer and use it in GitHub Desktop.
Save Dexterp37/20d2631e0b0090494500 to your computer and use it in GitHub Desktop.
Checks how many addons on Firefox 42 had no description.
{"nbformat_minor": 0, "cells": [{"source": "### Impact of Addons and Plugins with no desc, name or version", "cell_type": "markdown", "metadata": {}}, {"execution_count": 1, "cell_type": "code", "source": "import datetime as dt\nimport ujson as json\nimport pandas as pd\nimport numpy as np\nimport copy as cp\n\nfrom moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client, get_clients_history", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Unable to parse whitelist (/home/hadoop/anaconda/lib/python2.7/site-packages/moztelemetry/bucket-whitelist.json). Assuming all histograms are acceptable.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "build_ids = \"20151029151421\"\nversions = \"42.0\"\nsubmission_dates = (\"20151103\", \"20151110\")\nmain_pings = get_pings(sc,\n app=\"Firefox\",\n channel=\"release\",\n build_id=build_ids,\n version=versions,\n submission_date=submission_dates,\n doc_type=\"main\",\n schema=\"v4\",\n fraction=0.5)", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "main_pings.count()", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 10, "cell_type": "code", "source": "subset = get_pings_properties(main_pings, [\"meta/sampleId\",\n \"clientId\",\n \"environment/addons/activeAddons\",\n \"environment/addons/activePlugins\",\n \"environment/addons/theme\",])", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "subset.first()", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"source": "### See how many addons have no description", "cell_type": "markdown", "metadata": {}}, {"execution_count": 20, "cell_type": "code", "source": "def get_partial_addon_id(p):\n ids = []\n \n addons = p.get(\"environment/addons/activeAddons\", None)\n if not addons:\n ids.append(\"No addons\");\n return ids\n \n for addon_id in addons:\n addon = addons[addon_id]\n\n if not \"name\" in addon:\n ids.append(addon_id)\n elif not \"description\" in addon:\n ids.append(addon_id)\n elif not \"version\" in addon:\n ids.append(addon_id)\n \n return ids", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 26, "cell_type": "code", "source": "partial_addons = subset.flatMap(get_partial_addon_id).distinct()", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 27, "cell_type": "code", "source": "#partial_addons_series = pd.Series(partial_addons)\n#partial_addons_series.value_counts()\npartial_addons.count()", "outputs": [{"execution_count": 27, "output_type": "execute_result", "data": {"text/plain": "1618521"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "partial_addons_series.describe()", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"source": "### How many clients are affected?", "cell_type": "markdown", "metadata": {}}, {"execution_count": 15, "cell_type": "code", "source": "def has_partial_activeAddon_info(p):\n addons = p.get(\"environment/addons/activeAddons\", None)\n if not addons:\n return False\n\n for addon_id in addons:\n addon = addons[addon_id]\n\n if not \"name\" in addon or not \"description\" in addon or not \"version\" in addon:\n return True\n \n return False\n\ndef has_partial_addon_info(p):\n if has_partial_activeAddon_info(p):\n return True\n \n theme = p.get(\"environment/addons/theme\", None)\n if theme and (not \"name\" in theme or not \"description\" in theme or not \"version\" in theme):\n return True\n\n plugins = p.get(\"environment/addons/activePlugins\", None)\n if plugins:\n try:\n for plugin in plugins:\n if not \"name\" in plugin or not \"description\" in plugin or not \"version\" in plugin:\n return True\n except TypeError:\n return False\n \n return False", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 16, "cell_type": "code", "source": "affected_pings = subset.filter(has_partial_addon_info)", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 17, "cell_type": "code", "source": "affected_pings.count()", "outputs": [{"execution_count": 17, "output_type": "execute_result", "data": {"text/plain": "55531196"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 18, "cell_type": "code", "source": "affected_clients = get_one_ping_per_client(affected_pings)\naffected_clients.count()", "outputs": [{"execution_count": 18, "output_type": "execute_result", "data": {"text/plain": "11181842"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 19, "cell_type": "code", "source": "all_clients = get_one_ping_per_client(subset)\nall_clients.count()", "outputs": [{"execution_count": 19, "output_type": "execute_result", "data": {"text/plain": "76994736"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.9", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment