Skip to content

Dage 18: Persistent Storage JSON#179

Merged
dantuzi merged 30 commits into
dataset-generatorfrom
DAGE-18/Persistent-Storage-JSON
Aug 5, 2025
Merged

Dage 18: Persistent Storage JSON#179
dantuzi merged 30 commits into
dataset-generatorfrom
DAGE-18/Persistent-Storage-JSON

Conversation

@Intrinsical-AI

@Intrinsical-AI Intrinsical-AI commented Jul 23, 2025

Copy link
Copy Markdown
Collaborator

TASK TICKET

DAGE-18 - Includes a mini-research on mocks vs real I/O for files).

Changes

  • Improved docstrings on previous code
  • Improved logs information
  • Fixed OLD tests ("is" replaced by "==")
  • Added fns:
          save_queries_and_docs(self, filepath: str | Path) -> None:
          load_queries_and_docs(self, filepath: str | Path) -> None:
          save_rating_triples(self, filepath: str | Path) -> None:
          load_rating_triples(self, filepath: str | Path) -> None:
  • Added new tests to /tests/unit/test_data_store.py

@Intrinsical-AI Intrinsical-AI requested a review from nseidan July 23, 2025 11:39
self._query: str = query
self._doc_id_to_rating_score: Dict[str, int] = {doc_id: self.DOC_NOT_RATED}
self._doc_id_to_rating_score: Dict[str, int] = {}
# HANDLING NONEs - thowed error in some tests

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo -> throw*

@Intrinsical-AI Intrinsical-AI Jul 23, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the spot! Comming in the next commit

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve when you commit the change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: this should be solved

Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
nseidan
nseidan previously approved these changes Jul 24, 2025
@nseidan

nseidan commented Jul 24, 2025

Copy link
Copy Markdown

I approved this, but please make changes on the things mentioned and feel free to resolve the conversations once you update .

@Intrinsical-AI Intrinsical-AI changed the title Dage 18/persistent storage json Dage 18: Persistent Storage w/ json Jul 24, 2025
@Intrinsical-AI Intrinsical-AI changed the title Dage 18: Persistent Storage w/ json Dage 18: Persistent Storage JSON Jul 24, 2025
nicolo-rinaldi
nicolo-rinaldi previously approved these changes Jul 25, 2025
Comment thread rre-dataset-generator/src/model/query_rating_context.py
Comment thread rre-dataset-generator/src/search_engine/data_store.py
Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
@Intrinsical-AI

Copy link
Copy Markdown
Collaborator Author

@dantuzi should make more sense in general now

Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
"query_text": query.get_query(),
"doc_ids": query.get_doc_ids(),
"doc_ratings": query._doc_id_to_rating_score.copy(), # copy to avoid mutation
"documents": [doc.model_dump() for doc in documents if doc is not None]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does model_dump() do?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc it's a Pydantic model. model_dump it's the internal fn to serialize (to dict / json)

Comment thread rre-dataset-generator/src/search_engine/data_store.py Outdated
@dantuzi dantuzi force-pushed the DAGE-18/Persistent-Storage-JSON branch from 90cb945 to 49b531f Compare July 31, 2025 15:13
@Intrinsical-AI

Copy link
Copy Markdown
Collaborator Author

feat: datastore: JSON persistence + QueryContext API cleanup

Added on-disk persistence (./tmp/datastore.json) to make runs reproducible. Cleaned up QueryRatingContext with proper (de)serialization and safer access to ratings.

Included

  • DataStore.save/load_tmp_file_content() with custom serializer.
  • Stable IDs in QueryRatingContext; .to_dict() / .from_dict() methods.
  • get_query()get_query_text(); get_rating_score() raises if missing.
  • Field validator in Document to reject empty fields.
  • Writers/tests updated to use the new API; TMP file path patchable for tests.

Comment thread rre-dataset-generator/tests/unit/test_data_store.py Outdated
Comment thread rre-dataset-generator/tests/unit/test_query_rating_context.py Outdated
return path


def test_add_and_get_document(empty_store):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the naming convention test_expect

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added naming conventions

Comment thread rre-dataset-generator/tests/unit/test_query_rating_context.py Outdated
@Intrinsical-AI Intrinsical-AI force-pushed the DAGE-18/Persistent-Storage-JSON branch from bc5c5ac to e01a5f3 Compare August 5, 2025 13:26
@dantuzi dantuzi self-requested a review August 5, 2025 13:43
@Intrinsical-AI Intrinsical-AI force-pushed the DAGE-18/Persistent-Storage-JSON branch from e01a5f3 to e1c3d56 Compare August 5, 2025 13:56
@dantuzi dantuzi merged commit e5219c2 into dataset-generator Aug 5, 2025
1 check passed
@dantuzi dantuzi deleted the DAGE-18/Persistent-Storage-JSON branch August 5, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants