class_docstr: Datasets DAO
class_docstr_tok: ["Datasets","DAO"]
docstr: Transforms a stored elasticsearch document into a `BaseDatasetDB`
docstr_tok: ["Transforms","a","stored","elasticsearch","document","into","a","`","BaseDatasetDB","`"]
code: def _es_doc_to_instance(
      doc: Dict[str, Any],
      ds_class: Type[DatasetDB] = BaseDatasetDB,
  ) -> DatasetDB:
      """Transforms a stored elasticsearch document into a `BaseDatasetDB`"""
  
      def key_value_list_to_dict(
          key_value_list: List[Dict[str, Any]]
      ) -> Dict[str, Any]:
          return {
              data["key"]: json.loads(data["value"])
              for data in key_value_list
          }
  
      tags = doc.get("tags", [])
      metadata = doc.get("metadata", [])
  
      data = {
          **doc,
          "tags": key_value_list_to_dict(tags),
          "metadata": key_value_list_to_dict(metadata),
      }
  
      return ds_class.parse_obj(data)
  
imports: import json
  from typing import Any, Dict, List, Optional, Type
  from fastapi import Depends
  from argilla.server.daos.backend import BaseDatasetsQuery, GenericElasticEngineBackend
  from argilla.server.daos.models.datasets import BaseDatasetDB, BaseDatasetSettingsDB, DatasetDB, DatasetSettingsDB, EmbeddingsConfig
  from argilla.server.daos.records import DatasetRecordsDAO
  from argilla.server.errors import WrongTaskError
label_desc: Use image node_id 10 for calling the DatasetsDAO obj's underlying member method code with example usage: obj._es_doc_to_instance(doc, ds_class) and returns: ds_class, unknown