Skip to content

refactor(BA-6524): clean up the TUI installer internals#12242

Merged
seedspirit merged 17 commits into
mainfrom
refactor/installer-cleanup
Jul 3, 2026
Merged

refactor(BA-6524): clean up the TUI installer internals#12242
seedspirit merged 17 commits into
mainfrom
refactor/installer-cleanup

Conversation

@devyubin

@devyubin devyubin commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

resolves #12243 (BA-6524)

Clean up the single-host TUI installer internals: merge the duplicated DevContext/PackageContext install-info builders into a single shared helper, remove the dead python.py/pkg.py modules, and drop 59 of 60 # type: ignore comments in context.py by typing the loaded TOML documents. Along the way, fix --non-interactive --mode PACKAGE never starting the install and run_exec swallowing CancelledError (an aborted install no longer continues silently).

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

devyubin added 7 commits June 16, 2026 19:16
…ntext

DevContext and PackageContext defined byte-identical copies of
_configure_mock_accelerator. Move the single implementation onto the base
Context (replacing the abstract stub) and drop both overrides.
python.py's check_python / install_pyenv / install_python were all empty `pass`
stubs; check_python was even called from DevContext.check_prerequisites yet did
nothing. pkg.py's fetch_binaries had no callers. Remove both modules and the
dead call and import.
DevContext and PackageContext hydrate_install_info were ~95% identical and had
drifted (the source of the app-proxy-secrets gap fixed earlier). Move the shared
construction into Context._build_install_info; each context passes only its real
differences: install type, base path, local-proxy port, loopback aliases, and
the optional harbor/sftp agent fields. Also unify the storage secret generation
to token_hex (PACKAGE used token_urlsafe; functionally identical).
start_package_mode switched to the package-type submenu but never advanced it,
so `--non-interactive --mode PACKAGE` stalled with the install task never
started (unlike DEVELOP, which begins immediately). Auto-select the sole
RELEASE PACKAGE option when running non-interactively.
The tomlkit nested-write blocks carried ~60 `# type: ignore` comments (which
CLAUDE.md bans). Annotate each loaded document as `data: Any` -- the right type
for dynamic toml editing -- so mypy accepts the index/membership writes without
suppression. This loses no real checking: the ignores never type-checked those
writes anyway. One unrelated ignore remains (a rich RichCast in check_prerequisites).
A4 moved the optional harbor/sftp fields into `extra_service_kwargs: dict[str, Any]`,
which silenced mypy on both the field names AND the value types -- and the
ServiceConfig dataclass only rejects unknown keys at runtime, never wrong types.
Replace the dict with a `total=False` TypedDict so the DEVELOP dict literal and the
`**`-unpack into ServiceConfig are statically checked again (PACKAGE's `{}` stays
valid). Unlike the C2 tomlkit `Any` (a real library limitation), this Any was
self-inflicted and cheap to undo.
run_exec caught CancelledError, terminated/killed the child, then fell through to
`return exit_code` -- swallowing the cancellation, so an aborted install silently
continued to the next step. Cancellation here is always a global abort (no caller
wraps run_exec in a per-call timeout, it has no internal timeout, and reader-task
failures surface as an ExceptionGroup, not CancelledError). Reap the child for
clean shutdown, then re-raise.
@github-actions github-actions Bot added the size:L 100~500 LoC label Jun 17, 2026
@devyubin devyubin changed the title Refactor/installer cleanup refactor: clean up the TUI installer internals Jun 17, 2026
@devyubin devyubin marked this pull request as ready for review June 17, 2026 00:53
@devyubin devyubin requested a review from a team as a code owner June 17, 2026 00:53
@devyubin devyubin changed the title refactor: clean up the TUI installer internals refactor(BA-6524): clean up the TUI installer internals Jun 17, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This PR has had no activity for 14 days and has been marked as stale. It will be closed on 2026-07-16 (in 14 days) if no further activity occurs. Push a commit or leave a comment to keep it open.

@github-actions github-actions Bot added the stale label Jul 2, 2026
Comment thread src/ai/backend/install/context.py Outdated
Comment thread src/ai/backend/install/context.py Outdated
Comment thread src/ai/backend/install/context.py Outdated
@github-actions github-actions Bot removed the stale label Jul 3, 2026
devyubin and others added 3 commits July 3, 2026 13:17
…Any"

Reverts 7246d6d per review (Any-vs-type:ignore is not a meaningful change).
Also:
- re-add # type: ignore[index] on the coordinator announce_addr line that main
  introduced after that commit
- import `override` so the branch's existing @OverRide decorators resolve
  (they were missing the import -> F821 / mypy explicit-override)
Comment thread changes/12242.enhance.md Outdated
Comment thread src/ai/backend/install/context.py Outdated
devyubin added 4 commits July 3, 2026 14:24
- Trim the 12242 changelog to highlights (also drop the reverted type:ignore note)
- Use self.log_header instead of print in _configure_mock_accelerator so the
  message lands in the TUI log rather than stdout
Make HarborOptions / SftpAgentOptions frozen so the install-config options are
pure immutable values (no in-place mutation / hidden state). All usage is
read-only, so this is a one-line-per-class change with no call-site impact.
Drop the implicit defaults from HarborOptions/SftpAgentOptions so the option
schemas hold no hidden state; DevContext.hydrate_install_info now passes every
field explicitly at construction.
@seedspirit seedspirit merged commit 1aadfb7 into main Jul 3, 2026
33 checks passed
@seedspirit seedspirit deleted the refactor/installer-cleanup branch July 3, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up duplicated TUI installer context code and fix the non-interactive PACKAGE path

2 participants