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/2813698cf14ab611d980e1264449e8e3 to your computer and use it in GitHub Desktop.
Save Dexterp37/2813698cf14ab611d980e1264449e8e3 to your computer and use it in GitHub Desktop.
Bug 1255472 - Sanity check Windows 10 version data
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# coding: utf-8
# ### Bug 1255472 - Sanity check Windows 10 version data
# In[76]:
import ujson as json
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import plotly.plotly as py
import operator
from distutils.version import StrictVersion
from moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client, get_clients_history
get_ipython().magic(u'pylab inline')
# Let's fetch the main pings.
# In[66]:
submission_dates = ("20160419", "20160421")
build_ids = ("20160419000000", "20160499999999")
main_pings = get_pings(sc,
app="Firefox",
channel="nightly",
submission_date=submission_dates,
build_id=build_ids,
doc_type="main",
schema="v4",
fraction=1.0)
# ... and extract only the attributes we need from the Telemetry submissions:
# In[67]:
subset = get_pings_properties(main_pings, ["environment/system/os/name",
"environment/system/os/version",
"environment/system/os/windowsUBR",
"environment/system/os/windowsBuildNumber",
])
# In[68]:
subset.count()
# Pick the pings coming from Windows.
# In[69]:
windows_pings = subset.filter(lambda p: p.get("environment/system/os/name") == "Windows_NT")
windows_pings.count()
# ### Check that pings from Windows ver < 10 have no UBR/build number fields
# Get the pings for Windows < 10.0
# In[70]:
windows_lessthan_10 = windows_pings.filter(lambda p: StrictVersion(p.get("environment/system/os/version")) < StrictVersion("10.0"))
windows_lessthan_10.count()
# For these pings, we don't expect to see neither windowsUBR or windowsBuildNumber.
# In[71]:
windows_lessthan_10.filter(lambda p: (p.get("environment/system/os/windowsUBR", None) != None) or (p.get("environment/system/os/windowsBuildNumber", None) != None)).count()
# ### Check that pings from Windows ver >= 10 have sane UBR/build number fields
# In[72]:
windows_gethan_10 = windows_pings.filter(lambda p: StrictVersion(p.get("environment/system/os/version")) >= StrictVersion("10.0"))
windows_gethan_10.count()
# If we're on Windows ver >= 10.0, we expect to see both the UBR and the windows build number.
# In[73]:
def validate_ubr_buildnumber(p):
windows_ubr = p.get("environment/system/os/windowsUBR", None)
windows_build_number = p.get("environment/system/os/windowsBuildNumber", None)
if windows_ubr is None:
return ("No UBR", 1)
if type(windows_ubr) != int:
return ("Unexpecteed UBR " + type(windows_ubr).__name__, 1)
if windows_build_number is None:
return ("No Build Number", 1)
if type(windows_build_number) != int:
return ("Unexpecteed Build Number " + type(windows_build_number).__name__, 1)
return ("", 1)
windows_gethan_10.map(validate_ubr_buildnumber).countByKey()
# ### Check the distribution of the UBR/build number values
# In[82]:
build_values = windows_gethan_10.map(lambda p: (str(p.get("environment/system/os/windowsBuildNumber", "")) + ", " + str(p.get("environment/system/os/windowsUBR", "")), 1))
sorted(build_values.countByKey().items(), key=operator.itemgetter(1), reverse=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment