oliver-zehentleitner / maity

clean-up: G6 tools and scripts: hub/scripts: retire finished one-time scripts, one local-hub helper for the measure and smoke scripts

Sign in to report

tsk-bmw51x6qrq7p Open

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G6: CLI leftovers, public-page leftovers, tools and scripts), read at 9dfd4b65.

The two broken measure scripts are on their own bug card (filed at the same time: measure_board.py and measure_wait.py use the pre-namespace paths). This card is the rest of hub/scripts.

1. namespace_codemod.py is finished, and re-running it is no longer safe (dead code, docs drift)

  • Files: hub/scripts/namespace_codemod.py (105 lines, no caller: not in a Makefile, CI or a test); hub/context/namespace.md:21-25 ("It is idempotent, and a rebase runs it again instead of merging the literals").
  • What is wrong: the namespace (§6.25) landed long ago, and the script's test rewrite now damages the tree: TEST_PATH (:41) matches the slug list other, so hub/tests/test_route_limits.py:93 /api/v1/projects/other/thing/events (owner other) would become /projects/maintainer/other/thing/events. The context entry still tells a reader to run it.
  • Proposal: delete the script; add a dated line to the namespace.md entry that the codemod did its job and was removed (the CHANGELOG keeps its history).
  • Effort: S. Risk: none.

2. backfill_public_merges.py is a one-time script with its own test (dead code, decision needed)

  • Files: hub/scripts/backfill_public_merges.py (137 lines, "One-time", :1); hub/tests/test_backfill_public_merges.py; hub/context/probe.md:393-399.
  • Proposal: if it has run on the instance it was written for, delete script and test and add a dated line to the probe.md entry. If it has not run yet, leave it.
  • Effort: S. Risk: none.

3. Starting a local hub, an owner and a login is written four times; percentiles three times; two TCP proxies (duplication)

  • Files:
  • Hub process, owner, login, health wait: measure_wait.py:44-76 (Human, wait_for_health) and :121-139; measure_arenas.py:38-40 imports them from measure_wait.py (one script importing another through sys.path) and repeats the owner command at :63-80; smoke_join_windows.py:71-85 (Smoke.human, login), :207-214 (wait_for_hub), :226-240; check_dist.py:115-118 (free_port) and :151-163 (its own wait loop).
  • p95 by hand: measure_board.py:227, measure_wait.py:190, measure_arenas.py:139-140.
  • Proxies: measure_board.py:173-208 (delay_proxy, delays each chunk) and measure_wait.py:79-109 (CuttingProxy, cuts after a time), both an asyncio loop on a daemon thread with the same pipe code.
  • Proposal: hub/scripts/local_hub.py with start(env) -> process, owner(env), Human (call, login), wait_for_health, percentile, and one proxy with delay and cut_after options; the five scripts import it. smoke_join.sh stays shell.
  • Effort: M. Risk: low; check_dist.py runs in CI (hub-dist), so it proves its part; the measure scripts get a run each by hand.

4. Two scripts import the test package (design)

  • Files: measure_board.py:36 and :47, measure_notifications.py:25 and :33 (sys.path.insert(... parents[1]), then from tests import factory).
  • What is wrong: a script under hub/scripts depends on hub/tests, which the wheel and sdist do not carry, and a change to the test factory can break the scripts without a test noticing (see the sibling bug card).
  • Proposal: either move the two measure scripts under hub/tests (for example tests/perf/, not collected by default) or say in their docstrings that they need a checkout with tests. The cheap guard from the bug card (a tiny run in a test) covers the drift either way.
  • Effort: S. Risk: none.

Order

After the bug card for measure_board.py/measure_wait.py, or in the same PR as item 3.

Open question

Item 2: has backfill_public_merges.py run on maity.team (req-ds8mk5vdtkxx)? If yes, delete it.

Covered elsewhere

None. Searched: namespace_codemod, backfill_public_merges, measure_board, measure_wait. Reviewed and left: smoke_join_windows.py:53-60 stubs the resource module because avatar_decode.py:34 imports it at the top; that is the decoder's sandbox and not worth moving for a smoke test.

Effort: M + 3S.