chore(discovery-provider): remove dead Python files orphaned by Flask removal#14298
Merged
Conversation
… removal PR #14236 dropped the Flask REST API layer (`src/api/v1/`, `src/api_helpers.py`, `src/wsgi.py`, etc.) but left behind a long tail of modules in `src/queries/` that only the deleted blueprints called. None of these files are reached by the celery beat schedule, celery worker startup, eth/sol/core indexers, notifications/aggregates/trending tasks, or anything else still in production. ## Scope Each removed file has been verified to have **zero callers anywhere in the repo** — not in production code, not in tests, not via `__init__.py` re-exports (all relevant `__init__.py` files are empty). Removal was done via a basename sweep: ```bash for f in packages/discovery-provider/src/queries/*.py; do base=$(basename "$f" .py) refs=$(rg -l "\b$base\b" packages/discovery-provider --type py \ | grep -v "^$f$" | wc -l) [ "$refs" = "0" ] && echo "DEAD: $f" done ``` A second sweep checked `from <path>.<module> import` patterns across the whole monorepo to confirm no out-of-package callers either. ## Removed (54 files, ~3.8k lines) **`src/queries/` — query helpers with no callers (47):** download_csv, get_associated_user_id, get_associated_user_wallet, get_audio_transactions_history, get_cid_source, get_cid_type_data, get_dashboard_wallet_users, get_db_seed_restore_status, get_developer_apps, get_entities_count_check, get_events, get_feed, get_followees_for_user, get_followers_for_user, get_latest_entities, get_oldest_unarchived_play, get_playlist_repost_intersection_users, get_previously_private_playlists, get_previously_unlisted_tracks, get_purchasers, get_random_tracks, get_remix_track_parents, get_remixers, get_reposters_for_playlist, get_reposters_for_track, get_sales_aggregate, get_savers_for_playlist, get_savers_for_track, get_saves, get_sol_plays, get_stems_of, get_subscribers, get_subsequent_tracks, get_support_for_user, get_top_followee_saves, get_top_followee_windowed, get_track_access_info, get_track_inspect_info, get_track_repost_intersection_users, get_track_signature, get_tracks_including_unlisted, get_unclaimed_id, get_user_history, get_user_tracks_remixed, get_user_with_wallet, search_track_tags, search_user_tags **`src/queries/` — production + unit test pairs that only test each other (4):** get_block_confirmation.py + get_block_confirmation_unit_test.py get_latest_play.py + get_latest_play_unit_test.py **`src/queries/` — orphan test stub (1):** get_route_metrics_unit_test.py (its target `get_route_metrics.py` was deleted with PR #14236; the file is a one-line docstring stub pointing at `/integration_tests/test_get_route_metrics.py` which also doesn't exist) **Outside queries (2):** - `src/tracer.py` — OpenTelemetry tracer setup. Defined `configure_tracer()` but nothing called it after the Flask-app removal; the indexing-only worker uses Sentry directly. - `src/utils/track_event_constants.py` — a four-key dict (`track_event_types_lookup`) that nothing imports. ## Out of scope for this PR (deferred) Several query files still have callers — but only from tests. They exist to verify indexer behavior (e.g. `get_notifications.py` is the read-side for ~17 notification tests that run the indexer and assert what it wrote). Removing them would mean rewriting those tests to hit the DB directly, which is a separate refactor and a judgment call about test coverage. Examples: `get_notifications`, `get_challenges`, `get_attestation`, `get_collection_library`, `get_app_name_metrics`, plus the `*_unit_test.py` files paired with prod modules that are still test-only. ## Verification - `python3 -m compileall -q packages/discovery-provider/src packages/discovery-provider/integration_tests` → exit 0 - A second `rg` pass against every deleted module name found no remaining `from .*.<module> import` or `import <module>` references anywhere in `packages/discovery-provider/`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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
Cleans up 54 Python files (~3.8k lines) in
packages/discovery-provider/that were orphaned when PR #14236 removed the Flask REST API layer. Every deleted file has zero callers anywhere in the repo — verified by a basename grep sweep plus per-modulefrom .*.<module> import/import <module>scans.Removed
src/queries/— query helpers with no callers (47):download_csv,get_associated_user_id,get_associated_user_wallet,get_audio_transactions_history,get_cid_source,get_cid_type_data,get_dashboard_wallet_users,get_db_seed_restore_status,get_developer_apps,get_entities_count_check,get_events,get_feed,get_followees_for_user,get_followers_for_user,get_latest_entities,get_oldest_unarchived_play,get_playlist_repost_intersection_users,get_previously_private_playlists,get_previously_unlisted_tracks,get_purchasers,get_random_tracks,get_remix_track_parents,get_remixers,get_reposters_for_playlist,get_reposters_for_track,get_sales_aggregate,get_savers_for_playlist,get_savers_for_track,get_saves,get_sol_plays,get_stems_of,get_subscribers,get_subsequent_tracks,get_support_for_user,get_top_followee_saves,get_top_followee_windowed,get_track_access_info,get_track_inspect_info,get_track_repost_intersection_users,get_track_signature,get_tracks_including_unlisted,get_unclaimed_id,get_user_history,get_user_tracks_remixed,get_user_with_wallet,search_track_tags,search_user_tagsProd + unit-test pairs that only test each other (4):
get_block_confirmation.py+get_block_confirmation_unit_test.pyget_latest_play.py+get_latest_play_unit_test.pyOrphan test stub (1):
get_route_metrics_unit_test.py— its targetget_route_metrics.pywas deleted with Remove discovery-provider API code, keep indexing #14236; the file is a one-line docstring pointing to a sibling integration test that also doesn't exist.Outside queries (2):
src/tracer.py— OpenTelemetry tracer setup. Nothing calledconfigure_tracer()after the Flask-app removal; the indexing worker uses Sentry directly.src/utils/track_event_constants.py— a four-key dict (track_event_types_lookup) that nothing imports.How dead-ness was verified
Plus a second pass after deletion:
rg "from .*\.<module> import|import <module>"for every deleted module name found zero remaining references inpackages/discovery-provider/.All
__init__.pyfiles insrc/,src/queries/,src/utils/are empty — no re-exports to clean up.What was intentionally NOT touched
Indexing code (everything under
src/tasks/,src/eth_indexing/,src/solana/,src/challenges/, the celery beat schedule) — none of it was flagged dead and none is removed.Out of scope (deferred to a follow-up audit)
Several query files have callers, but only from tests that exercise indexer behavior — e.g.
get_notifications.pyis read by ~17 notification tests that run the indexer and assert what it wrote. Removing those would mean rewriting tests to hit the DB directly, which is a separate refactor. Examples in this bucket:get_notifications,get_challenges,get_attestation,get_collection_library,get_app_name_metrics, plus several*_unit_test.pyfiles paired with prod modules that are themselves test-only.Test plan
python3 -m compileall -q packages/discovery-provider/src packages/discovery-provider/integration_tests→ exit 0rgfor orphan import references to any deleted module → no hits inpackages/discovery-provider/npm run protocol) and confirm celery beat + workers come up cleanly🤖 Generated with Claude Code