def CreateRowEntities(histogram_dict, test_metadata_key, stat_names_to_test_keys, revision): h = histogram_module.Histogram.FromDict(histogram_dict) # TODO(#3564): Move this check into _PopulateNumericalFields once we # know that it's okay to put rows that don't have a value/error. if h.num_values == 0: return None rows = [] row_dict = _MakeRowDict(revision, test_metadata_key.id(), h) properties = add_point.GetAndValidateRowProperties(row_dict) test_container_key = utils.GetTestContainerKey(test_metadata_key) rows.append( graph_data.Row(id=revision, parent=test_container_key, **properties)) for stat_name, suffixed_key in stat_names_to_test_keys.iteritems(): row_dict = _MakeRowDict(revision, suffixed_key.id(), h, stat_name=stat_name) properties = add_point.GetAndValidateRowProperties(row_dict) test_container_key = utils.GetTestContainerKey(suffixed_key) rows.append( graph_data.Row(id=revision, parent=suffixed_key, **properties)) return rows
def AddRows(histogram_dict, test_metadata_key, stat_names_to_test_keys, revision, internal_only): h = histogram_module.Histogram.FromDict(histogram_dict) # TODO(eakuefner): Move this check into _PopulateNumericalFields once we # know that it's okay to put rows that don't have a value/error (see # https://github.com/catapult-project/catapult/issues/3564). if h.num_values == 0: return None rows = [] row_dict = _MakeRowDict(revision, test_metadata_key.id(), h) properties = add_point.GetAndValidateRowProperties(row_dict) test_container_key = utils.GetTestContainerKey(test_metadata_key) rows.append( graph_data.Row(id=revision, parent=test_container_key, internal_only=internal_only, **properties)) for stat_name, suffixed_key in stat_names_to_test_keys.iteritems(): row_dict = _MakeRowDict(revision, suffixed_key.id(), h, stat_name=stat_name) properties = add_point.GetAndValidateRowProperties(row_dict) test_container_key = utils.GetTestContainerKey(suffixed_key) rows.append( graph_data.Row(id=revision, parent=suffixed_key, internal_only=internal_only, **properties)) return rows
def AddRow(histogram_dict, test_metadata_key, revision, test_path, internal_only): h = histogram_module.Histogram.FromDict(histogram_dict) # TODO(eakuefner): Move this check into _PopulateNumericalFields once we # know that it's okay to put rows that don't have a value/error (see # https://github.com/catapult-project/catapult/issues/3564). if h.num_values == 0: return row_dict = _MakeRowDict(revision, test_path, h) properties = add_point.GetAndValidateRowProperties(row_dict) test_container_key = utils.GetTestContainerKey(test_metadata_key) row = graph_data.Row(id=revision, parent=test_container_key, internal_only=internal_only, **properties) row.put()
def _AddRow(row_dict, whitelist): """Add a Row entity to the datastore. There are three main things that are needed in order to make a new entity; the ID, the parent key, and all of the properties. Making these three things, and validating the related input fields, are delegated to sub-functions. Args: row_dict: A dictionary obtained from the JSON that was received. whitelist: A BotWhitelist entity, which determines what new tests are marked as internal-only. Returns: A triple: The new row, the parent test, and a list of entity put futures. Raises: add_point.BadRequestError: The input dict was invalid. RuntimeError: The required parent entities couldn't be created. """ parent_test = _GetParentTest(row_dict, whitelist) test_container_key = utils.GetTestContainerKey(parent_test.key) columns = add_point.GetAndValidateRowProperties(row_dict) columns['internal_only'] = parent_test.internal_only row_id = add_point.GetAndValidateRowId(row_dict) # Update the last-added revision record for this test. master, bot, test = row_dict['master'], row_dict['bot'], row_dict['test'] test_path = '%s/%s/%s' % (master, bot, test) last_added_revision_entity = graph_data.LastAddedRevision( id=test_path, revision=row_id) entity_put_futures = [] entity_put_futures.append(last_added_revision_entity.put_async()) # If the row ID isn't the revision, that means that the data is Chrome OS # data, and we want the default revision to be Chrome version. if row_id != row_dict.get('revision'): columns['a_default_rev'] = 'r_chrome_version' # Create the entity and add it asynchronously. new_row = graph_data.Row(id=row_id, parent=test_container_key, **columns) entity_put_futures.append(new_row.put_async()) return new_row, parent_test, entity_put_futures