[Feature] : API ENDPOINTS PR 4 : Samples Endpoints#1133
Open
pulk17 wants to merge 7 commits into
Open
Conversation
0b4d808 to
60e7582
Compare
d3e08e7 to
150f466
Compare
|
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.



Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Feature: Samples Endpoints (PR 4/6)
Executive Summary
Because this PR builds upon the foundation from previous PRs, GitHub currently shows the combined file changes. Once PR 3 is merged into master, this PR will automatically update to only show the Samples specific files.
This Pull Request is Part 4 of 6 in the initiative to introduce a fully-featured JSON REST API.
This PR introduces the Samples Endpoints, responsible for querying individual media samples and their historical CI tracking records, as well as exposing the active
RegressionTestcatalogue.(Note: Baseline Approval endpoints operate directly on test result data, so they have been logically grouped into the upcoming PR 5 (Results Data) for cleaner reviewing).
Architectural Additions & Enhancements
1. Samples & Regression Endpoints (
mod_api/routes/samples.py)Mounted at
/api/v1/runsand/api/v1/samples, this PR exposes the core media tracking logic:GET /runs/<run_id>/samples: Returns a paginated list of all samples processed within a specific CI run. Integrates tightly with the status determination engine built in PR 3 to compute pass/fail/missing states per file.GET /runs/<run_id>/samples/<sample_id>: Retrieves highly detailed telemetry for a single sample within a run, including exit codes, execution times, and raw standard output/error logs.GET /samples: Retrieves a comprehensive, paginated registry of all known media samples in the system.GET /samples/<sample_id>: Fetches metadata for a specific media sample file.GET /samples/<sample_id>/history: An advanced analytical endpoint that traces the execution history of a single sample across multiple historical CI runs, charting regressions and performance over time. (Includes N+1 optimizations for heavy batch-loading).GET /regression-tests: Lists all registered regression tests, supporting filters to view only active/inactive tests (?active=true) and filters by tag (?tag=...).2. Schemas & Serialization (
mod_api/schemas/samples.py)Implements robust marshmallow schemas (
SampleSchema,RegressionTestSchema,RunSampleSchema) to safely serialize complex SQLAlchemy object graphs without leaking internal database IDs or relationships where inappropriate.3. Structural Test Refactoring (
tests/base.py)Centralized repetitive token generation and database test object generation (
setup_admin_user_and_test) intoBaseTestCase, eliminating significant duplication across the test suite and speeding up future test additions.Testing & Quality Assurance
_process_history_entrieslogic, which aggregates statuses across historical runs, has been heavily verified against N+1 query regression.isort,pydocstyle,pycodestyle, andmypypass perfectly on all introduced files locally and remotely.📝 Known Caveats & Design Decisions
To address some of the review feedback, the following items were intentionally left as-is, representing conscious design tradeoffs:
list_run_samples: The endpoint lazy-loads test results instead of one massive eager join. The ~300 tests limit makes this perfectly fine.blob.exists(): We rely on the database state to determinestorage_status: 'ok'or'degraded'without an expensive synchronous network call to Google Cloud Storage.mod_auth) and Argon2 (api_token) use secure, constant-time verifications.Next Steps
Following the review and merge of this PR, PR 5 (Results Data & Baseline Approvals) will be submitted. It will expose endpoints for fetching diff lines, raw test outputs, and approving new algorithmic baselines.