Skip to content

usaspending-orm v0.5.1

Choose a tag to compare

@caseydreier caseydreier released this 13 Sep 04:26
· 197 commits to main since this release

usaspending-orm v0.5.1

This release focuses on improving reliability, data handling, and resiliency. Key changes include a critical fix to the lazy loading logic, robust fallback for cache failures, and more detailed query logging.

Highlights

  • Improved Lazy Loading: Lazy-loaded attributes will now correctly fetch fresh data from the API if their current value is None or the key is missing. This fixes a critical bug where None values were incorrectly treated as valid data, particularly affecting the Recipient.parents property.
  • Robust Cache Fallback: The client is now more resilient to caching issues. If the cache fails, returns invalid data, or raises an exception, the client will automatically fall back to an uncached API request, ensuring your application continues to function.
  • Centralized Model Validation: Model initialization is now more consistent and robust with a new centralized validation method. This improves error handling when creating Agency, Award, and Recipient objects from invalid data (e.g., None or incorrect types).

Features & Improvements

  • Enhanced Query Logging: Query logging is now significantly more detailed. At the DEBUG level, logs include a full breakdown of the filters being applied to a query, making debugging much easier. At the INFO level, active filter keys are logged.

Bug Fixes

  • Fixed a bug in LazyRecord where a None value for an attribute would prevent lazy loading from being triggered. The logic now correctly fetches data when a key is missing or its value is None.
  • The Recipient.parents property now correctly uses the lazy loading mechanism to fetch parent data when it's not present in the initial object data.

Refactoring & Configuration Changes

  • The Recipient.alternate_names property now always returns a list, defaulting to an empty list ([]) instead of None if no names are present.
  • Sessions will now refresh after 250 calls to prevent IP throttling from the USASpending API. This is helpful when running extensive querying.

Full Changelog: v0.5.0...v0.5.1