def _LoadArtifactsFromDatastore(self, source_urns=None, token=None,
                                  overwrite_if_exists=True):
    """Load artifacts from the data store."""
    if token is None:
      token = access_control.ACLToken(username="GRRArtifactRegistry",
                                      reason="Managing Artifacts.")
    loaded_artifacts = []

    for artifact_coll_urn in source_urns or []:
      with aff4.FACTORY.Create(
          artifact_coll_urn, aff4_type="RDFValueCollection",
          token=token, mode="rw") as artifact_coll:
        for artifact_value in artifact_coll:
          self.RegisterArtifact(
              artifact_value, source="datastore:%s" % artifact_coll_urn,
              overwrite_if_exists=overwrite_if_exists)
          loaded_artifacts.append(artifact_value)
          logging.debug("Loaded artifact %s from %s", artifact_value.name,
                        artifact_coll_urn)

    # Once all artifacts are loaded we can validate.
    revalidate = True
    while revalidate:
      revalidate = False
      for artifact_obj in loaded_artifacts[:]:
        try:
          artifact_obj.Validate()
        except ArtifactDefinitionError as e:
          logging.error("Artifact %s did not validate: %s",
                        artifact_obj.name, e)
          artifact_obj.error_message = utils.SmartStr(e)
          loaded_artifacts.remove(artifact_obj)
          revalidate = True
dataset/ETHPy150Open google/grr/grr/lib/artifact_registry.py/ArtifactRegistry._LoadArtifactsFromDatastore/original