Skip to content

Instantly share code, notes, and snippets.

@AndrewGreen
Last active September 19, 2016 02:29
Show Gist options
  • Save AndrewGreen/7543e550d5d14ccc6e2399950e76f404 to your computer and use it in GitHub Desktop.
Save AndrewGreen/7543e550d5d14ccc6e2399950e76f404 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "AndyRussG_BannerHistory_errors"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": "SAMPLE_SIZE = 200\nPAST_HOUR_RANGE = 2160 # 90 days * 24 hrs\n\nimport json\nfrom datetime import datetime, timedelta\n\nevents = []\n\nfor _ in range( SAMPLE_SIZE ):\n h = random.randint( 0, PAST_HOUR_RANGE - 1 )\n dh = datetime.today() - timedelta( hours = h )\n f_name = \"/wmf/data/raw/eventlogging/eventlogging_CentralNoticeBannerHistory/hourly/\" + \\\n \"{}/{:02d}/{:02d}/{:02d}\".format( dh.year, dh.month, dh.day, dh.hour )\n rdd = sc.sequenceFile( f_name )\n event = json.loads(rdd.first()[1])['event']\n events.append(event)\n\nerrors = [event['e'] for event in events if 'e' in event]\nerrors",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 1,
"text": "[u'LocalStorage not available.',\n u'LocalStorage not available.',\n u'LocalStorage not available.',\n u'LocalStorage not available.']"
}
],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": "len(events)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 2,
"text": "200"
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": "len(errors)",
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": "4"
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": "",
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment