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

Add Dataset.tables_columns and tables_rows #113

Merged
merged 13 commits into from
Oct 22, 2024
Merged

Add Dataset.tables_columns and tables_rows #113

merged 13 commits into from
Oct 22, 2024

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented Sep 26, 2024

Closes #111

This adds the cached properties audbcards.Dataset.tables_columns and audbcards.Dataset.tables_rows,
which return the number of columns and rows for each table of a dataset.

image

image

In addition, it uses those in the HTML table preview:

image

Under the hood, it adds the private cached property audbcards.Dataset._tables_stats() to avoid loading the tables multiple times.

Summary by Sourcery

Add new cached properties tables_columns and tables_rows to the audbcards.Dataset class to provide table dimensions, and enhance the HTML table preview to display these dimensions. Update tests to cover the new properties.

New Features:

  • Introduce cached properties tables_columns and tables_rows in the audbcards.Dataset class to provide the number of columns and rows for each table in a dataset.

Enhancements:

  • Enhance the HTML table preview by displaying the number of rows and columns for each table.

Tests:

  • Update tests to include validation for the new tables_columns and tables_rows properties.

@hagenw hagenw changed the title Add Dataset.tables_rows and number of rows to table preview Add Dataset.tables_rows and show in table preview Sep 26, 2024
@hagenw hagenw marked this pull request as draft September 26, 2024 12:52
@hagenw hagenw changed the title Add Dataset.tables_rows and show in table preview Add Dataset.tables_columns and tables_rows Oct 21, 2024
@hagenw hagenw marked this pull request as ready for review October 21, 2024 12:49
Copy link

sourcery-ai bot commented Oct 21, 2024

Reviewer's Guide by Sourcery

This pull request adds new cached properties tables_columns and tables_rows to the audbcards.Dataset class, providing information about the number of columns and rows for each table in a dataset. It also introduces a private cached property _tables_stats to optimize performance by avoiding multiple table loads. The changes are integrated into the HTML table preview to display table statistics.

User journey diagram for HTML table preview enhancement

journey
    title User Journey for Enhanced HTML Table Preview
    section Accessing Dataset Table Information
      User accesses dataset table preview: 5: User
      System retrieves table statistics using tables_columns and tables_rows: 4: System
      System displays enhanced table preview with row and column counts: 5: System
    section Viewing Table Statistics
      User views table statistics in HTML preview: 5: User
      User sees number of rows and columns for each table: 5: User
Loading

Class diagram for audbcards.Dataset with new properties

classDiagram
    class Dataset {
        +cached_property tables_columns: Dict[str, int]
        +cached_property tables_rows: Dict[str, int]
        +cached_property tables_preview: Dict[str, List[List[str]]]
        +cached_property tables_table: List[str]
        +cached_property _tables_stats: Dict[str, dict]
    }
    note for Dataset "New properties tables_columns and tables_rows added"
    note for Dataset "Private cached property _tables_stats added for performance optimization"
Loading

File-Level Changes

Change Details Files
Add new cached properties to Dataset class
  • Implement tables_columns property to return number of columns for each table
  • Implement tables_rows property to return number of rows for each table
  • Add private _tables_stats property to cache table information and improve performance
audbcards/core/dataset.py
Update HTML table preview to include row and column counts
  • Modify table preview template to display row and column counts for each table
  • Add CSS styling for the new table statistics
audbcards/core/templates/datacard_tables.j2
audbcards/sphinx/table-preview.css
Extend and update tests for new functionality
  • Add test cases for tables_columns and tables_rows properties
  • Update existing tests to accommodate new properties and behavior
  • Modify test parameters to include expected values for new properties
tests/test_dataset.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hagenw - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

audbcards/core/dataset.py Outdated Show resolved Hide resolved
tests/test_dataset.py Outdated Show resolved Hide resolved
tests/test_dataset.py Outdated Show resolved Hide resolved
audbcards/core/dataset.py Outdated Show resolved Hide resolved
@hagenw hagenw marked this pull request as draft October 21, 2024 12:50
@hagenw hagenw marked this pull request as ready for review October 21, 2024 13:44
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hagenw - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tests/test_dataset.py Show resolved Hide resolved
audbcards/core/dataset.py Show resolved Hide resolved
@hagenw
Copy link
Member Author

hagenw commented Oct 21, 2024

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @hagenw - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

audbcards/core/dataset.py Show resolved Hide resolved
tests/test_dataset.py Outdated Show resolved Hide resolved
Copy link
Member

@ChristianGeng ChristianGeng left a comment

Choose a reason for hiding this comment

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

The caching structure will be modified in #115. This MR is a precursor work and will be approved.

@hagenw hagenw merged commit 0401183 into main Oct 22, 2024
10 checks passed
@hagenw hagenw deleted the tables-rows branch October 22, 2024 07:37
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.

Add number of rows (and columns?) to the table preview
2 participants