Repository navigation
feat: silence the non-Colab setup_colab() message on plain CLI runs - #157
Conversation
Outside Colab, _colab_setup printed a five-line "You are not running in a Google Colab environment" reassurance on every run. The message only earns its place in a notebook, where the user just executed a setup cell that was a no-op; on the command line it is noise on every run, forever. The non-Colab branch now prints only when an IPython interactive shell is driving the process (_running_in_ipython: IPython already in sys.modules and get_ipython() returning a live shell) and demotes to logger.debug on the plain-interpreter path, so the text stays retrievable. Applies uniformly to all six _PROJECTS entries; no workspace start_here.py bootstrap block changes. Closes #156 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kcn2SQSFmD11DncWxfNF7f
Independent adversary verdict (autonomous-ship gate leg 5): CLEANRun by a different model from the branch author, Witness-first, against real IPython 9.17.0 / ipykernel 7.3.0 — not the branch's own stubs. Nothing falsified. Witness disposition — basis-cited, both halves by live run:
Other checks that found nothing: on-Colab path byte-identical to base under a simulated Colab runtime (stdout, Non-blocking observations (not findings, no gate effect):
Generated by Claude Code |
Summary
Outside Colab,
_colab_setupprinted a five-line "You are not running in a Google Colab environment" reassurance on every run — pure noise for CLI users, since every workspacestart_here.pycallssetup_colab.for_<project>(...)unconditionally. The message only earns its place in a notebook, where the user just executed a setup cell that was a no-op and needs telling they can carry on.The non-Colab branch is now context-aware: it prints only when an IPython interactive shell is driving the process (new
_running_in_ipython()helper —IPythonalready insys.modulesandIPython.get_ipython()returning a live shell), and demotes tologger.debugon the plain-interpreter path so the text stays retrievable. The change lands wholly inautonerves/setup_colab.py, applies uniformly to all six_PROJECTSentries, and touches no workspace bootstrap block.Design choice (per the prompt's option list): only execution-context detection satisfies the Witness — a silent CLI run and a notebook path that still surfaces the message. Print-once dedup, a persisted marker, or bare log-demotion would silence the notebook path or leave first-run CLI noise; an env-var opt-out leaves the default noisy. Log-demotion is kept as the complement on the silent path.
Closes #156
API Changes
Behaviour-only:
setup_colab.setup(...)and thefor_<project>(...)wrappers no longer print the non-Colab reassurance on plain CLI runs — it still prints in notebook/IPython sessions and is logged at DEBUG otherwise. No symbols removed, added to the public surface, renamed, or re-signatured.See full details below.
Test Plan
python3 -m pytest -q -n auto→ 169 passed (was 155 + astropy-missing collection error in this container; astropy installed, all green)TestOutsideColab::test_cli_run_is_a_silent_noop: no IPython insys.modules→ nothing installed/cloned and stdout emptytest_notebook_run_still_surfaces_the_message: stub IPython with a liveget_ipython()shell → message still printstest_imported_but_inactive_ipython_stays_silent: IPython imported butget_ipython()→None→ silenttest_cli_message_retrievable_at_debug_level: silent path emits the text at DEBUG onautonerves.setup_colabpython3 -c "from autonerves import setup_colab; setup_colab.for_autolens(raise_error_if_not_gpu=False)"prints nothing on stdoutFull API Changes (for automation & release notes)
Changed Behaviour
setup_colab.setup(project, ...)and all sixsetup_colab.for_<project>(...)wrappers — outside Colab, the "You are not running in a Google Colab environment" block now prints only when an IPython interactive shell is active; on a plain interpreter it is emitted atlogging.DEBUGon theautonerves.setup_colablogger instead of stdout. Return values, signatures and the on-Colab path are unchanged (byte-identical output verified against base under a simulated Colab runtime).Added
setup_colab._running_in_ipython()— private module helper (underscore-prefixed, not public API).Migration
autonerves.setup_colablogger.Validation checklist (--auto run — plan was not pre-approved)
setup_colab— is asserted directly by the Witness test and a live CLI run; batch record expected-effects already notes "workspace smoke logs will differ") · review CLEAN — claim "on the command line it is noise on every run, forever" → basis-cited: pre-change unconditionalprint()in theexcept ImportErrorbranch, asserted by the oldtest_setup_is_a_noop· Heart YELLOW (score 65) within the launch ack recorded inPyAutoMind/batches/2026-08-31-pm.md(manifest drift: local checkout origins; CI-status measurement blindness in web container); no new reason measurable in-container intersects PyAutoNervesGenerated by the PyAutoLabs agent workflow.
Generated by Claude Code