Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Unfreeze Document in Haystack 2.0 #5974

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions haystack/preview/dataclasses/document.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from typing import List, Any, Dict, Optional, Type

import json
import hashlib
import json
import logging
from dataclasses import asdict, dataclass, field, fields
from pathlib import Path
from dataclasses import dataclass, field, fields, asdict
from typing import Any, Dict, List, Optional, Type

import numpy
import pandas


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -50,7 +48,7 @@ def document_decoder(self, dictionary):
return dictionary


@dataclass(frozen=True)
@dataclass
class Document:
"""
Base data class containing some data to be queried.
Expand Down
17 changes: 5 additions & 12 deletions test/preview/dataclasses/test_document.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
from pathlib import Path
import dataclasses
import textwrap
import json
import textwrap
from pathlib import Path

import pytest
import pandas as pd
import numpy as np
import pandas as pd
import pytest

from haystack.preview import Document
from haystack.preview.dataclasses.document import DocumentEncoder, DocumentDecoder


@pytest.mark.unit
def test_document_is_immutable():
doc = Document(text="test text")
with pytest.raises(dataclasses.FrozenInstanceError):
doc.text = "won't work"
from haystack.preview.dataclasses.document import DocumentDecoder, DocumentEncoder


@pytest.mark.unit
Expand Down