<commit_before># Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import logging

from google.appengine.ext import deferred
from google.appengine.ext import ndb

from dashboard import list_tests
from dashboard import update_test_suites
from dashboard.common import datastore_hooks
from dashboard.common import namespaced_stored_object
from dashboard.common import request_handler
from dashboard.common import stored_object
from dashboard.common import utils
from dashboard.models import graph_data
from dashboard.models import histogram
from tracing.value.diagnostics import reserved_infos
from tracing.value.diagnostics import generic_set


def CacheKey(master, test_suite):
  return 'test_suite_descriptor_%s_%s' % (master, test_suite)


def FetchCachedTestSuiteDescriptor(master, test_suite):
  masters = [master]
  if not master:
    masters = _GetMastersForSuite(test_suite)

  futures = [
      namespaced_stored_object.GetAsync(CacheKey(m, test_suite))
      for m in masters
  ]

  ndb.Future.wait_all(futures)

  desc = {'measurements': [], 'bots': [], 'cases': [], 'caseTags': {}}

  for f in futures:
    cur_desc = f.get_result()

    desc['measurements'].extend(cur_desc['measurements'])
    desc['bots'].extend(cur_desc['bots'])
    desc['cases'].extend(cur_desc['cases'])
    for tag, case_tags in cur_desc['caseTags'].iteritems():
      desc['caseTags'].setdefault(tag, []).extend(case_tags)

  desc['measurements'] = list(sorted(set(desc['measurements'])))
  desc['bots'] = list(sorted(set(desc['bots'])))
  desc['cases'] = list(sorted(set(desc['cases'])))
  for tag in desc['caseTags'].keys():
    desc['caseTags'][tag] = list(sorted(set(desc['caseTags'][tag])))

  return desc


class UpdateTestSuiteDescriptorsHandler(request_handler.RequestHandler):

  def get(self):
    self.post()<commit_msg>Fix DescribeHandler request for test_suite=='webrtc_perf_tests'.<commit_after># Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import logging

from google.appengine.ext import deferred
from google.appengine.ext import ndb

from dashboard import list_tests
from dashboard import update_test_suites
from dashboard.common import datastore_hooks
from dashboard.common import namespaced_stored_object
from dashboard.common import request_handler
from dashboard.common import stored_object
from dashboard.common import utils
from dashboard.models import graph_data
from dashboard.models import histogram
from tracing.value.diagnostics import reserved_infos
from tracing.value.diagnostics import generic_set


def CacheKey(master, test_suite):
  return 'test_suite_descriptor_%s_%s' % (master, test_suite)


def FetchCachedTestSuiteDescriptor(master, test_suite):
  masters = [master]
  if not master:
    masters = _GetMastersForSuite(test_suite)

  futures = [
      namespaced_stored_object.GetAsync(CacheKey(m, test_suite))
      for m in masters
  ]

  ndb.Future.wait_all(futures)

  desc = {'measurements': [], 'bots': [], 'cases': [], 'caseTags': {}}

  for f in futures:
    cur_desc = f.get_result()
    if cur_desc is not None:
      desc['measurements'].extend(cur_desc['measurements'])
      desc['bots'].extend(cur_desc['bots'])
      desc['cases'].extend(cur_desc['cases'])
      for tag, case_tags in cur_desc['caseTags'].iteritems():
        desc['caseTags'].setdefault(tag, []).extend(case_tags)

  desc['measurements'] = list(sorted(set(desc['measurements'])))
  desc['bots'] = list(sorted(set(desc['bots'])))
  desc['cases'] = list(sorted(set(desc['cases'])))
  for tag in desc['caseTags'].keys():
    desc['caseTags'][tag] = list(sorted(set(desc['caseTags'][tag])))

  return desc


class UpdateTestSuiteDescriptorsHandler(request_handler.RequestHandler):

  def get(self):
    self.post()
{'fraction_non_alphanumeric': 0.1114045618247299, 'fraction_numerical': 0.0019207683073229293, 'mean_word_length': 5.591772151898734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5211968', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1241, 'n_words': 326}