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

Rework Article class #559

Merged
merged 6 commits into from
Jul 17, 2024
Merged

Rework Article class #559

merged 6 commits into from
Jul 17, 2024

Conversation

MaxDall
Copy link
Collaborator

@MaxDall MaxDall commented Jul 12, 2024

Overhaul of Article Class with Enhanced Data Management

Overview

This PR presents a comprehensive overhaul of the Article class to improve data handling and maintainability.

Key Changes

  • Introduction of Data Views: The refactor emphasizes maintaining raw extraction data as the primary source while providing structured Views for data access. This approach facilitates easier benchmarking and evaluation.

  • Implementation of Custom Attribute Handling: Custom __getattribute__ and __setattr__ methods replicate Descriptor-like behavior, ensuring controlled attribute access without relying on class attributes.

  • Read-Only Attributes: Initially, all extraction data is read-only to enhance security and stability. This simplifies data integrity management, with provisions for future writable features.

This PR serves as preparation for the upcoming CC-NEWS benchmark!

@MaxDall MaxDall requested a review from dobbersc July 12, 2024 13:58
@MaxDall MaxDall marked this pull request as draft July 12, 2024 15:43
@MaxDall MaxDall marked this pull request as ready for review July 16, 2024 14:12
@MaxDall MaxDall requested a review from addie9800 July 16, 2024 14:12
Copy link
Collaborator

@addie9800 addie9800 left a comment

Choose a reason for hiding this comment

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

Thank you for the rework. This looks really good 👍

src/fundus/scraping/article.py Show resolved Hide resolved
src/fundus/scraping/article.py Outdated Show resolved Hide resolved
src/fundus/scraping/article.py Show resolved Hide resolved

def __getattribute__(self, item: str):
if (attribute := object.__getattribute__(self, item)) and hasattr(attribute, "__get__"):
return attribute.__get__(self, type(self))
Copy link
Collaborator

Choose a reason for hiding this comment

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

When does this case come into play? I tried playing around a bit, but didn't find a setting where it is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Every unvalidated attribute, more precise, every attribute that is added as AttributeView rather than a property is accessed this way.
You can see this in action in the test_extraction_view_getter test case.

@MaxDall MaxDall requested a review from addie9800 July 17, 2024 12:56
@MaxDall MaxDall merged commit 94ccc15 into master Jul 17, 2024
4 checks passed
@MaxDall MaxDall deleted the rework-article branch July 17, 2024 15:09
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.

2 participants