cli: shared option decorators, one `--device`/`--num-workers`/`--seed` convention, lazy startup

Abierto
#271 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
24/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python

Línea de trabajo

Start with the duplicated option blocks in src/leech/cli.py (the train and optimize commands) and the shared helpers in cli_options.py, including LazyChoice. Then check the import chain: leech/__init__.py (the subprocess import) and leech/commands/__init__.py, measured with python -X importtime -c "import leech.cli". Done means the shared decorators are used everywhere, a click-tree test enforces one help string and default per option name, and import time is under 300 ms. The design choices (device default, metric alias, seed) need maintainer input before coding.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement review-2026-09

Tier P2 · effort M · from the 2026-09-13 review (CLI F4, F5, F10, F11, F17, F18)

src/leech/cli.py is 2,029 lines, 1,185 of them inside @click.option
decorators (204 of them); 146 distinct options appear 259 times and 42 are
declared verbatim on two or more commands. --balance-groups,
--oversample-minority, --adversarial-lambda, --adversarial-anneal-epochs,
--confound, --confound-config, --cl-regression, --cl-lambda,
--signal-mode, --num-workers are pasted inline in both train
(cli.py:721-808) and optimize (:1362-1425); --checkpoint-metric (:810)
and --selection-metric (:1426) are one option under two names; prepare
and predict re-declare eight extraction options with hand-copied help that has
drifted (--cl-regression 788 vs 1410; --backend 227 vs 1921).
--device is Choice[cuda,cpu] default cuda on eight commands, type=str
default cpu on calibrate (:1141-1146), Choice[auto,cuda,cpu] default
auto on train-crf (:530-532). --num-workers means "0 = auto" on four
commands and defaults to 8 on benchmark (:974-979); prepare/predict
call it --workers. --seed is None everywhere except train-crf (0).
--min-margin is a uint8 range on predict and a float on train-crf.
--motif is required=True (cli_options.py:310-315) on train/optimize
although prepare supports --focus-tsv corpora with no motif. Startup:
import leech.cli is 484 ms, of which pkg_version("leech") at decoration
time (cli.py:69) is 137 ms and a top-level import subprocess in
leech/__init__.py:24 is 59 ms; leech.commands.__init__ eagerly imports
eight handlers and numpy (909 ms) against the lazy-import rule
leech/__init__.py:59-61 documents. LazyChoice (cli_options.py:87-91)
skips click.Choice.__init__.

Acceptance criteria
  • training_extras, confound_options, extraction_options and device_option decorators in cli_options.py; no option text is declared twice. A test iterates the click tree and asserts every option name has one help string and one default across commands (documented exceptions listed in the test).
  • --device auto|cuda|cpu with auto as the default everywhere; --num-workers everywhere with --workers kept as a hidden alias for one minor; the metric option has one name (the other kept hidden as an alias); --seed default None everywhere (or the CRF exception documented in its help).
  • --motif optional on train/optimize, warned when absent.
  • @click.version_option(package_name="leech"); subprocess imported lazily; commands/__init__.py is PEP 562 lazy; python -X importtime -c "import leech.cli" under 300 ms on this node, recorded in the PR.
  • LazyChoice calls super().__init__ or resolves names at import (the registry is torch-free).
Non-goals
  • The TrainConfig work (separate issue; do that first if both are scheduled, since it removes the three 54-name lists).
Lenguaje dominante
Python
Estrellas
0
Forks
0
Merge medio
11 h 17 min
PR fusionados (30 d)
23

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rnabioco/leech

Todos los issues de rnabioco/leech

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.