Skip to content

feat: silence the non-Colab setup_colab() message on plain CLI runs - #157

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/silence-colab-cli-message
Sep 1, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/silence-colab-cli-message

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Outside Colab, _colab_setup printed a five-line "You are not running in a Google Colab environment" reassurance on every run — pure noise for CLI users, since every workspace start_here.py calls setup_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 — IPython already in sys.modules and IPython.get_ipython() returning a live shell), and demotes to logger.debug on the plain-interpreter path so the text stays retrievable. The change lands wholly in autonerves/setup_colab.py, applies uniformly to all six _PROJECTS entries, 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 the for_<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

  • Full PyAutoNerves suite: python3 -m pytest -q -n auto → 169 passed (was 155 + astropy-missing collection error in this container; astropy installed, all green)
  • Witness test TestOutsideColab::test_cli_run_is_a_silent_noop: no IPython in sys.modules → nothing installed/cloned and stdout empty
  • test_notebook_run_still_surfaces_the_message: stub IPython with a live get_ipython() shell → message still prints
  • test_imported_but_inactive_ipython_stays_silent: IPython imported but get_ipython() → None → silent
  • test_cli_message_retrievable_at_debug_level: silent path emits the text at DEBUG on autonerves.setup_colab
  • Live CLI check: python3 -c "from autonerves import setup_colab; setup_colab.for_autolens(raise_error_if_not_gpu=False)" prints nothing on stdout
Full API Changes (for automation & release notes)

Changed Behaviour

  • setup_colab.setup(project, ...) and all six setup_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 at logging.DEBUG on the autonerves.setup_colab logger 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

  • None required. To see the message on a CLI run: enable DEBUG logging for the autonerves.setup_colab logger.

Validation checklist (--auto run — plan was not pre-approved)

  • Effective level: safe (header: safe, cap: feature @ Difficulty small → safe)
  • Plan: on the issue (feat: silence non-Colab setup_colab() message on plain CLI runs #156), written at start, unmodified since
  • Gate: tests 169/169 pass on PyAutoNerves (downstream library suites n/a — no Removed/Renamed/Changed-Signature public-API entries, behaviour-only stdout change) · smoke n/a in this web-github container (no workspace checkouts; the changed surface — CLI stdout of 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 unconditional print() in the except ImportError branch, asserted by the old test_setup_is_a_noop · Heart YELLOW (score 65) within the launch ack recorded in PyAutoMind/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 PyAutoNerves
  • Independent adversary (leg 5, batch launch): run by a different model on the same diff, Witness-first — verdict CLEAN, full report in the PR conversation below
  • Human: plan sound in hindsight?
  • Human: diff matches plan (no scope creep)?
  • Human: merge, amend, or reject — then log the outcome

Generated by the PyAutoLabs agent workflow.


Generated by Claude Code

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
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 31, 2026 — with Claude

Copy link
Copy Markdown
Collaborator Author

Independent adversary verdict (autonomous-ship gate leg 5): CLEAN

Run 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:

  • CLI silent: a synthetic start_here.py calling all six for_<project> wrappers as plain python3 script.py printed nothing but its own end marker; stderr carried only the pre-existing JAX-missing warning (a different emitter, present on base).
  • Notebook surfaces it: a real notebook executed through a real kernel (nbclient) confirmed the load-bearing premise (IPython in sys.modules before user code; get_ipython() live) and emitted the full block into the notebook stream. Terminal IPython also prints; IPython merely imported with no shell stays silent.
  • Tests genuinely bind: the three silence tests fail on an origin/main checkout (3 failed / 17 passed) — a real regression guard, not decoration.

Other checks that found nothing: on-Colab path byte-identical to base under a simulated Colab runtime (stdout, XLA_FLAGS, pip/clone calls, chdir, config push); PyAutoHeart's verify_install check F installs a fake google.colab so it exercises the unchanged on-Colab branch; org-wide search shows nothing consumes the stdout string (the captured copies in workspace markdown/**/start_here.md are nbconvert kernel renders — the notebook path — so regeneration still contains it); full suite 169 passed re-run with real IPython installed; the AST no-import-side-effects guard still passes.

Non-blocking observations (not findings, no gate effect):

  1. _colab_setup retains a now-redundant function-local import sys — safe to drop in a later cleanup.
  2. The caplog test reads record.message; record.getMessage() is the stabler accessor.
  3. test_notebook_run_still_surfaces_the_message also passes on base (base always printed) — the silence tests carry the regression load.
  4. "Retrievable at DEBUG" note: autolens_workspace/config/logging.yaml filters at INFO on a stdout handler, so under shipped config the demoted record is invisible; a user raising that config to DEBUG gets the text back on stdout, as intended.

Generated by Claude Code

@Jammy2211
Jammy2211 merged commit 6fd0c97 into main Sep 1, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/silence-colab-cli-message branch September 1, 2026 19:35
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: silence non-Colab setup_colab() message on plain CLI runs

2 participants