Skip to content

Instantly share code, notes, and snippets.


mhammond/Max validation errors.ipynb Secret

Last active Jan 31, 2017
What would you like to do?
Max validation errors
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# In[1]:
from moztelemetry import get_pings, get_pings_properties
# filter the ones we care about early...
def filterOurs(ping):
syncs = ping["payload"]["syncs"]
except KeyError:
return False
for sync in syncs:
for engine in sync.get("engines", []):
if "name" in engine and engine["name"] == "bookmarks" and "validation" in engine and "problems" in engine["validation"]:
return True
return False
pings = get_pings(sc, doc_type='sync', fraction=1.0).filter(filterOurs)
# In[2]:
def flattenBookmarkValidations(ping):
result = []
for sync in ping["payload"]["syncs"]:
for engine in sync.get("engines", []):
if "validation" in engine:
# turn it into a dict.
this = {}
for problem in engine["validation"]["problems"]:
this[problem["name"]] = problem["count"]
return result
# And reduce each one into the max
def reduceToMax(a, b):
allKeys = set(a.keys())
result = {}
for key in allKeys:
result[key] = max(a.get(key, 0), b.get(key, 0))
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment