Skip to content

chore(discovery-provider): remove dead Python files orphaned by Flask removal#14298

Merged
dylanjeffers merged 1 commit into
mainfrom
dylan/discovery-provider-dead-code
May 12, 2026
Merged

chore(discovery-provider): remove dead Python files orphaned by Flask removal#14298
dylanjeffers merged 1 commit into
mainfrom
dylan/discovery-provider-dead-code

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

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-module from .*.<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_tags

Prod + 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

Orphan test stub (1):

Outside queries (2):

  • src/tracer.py — OpenTelemetry tracer setup. Nothing called configure_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

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

Plus a second pass after deletion: rg "from .*\.<module> import|import <module>" for every deleted module name found zero remaining references in packages/discovery-provider/.

All __init__.py files in src/, 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.py is 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.py files 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 0
  • rg for orphan import references to any deleted module → no hits in packages/discovery-provider/
  • Boot the protocol stack (npm run protocol) and confirm celery beat + workers come up cleanly
  • Run the discovery-provider test suite — surviving tests should still pass

🤖 Generated with Claude Code

… 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>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: e4463e1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers dylanjeffers merged commit ce02a29 into main May 12, 2026
3 checks passed
@dylanjeffers dylanjeffers deleted the dylan/discovery-provider-dead-code branch May 12, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant