class_docstr: Datasets records DAO
class_docstr_tok: ["Datasets","records","DAO"]
docstr: Add records to dataset
  
  Parameters
  ----------
  dataset:
      The dataset
  records:
      The list of records
  record_class:
      Record class used to convert records to
  Returns
  -------
      The number of failed records
docstr_tok: ["Add","records","to","dataset","Parameters","--","--","--","--","--","dataset",":","The","dataset","records",":","The","list","of","records","record_class",":","Record","class","used","to","convert","records","to","Returns","--","--","--","-","The","number","of","failed","records"]
code: def add_records(
      self,
      dataset: DatasetDB,
      records: List[RecordDB],
      record_class: Type[RecordDB],
  ) -> int:
      """
      Add records to dataset
  
      Parameters
      ----------
      dataset:
          The dataset
      records:
          The list of records
      record_class:
          Record class used to convert records to
      Returns
      -------
          The number of failed records
  
      """
  
      now = datetime.datetime.utcnow()
      documents = []
      metadata_values = {}
  
      mapping = self._es.get_schema(id=dataset.id)
      exclude_fields = [
          name
          for name in record_class.schema()["properties"]
          if name not in mapping["mappings"]["properties"]
      ]
  
      vectors_configuration = {}
      for record in records:
          metadata_values.update(record.metadata or {})
  
          db_record = record_class.parse_obj(record)
          db_record.last_updated = now
  
          record_dict = db_record.dict(
              exclude_none=True, exclude=set(exclude_fields)
          )
  
          if record.vectors is not None:
              # TODO: Create embeddings config by settings
              for (
                  vector_name,
                  vector_data_mapping,
              ) in record.vectors.items():
                  vector_dimension = vectors_configuration.get(
                      vector_name, None
                  )
  
                  if vector_dimension is None:
                      dimension = len(vector_data_mapping.value)
                      vectors_configuration[vector_name] = dimension
  
          documents.append(record_dict)
  
      self._es.create_dataset(
          id=dataset.id,
          task=dataset.task,
          metadata_values=metadata_values,
          vectors_cfg=vectors_configuration,
      )
  
      return self._es.add_dataset_records(
          id=dataset.id,
          documents=documents,
      )
  
file_path: argilla/src/argilla/server/daos/records.py
imports: import datetime
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Type
  from fastapi import Depends
  from argilla.server.daos.backend import GenericElasticEngineBackend
  from argilla.server.daos.backend.base import ClosedIndexError, IndexNotFoundError
  from argilla.server.daos.backend.generic_elastic import PaginatedSortInfo
  from argilla.server.daos.backend.search.model import BaseRecordsQuery, SortableField
  from argilla.server.daos.models.datasets import DatasetDB
  from argilla.server.daos.models.records import DaoRecordsSearch, DaoRecordsSearchResults, RecordDB
  from argilla.server.errors import ClosedDatasetError, MissingDatasetRecordsError
label_desc: Use image node_id 4 for calling the DatasetRecordsDAO obj's underlying member method code with example usage: obj.add_records(dataset, records, record_class) and returns: self