✨ (providers): Implement Phase 1.2 Provider Engine#412
Open
juftin wants to merge 1 commit into
Open
Conversation
- Created CampsiteDTO and BaseProvider ABC. - Implemented RecreationGovProvider async engine with optimized chunked paging. - Replaced raw dictionaries with typed Pydantic models for search/availability parameters and metadata. - Resolved type safety across asyncio.gather with explicit casts. - Added comprehensive pytest-vcr integration tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement the Phase 1.2 "Provider Engine" async architecture and fully migrate the Recreation.gov provider to a strongly-typed, high-performance parallel async implementation.
Context
Transitioning the legacy command line interface into a robust, modern full-stack web application requires a highly performant, async-first, and de-duplicated campsite polling worker. This PR establishes the core provider abstraction framework and completely refactors the Recreation.gov provider into Pydantic v2 data models, standard
StrEnumparameters, and safeasyncio.gatherparallel queries.Changes
Code Changes
backend/packages/providers/providers/dto.pyCampsiteTypeandCampsiteDTOmodels to represent unified data transfer objects returned by all campsite booking APIs.backend/packages/providers/providers/base.pyBaseProviderto declare async signatures forfind_availabilities,sync_metadata, andpopulate_database.fake-useragenton initialization.backend/packages/providers/providers/recreation_gov/config.pyRecreationGovConfigclass utilizing urllib urljoins.backend/packages/providers/providers/recreation_gov/models/enums.pybackend/packages/providers/providers/recreation_gov/models/api.pyRecDotGovCampsite,CampsiteAvailabilityResponse) and request query parameter models (RecDotGovCampsiteSearchParams,RecDotGovAvailabilityParams).backend/packages/providers/providers/recreation_gov/provider.pyRecreationGovProviderusing async-first HTTPX._process_single_campsiteinto modular, highly-focused helper methods (_get_available_dates,_create_campsite_dto) with type-safetyping.castbindings.backend/packages/providers/tests/test_recreation_gov.pypytest-vcr(VCRPy) without mocking the client, verifying actual API contract behavior.Test Plan
task checkandtask lintpassed with 0 errors across 51 files.task testpassed all 13 tests in 0.58 seconds.Behavior Diagram
sequenceDiagram participant W as Worker participant P as RecreationGovProvider participant API as Recreation.gov API W->>P: find_availabilities(park_id, start_date, end_date) rect rgb(30, 30, 30) Note over P: Determine months & generate Chrome User-Agent par Page Metadata P->>API: GET api/search/campsites (RecDotGovCampsiteSearchParams) API-->>P: RecDotGovCampsiteResponse and Month Availabilities loop For each Month P->>API: GET api/camps/availability/campground/{id}/month (RecDotGovAvailabilityParams) API-->>P: CampsiteAvailabilityResponse end end end Note over P: type-safe cast gather results P->>P: Decompose & match metadata (CampsiteDTO keyword args) P-->>W: list[CampsiteDTO]