mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-08-29 19:06:21 +00:00
feat: Unfreeze Document in Haystack 2.0 (#5974)
* Unfreeze document * Remove immutability test
This commit is contained in:
parent
f983e605c7
commit
282419d82b
@ -1,15 +1,13 @@
|
|||||||
from typing import List, Any, Dict, Optional, Type
|
|
||||||
|
|
||||||
import json
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from dataclasses import asdict, dataclass, field, fields
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from dataclasses import dataclass, field, fields, asdict
|
from typing import Any, Dict, List, Optional, Type
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
import pandas
|
import pandas
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ class DocumentDecoder(json.JSONDecoder):
|
|||||||
return dictionary
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass
|
||||||
class Document:
|
class Document:
|
||||||
"""
|
"""
|
||||||
Base data class containing some data to be queried.
|
Base data class containing some data to be queried.
|
||||||
|
@ -1,21 +1,14 @@
|
|||||||
from pathlib import Path
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import textwrap
|
|
||||||
import json
|
import json
|
||||||
|
import textwrap
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
|
||||||
import pandas as pd
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import pytest
|
||||||
|
|
||||||
from haystack.preview import Document
|
from haystack.preview import Document
|
||||||
from haystack.preview.dataclasses.document import DocumentEncoder, DocumentDecoder
|
from haystack.preview.dataclasses.document import DocumentDecoder, DocumentEncoder
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
|
||||||
def test_document_is_immutable():
|
|
||||||
doc = Document(text="test text")
|
|
||||||
with pytest.raises(dataclasses.FrozenInstanceError):
|
|
||||||
doc.text = "won't work"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user