feat(export): connect job export service to api and cli#6
Merged
Conversation
jaeyeopme
force-pushed
the
export-api-cli
branch
2 times, most recently
from
June 6, 2026 16:21
f3eb02b to
3ff0173
Compare
Add the reusable job export orchestration path and wire it through FastAPI and Typer. Persist validated export run records before returning the final summary, so count validation lives at the workflow boundary. Tested: uv run pytest tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py -v Tested: uv run ruff check src/clean_data_export_api/models.py src/clean_data_export_api/repository.py src/clean_data_export_api/export_service.py src/clean_data_export_api/app.py src/clean_data_export_api/cli.py tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py Tested: uv run basedpyright Tested: uv run pytest -v Tested: uv run pytest tests/test_export_service.py tests/test_app.py tests/test_cli.py --cov=clean_data_export_api --cov-report=term-missing Tested: uv run pytest --cov=clean_data_export_api --cov-report=term-missing --cov-fail-under=90 Tested: uv run python -m compileall src tests Tested: uv run clean-data-export-api export jobs --from-date 2026-06-01 --to-date 2026-06-05 --output-dir <tmp>/outputs --database-path <tmp>/history.sqlite3 --page-size 4 Tested: git diff --check
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.
Motivation
The project now has source records, rules, output writers, and run history. This PR connects those pieces through one reusable export service and exposes the same workflow through API and CLI entry points.
Scope
run_job_exportorchestration for the local job export workflow.ExportRunRecordso persisted run counts are validated before SQLite insert.RunRepositoryto accept a validated run record instead of loose count arguments.POST /exports/jobsthrough FastAPI.clean-data-export-api export jobsandclean-data-export-api servecommands.Out of Scope
Modifications
export_service.pyto fetch paginated source jobs, fetch related updates, map, validate, remove duplicates, write reports, persist run history, and return an export summary.app.pywith a thin FastAPI endpoint that calls the export service.cli.pywith export and serve commands while keeping business rules outside the CLI layer.ExportRunRecordand updated repository persistence to store validated run data.Test Plan
uv run pytest tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.py -vuv run ruff check src/clean_data_export_api/models.py src/clean_data_export_api/repository.py src/clean_data_export_api/export_service.py src/clean_data_export_api/app.py src/clean_data_export_api/cli.py tests/test_models.py tests/test_repository.py tests/test_export_service.py tests/test_app.py tests/test_cli.pyuv run basedpyrightuv run pytest -vuv run pytest tests/test_export_service.py tests/test_app.py tests/test_cli.py --cov=clean_data_export_api --cov-report=term-missinguv run pytest --cov=clean_data_export_api --cov-report=term-missing --cov-fail-under=90uv run python -m compileall src testsuv run clean-data-export-api export jobs --from-date 2026-06-01 --to-date 2026-06-05 --output-dir <tmp>/outputs --database-path <tmp>/history.sqlite3 --page-size 4git diff --checkDocs Impact
none
ADR Check
Result
The same deterministic job export workflow now runs through the reusable service, FastAPI endpoint, and CLI command.