def init_from_datastore(self):
    """Init list of submission from Datastore.

    Should be called by each worker during initialization.
    """
    self._attacks = {}
    self._targeted_attacks = {}
    self._defenses = {}
    for entity in self._datastore_client.query_fetch(kind=KIND_SUBMISSION):
      submission_id = entity.key.flat_path[-1]
      submission_path = entity['submission_path']
      participant_id = {k: entity[k]
                        for k in ['team_id', 'baseline_id']
                        if k in entity}
      submission_descr = SubmissionDescriptor(path=submission_path,
                                              participant_id=participant_id)
      if list(entity.key.flat_path[0:2]) == ATTACKS_ENTITY_KEY:
        self._attacks[submission_id] = submission_descr
      elif list(entity.key.flat_path[0:2]) == TARGET_ATTACKS_ENTITY_KEY:
        self._targeted_attacks[submission_id] = submission_descr
      elif list(entity.key.flat_path[0:2]) == DEFENSES_ENTITY_KEY:
        self._defenses[submission_id] = submission_descr
def init_from_datastore ( self ) : self . _attacks = { } self . _targeted_attacks = { } self . _defenses = { } for entity in self . _datastore_client . query_fetch ( kind = KIND_SUBMISSION ) : submission_id = entity . key . flat_path [ - 1 ] submission_path = entity [ 'submission_path' ] participant_id = { k : entity [ k ] for k in [ 'team_id' , 'baseline_id' ] if k in entity } submission_descr = SubmissionDescriptor ( path = submission_path , participant_id = participant_id ) if list ( entity . key . flat_path [ 0 : 2 ] ) == ATTACKS_ENTITY_KEY : self . _attacks [ submission_id ] = submission_descr elif list ( entity . key . flat_path [ 0 : 2 ] ) == TARGET_ATTACKS_ENTITY_KEY : self . _targeted_attacks [ submission_id ] = submission_descr elif list ( entity . key . flat_path [ 0 : 2 ] ) == DEFENSES_ENTITY_KEY : self . _defenses [ submission_id ] = submission_descr
Init list of submission from Datastore.

    Should be called by each worker during initialization.