| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stderr", | |
| "output_type": "stream", | |
| "text": [ | |
| "/mnt/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n", | |
| " warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\n" | |
| ] | |
| }, | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Unable to parse whitelist (/mnt/anaconda2/lib/python2.7/site-packages/moztelemetry/histogram-whitelists.json). Assuming all histograms are acceptable.\n", | |
| "Populating the interactive namespace from numpy and matplotlib\n", | |
| "Cloning into 'telemetry_utils'...\n", | |
| "remote: Counting objects: 64, done.\u001b[K\n", | |
| "remote: Total 64 (delta 0), reused 0 (delta 0), pack-reused 64\u001b[K\n", | |
| "Unpacking objects: 100% (64/64), done.\n", | |
| "Checking connectivity... done.\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "import ujson as json\n", | |
| "import matplotlib.pyplot as plt\n", | |
| "import pandas as pd\n", | |
| "import numpy as np\n", | |
| "import plotly.plotly as py\n", | |
| "import IPython\n", | |
| "\n", | |
| "from __future__ import division\n", | |
| "from moztelemetry.spark import get_one_ping_per_client, get_pings_properties\n", | |
| "from moztelemetry import Dataset\n", | |
| "from montecarlino import grouped_permutation_test\n", | |
| "\n", | |
| "%pylab inline\n", | |
| "IPython.core.pylabtools.figsize(16, 7)\n", | |
| "import warnings; warnings.simplefilter('ignore')\n", | |
| "\n", | |
| "\n", | |
| "!rm -rf telemetry_utils && git clone https://github.com/ekr/telemetry_utils\n", | |
| "sc.addPyFile(\"telemetry_utils/lib/utils.py\")\n", | |
| "import utils\n", | |
| "sc.addPyFile(\"telemetry_utils/lib/tls.py\")\n", | |
| "import tls\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "def tls_exp_handle_ping(accums, p):\n", | |
| " try:\n", | |
| " results = p[\"payload\"][\"results\"]\n", | |
| " for res in results:\n", | |
| " if \"status\" in res and res[\"status\"] == 200:\n", | |
| " accums[res[\"url\"]][\"success\"].add(1)\n", | |
| " else:\n", | |
| " accums[res[\"url\"]][\"failure\"].add(1)\n", | |
| " except:\n", | |
| " accums[\"except\"].add(1)\n", | |
| " pass\n", | |
| "\n", | |
| "def tls_exp_results(pings):\n", | |
| " urls = [\n", | |
| " \"https://enabled.tls13.com/\",\n", | |
| " \"https://disabled.tls13.com/\",\n", | |
| " \"https://short.tls13.com/\",\n", | |
| " \"https://control.tls12.com/\"]\n", | |
| " accums = {}\n", | |
| " for u in urls:\n", | |
| " accums[u] = {\n", | |
| " \"success\":sc.accumulator(0),\n", | |
| " \"failure\":sc.accumulator(0),\n", | |
| " }\n", | |
| " accums[\"except\"] = sc.accumulator(0)\n", | |
| "\n", | |
| " pings.foreach(lambda p: tls_exp_handle_ping(accums, p))\n", | |
| "\n", | |
| " results = {}\n", | |
| " for u in urls:\n", | |
| " results[u] = {\n", | |
| " \"success\": accums[u][\"success\"].value,\n", | |
| " \"failure\": accums[u][\"failure\"].value,\n", | |
| " }\n", | |
| " return [results, accums[\"except\"].value]\n", | |
| "\n", | |
| " \n", | |
| "\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "ds = Dataset.from_source('telemetry').where(docType='tls_13_study_v3')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "s = ds.records(sc,sample=.01)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "res01 = tls_exp_results(s)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python [default]", | |
| "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.12" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 1 | |
| } |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment