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

Đang mở
#271 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
24/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
cli, developer-experience

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).
Ngôn ngữ chính
Python
Star
0
Fork
0
Merge trung bình
11 giờ 17 phút
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rnabioco/leech

Tất cả issue của rnabioco/leech

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.