Skip to content

Conversation

@hagenw
Copy link
Member

@hagenw hagenw commented Jan 5, 2026

Closes #483

Ensure we except all possible errors when loading a table from pickle as storing/loading with different pandas versions might result in a variety of different errors.

Summary by Sourcery

Bug Fixes:

  • Handle all exceptions raised during pickled table loading so that fallback loading from PARQUET or CSV works reliably with differing pandas versions.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Broadens the exception handling when loading pickled tables so that any error during pickle loading falls back to alternative formats like PARQUET or CSV, improving compatibility across different pandas versions.

Sequence diagram for loading a table with pickle fallback

sequenceDiagram
    participant UserCode
    participant Table
    participant PickleLoader as _load_pickled
    participant FallbackLoader as load_parquet_or_csv

    UserCode->>Table: load(pkl_file, pickled=True)
    activate Table
    Table->>PickleLoader: _load_pickled(pkl_file)
    activate PickleLoader
    PickleLoader-->>Table: raise Exception
    deactivate PickleLoader

    Note over Table: Any Exception triggers fallback

    Table->>FallbackLoader: try PARQUET or CSV
    activate FallbackLoader
    FallbackLoader-->>Table: table_data
    deactivate FallbackLoader
    Table-->>UserCode: loaded table
    deactivate Table
Loading

File-Level Changes

Change Details Files
Broaden exception handling around pickled table loading to catch all errors and trigger fallback loading from other formats.
  • Replace the narrow tuple of caught exceptions (AttributeError, ValueError, EOFError) with a generic Exception catch in the load path for pickled tables
  • Preserve the existing fallback behavior to try loading from PARQUET or CSV when pickle loading fails for any reason
audformat/core/table.py

Assessment against linked issues

Issue Objective Addressed Explanation
#483 Handle errors arising from pandas version incompatibilities when loading pickled tables (e.g., TypeError from StringDtype) by catching them and falling back to alternative formats.
#483 Allow reuse of the same audb cache across different pandas versions without requiring manual deletion of incompatible pickle files.

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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
Contributor

@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 - I've left some high level feedback:

  • Catching a broad Exception here may mask unexpected issues unrelated to pickle/pandas compatibility; consider either narrowing the set of caught exceptions or checking the exception type/message before falling back to PARQUET/CSV.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Catching a broad `Exception` here may mask unexpected issues unrelated to pickle/pandas compatibility; consider either narrowing the set of caught exceptions or checking the exception type/message before falling back to PARQUET/CSV.

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.

@hagenw hagenw self-assigned this Jan 5, 2026
@hagenw hagenw requested a review from audeerington January 5, 2026 13:53
@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (abdbbd2) to head (67ce13b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
audformat/core/table.py 100.0% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hagenw hagenw merged commit 1053f7f into main Jan 7, 2026
13 checks passed
@hagenw hagenw deleted the catch-type-error branch January 7, 2026 08:55
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.

Error loading a cached database stored with newer pandas version

3 participants