# Buggy code
def __init__(
    self,
    text: str,
    id: Optional[Union[str, UUID]] = None,
    query_score: Optional[float] = None,
    question: Optional[str] = None,
    meta: Dict[str, Any] = None,
    tags: Optional[Dict[str, Any]] = None,
    embedding: Optional[List[float]] = None,
):
    """
    Object used to represent documents / passages in a standardized way within Haystack.
    For example, this is what the retriever will return from the DocumentStore,
    regardless if it's ElasticsearchDocumentStore or InMemoryDocumentStore.

    Note that there can be multiple Documents originating from one file (e.g. PDF),
    if you split the text into smaller passages. We'll have one Document per passage in this case.

    :param id: ID used within the DocumentStore
    :param text: Text of the document
    :param query_score: Retriever's query score for a retrieved document
    :param question: Question text for FAQs.
    :param meta: Meta fields for a document like name, url, or author.
    :param tags: Tags that allow filtering of the data
    :param embedding: Vector encoding of the text
    """

    self.text = text
    # Create a unique ID (either new one, or one from user input)
    if id:
        if isinstance(id, str):
            self.id = UUID(hex=str(id), version=4)
        if isinstance(id, UUID):
            self.id = id
    else:
        self.id = uuid4()

    self.query_score = query_score
    self.question = question
    self.meta = meta
    self.tags = tags  # deprecate?
    self.embedding = embedding


# Traceback (ValueError)
07/31/2020 16:12:59 - INFO - haystack.retriever.dpr_utils -   Loading saved model from models/dpr/checkpoint/retriever/single/nq/bert-base-encoder.cp
07/31/2020 16:12:59 - INFO - haystack.retriever.dense -   Loaded encoder params:  {'do_lower_case': True, 'pretrained_model_cfg': 'bert-base-uncased', 'encoder_model_type': 'hf_bert', 'pretrained_file': None, 'projection_dim': 0, 'sequence_length': 256}
07/31/2020 16:13:09 - INFO - haystack.retriever.dense -   Loading saved model state ...
07/31/2020 16:13:09 - INFO - haystack.retriever.dense -   Loading saved model state ...
07/31/2020 16:13:09 - INFO - elasticsearch -   POST https://df4bc7e5f2a54314ac10223dd343fe94.us-central1.gcp.cloud.es.io:9243/document/_search?scroll=5m&amp;size=1000 [status:200 request:0.139s]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-9372aaabee19> in <module>()
11 # At query time, we only need to embed the query and compare it the existing doc embeddings which is very fast.
12
---> 13 document_store.update_embeddings(retriever)
14
15 # ES retreivar

5 frames
/usr/lib/python3.6/uuid.py in __init__(self, hex, bytes, bytes_le, fields, int, version)
138             hex = hex.strip('{}').replace('-', '')
139             if len(hex) != 32:
--> 140                 raise ValueError('badly formed hexadecimal UUID string')
141             int = int_(hex, 16)
142         if bytes_le is not None:

**ValueError: badly formed hexadecimal UUID string**

# Fixed code
def __init__(
    self,
    text: str,
    id: str = None,
    query_score: Optional[float] = None,
    question: Optional[str] = None,
    meta: Dict[str, Any] = None,
    tags: Optional[Dict[str, Any]] = None,
    embedding: Optional[List[float]] = None,
):
    """
    Object used to represent documents / passages in a standardized way within Haystack.
    For example, this is what the retriever will return from the DocumentStore,
    regardless if it's ElasticsearchDocumentStore or InMemoryDocumentStore.

    Note that there can be multiple Documents originating from one file (e.g. PDF),
    if you split the text into smaller passages. We'll have one Document per passage in this case.

    :param id: ID used within the DocumentStore
    :param text: Text of the document
    :param query_score: Retriever's query score for a retrieved document
    :param question: Question text for FAQs.
    :param meta: Meta fields for a document like name, url, or author.
    :param tags: Tags that allow filtering of the data
    :param embedding: Vector encoding of the text
    """

    self.text = text
    # Create a unique ID (either new one, or one from user input)
    if id:
        self.id = str(id)
    else:
        self.id = str(uuid4())

    self.query_score = query_score
    self.question = question
    self.meta = meta
    self.tags = tags  # deprecate?
    self.embedding = embedding