Skip to content

Conversation

@lpi-tn
Copy link
Collaborator

@lpi-tn lpi-tn commented Jan 13, 2026

This pull request focuses on improving the serialization of metadata extracted from UVED documents, ensuring that all relevant objects are converted to dictionaries for compatibility with JSON serialization. It also adds a test to verify that the metadata can be serialized without errors.

Metadata Serialization Improvements:

  • Updated the _extract_metadata method in uved.py to convert all extracted topic, level, scholar institution type, field of education, and author objects to dictionaries using asdict, ensuring the returned metadata is fully JSON-serializable. [1] [2]
  • Imported asdict from dataclasses in uved.py to support the new serialization logic.

Testing Enhancements:

  • Added a new test test_serialize_metadata in test_uved.py to verify that the metadata extracted from a UVED item can be serialized to JSON without errors.

@lpi-tn lpi-tn requested a review from Copilot January 13, 2026 16:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures that metadata extracted from UVED documents is fully JSON-serializable by converting dataclass objects to dictionaries. This addresses serialization issues that would occur when attempting to convert metadata containing dataclass instances to JSON.

Changes:

  • Converted topics, levels, scholar institution types, fields of education, and authors from dataclass objects to dictionaries using asdict
  • Added test case to verify metadata can be serialized to JSON without errors

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
welearn_datastack/plugins/rest_requesters/uved.py Updated _extract_metadata to convert all dataclass objects to dictionaries for JSON serialization
tests/document_collector_hub/plugins_test/test_uved.py Added test to verify metadata serialization works correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…'t assert anything. Consider adding an assertion to verify the serialization succeeds, such as self.assertIsInstance(json.dumps(metadata), str) or at minimum add a comment explaining that this test validates no exception is raised.
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.

3 participants