tools/perf/cli_tools/flakiness_cli/analysis.py
def AggregateBuilds(df, half_life):
  """Aggregate results from multiple builds of the same test configuration.

  Also computes the "flakiness" of a test configuration.

  Args:
    df: A data frame with test results per build for a single test
      configuration (i.e. fixed master, builder, test_type).
    half_life: A number of days. Builds failures from these many days ago are
      half as important as a build failing today.
  """
  results_key = ResultsKey()
  df = df.copy()
  df['result'] = CompactResults(df['result'])
  df['status'] = df['result'].map(results_key['char'])
  df['flakiness'] = df['result'].map(results_key['badness'])
  time_ago = df['timestamp'].max() - df['timestamp']
  days_ago = time_ago.dt.total_seconds() / SECONDS_IN_A_DAY
  df['weight'] = numpy.power(0.5, days_ago / half_life)
  df['flakiness'] *= df['weight']
  latest_build = df['build_number'].iloc[0]

  grouped = df.groupby(['builder', 'test_suite', 'test_case'])
  df = grouped['flakiness'].sum().to_frame()
  df['flakiness'] *= 100 / grouped['weight'].sum()
  df['build_number'] = latest_build
  df['status'] = grouped['status'].agg(lambda s: s.str.cat())
  return df
Aggregate results from multiple builds of the same test configuration.

  Also computes the "flakiness" of a test configuration.

  Args:
    df: A data frame with test results per build for a single test
      configuration (i.e. fixed master, builder, test_type).
    half_life: A number of days. Builds failures from these many days ago are
      half as important as a build failing today.
  
Aggregate results from multiple builds of the same test configuration.
Also computes the "flakiness" of a test configuration.
Aggregate results from multiple builds of the same test configuration . Also computes the " flakiness " of a test configuration .
def AggregateBuilds(df, half_life):
  results_key = ResultsKey()
  df = df.copy()
  df['result'] = CompactResults(df['result'])
  df['status'] = df['result'].map(results_key['char'])
  df['flakiness'] = df['result'].map(results_key['badness'])
  time_ago = df['timestamp'].max() - df['timestamp']
  days_ago = time_ago.dt.total_seconds() / SECONDS_IN_A_DAY
  df['weight'] = numpy.power(0.5, days_ago / half_life)
  df['flakiness'] *= df['weight']
  latest_build = df['build_number'].iloc[0]
  grouped = df.groupby(['builder', 'test_suite', 'test_case'])
  df = grouped['flakiness'].sum().to_frame()
  df['flakiness'] *= 100 / grouped['weight'].sum()
  df['build_number'] = latest_build
  df['status'] = grouped['status'].agg(lambda s: s.str.cat())
  return df
def AggregateBuilds ( df , half_life ) : results_key = ResultsKey ( ) df = df . copy ( ) df [ 'result' ] = CompactResults ( df [ 'result' ] ) df [ 'status' ] = df [ 'result' ] . map ( results_key [ 'char' ] ) df [ 'flakiness' ] = df [ 'result' ] . map ( results_key [ 'badness' ] ) time_ago = df [ 'timestamp' ] . max ( ) - df [ 'timestamp' ] days_ago = time_ago . dt . total_seconds ( ) / SECONDS_IN_A_DAY df [ 'weight' ] = numpy . power ( 0.5 , days_ago / half_life ) df [ 'flakiness' ] *= df [ 'weight' ] latest_build = df [ 'build_number' ] . iloc [ 0 ] grouped = df . groupby ( [ 'builder' , 'test_suite' , 'test_case' ] ) df = grouped [ 'flakiness' ] . sum ( ) . to_frame ( ) df [ 'flakiness' ] *= 100 / grouped [ 'weight' ] . sum ( ) df [ 'build_number' ] = latest_build df [ 'status' ] = grouped [ 'status' ] . agg ( lambda s : s . str . cat ( ) ) return df
Aggregate results from multiple builds of the same test configuration.
Aggregate results from multiple builds of the same test configuration .
"""Aggregate results from multiple builds of the same test configuration.

  Also computes the "flakiness" of a test configuration.

  Args:
    df: A data frame with test results per build for a single test
      configuration (i.e. fixed master, builder, test_type).
    half_life: A number of days. Builds failures from these many days ago are
      half as important as a build failing today.
  """
df
A data frame with test results per build for a single test
configuration .
A data frame with test results per build for a single test configuration .
half_life
A number of days. Builds failures from these many days ago are
half as important as a build failing today.
A number of days . Builds failures from these many days ago are half as important as a build failing today .