Skip to content

Fix Colab notebook setup warnings#14

Merged
bernalde merged 3 commits into
mainfrom
fix/issue-13-colab-notebook-warnings
May 17, 2026
Merged

Fix Colab notebook setup warnings#14
bernalde merged 3 commits into
mainfrom
fix/issue-13-colab-notebook-warnings

Conversation

@bernalde

Copy link
Copy Markdown
Member

Summary

  • Resolve Julia notebook projects in Colab when the checked-in manifest targets a different Julia runtime, so the bootstrap behavior matches the existing warning text.
  • Call Julia notebook bootstrap via Base.invokelatest to avoid Julia 1.12 world-age warnings after including the bootstrap module.
  • Make the QCI Colab setup install the eqc-models-compatible NumPy/NetworkX stack before imports, then restart the Colab runtime once so NumPy is reloaded cleanly.
  • Add regression coverage for the Julia bootstrap policy, Julia notebook setup cells, and QCI Colab setup source.

Tests run

  • python -m unittest tests.test_verify_notebooks tests.test_notebook3_pair_sync - passed, 43 tests.
  • python -m unittest discover -s tests - passed, 64 tests.
  • UV_CACHE_DIR=.uv-cache uv run --group docs python -m unittest discover -s tests - passed, 64 tests.
  • python ./scripts/verify_colab_runtime_smokes.py --skip-julia - passed; printed dwave.samplers Colab smoke ok and QCI Colab setup policy ok.
  • julia --project=./scripts -e 'include("./scripts/notebook_bootstrap.jl"); using .QuIPNotebookBootstrap; println(QuIPNotebookBootstrap.should_resolve_project_for_current_julia("notebooks_jl/envs/2-QUBO"; in_colab=true))' - passed, printed true.
  • make verify-julia-colab-mismatch-smoke - passed under Julia 1.12.6.
  • COLAB_RELEASE_TAG=local-test JULIA_DEPOT_PATH=/tmp/quip-issue13-julia-depot /home/bernalde/.julia/juliaup/julia-1.12.6+0.x64.linux.gnu/bin/julia --project=./scripts -e 'include("./scripts/notebook_bootstrap.jl"); using .QuIPNotebookBootstrap; QuIPNotebookBootstrap.instantiate_project!(ARGS[1]; precompile=false)' /tmp/quip-issue13-resolve-smoke - passed, logged Resolving Julia packages for current runtime Julia 1.12.6.
  • git diff --check - passed.

Notes about tests not run

  • UV_CACHE_DIR=.uv-cache uv run --group docs jupyter book build --html --ci could not run locally because MyST reported npm as Package Not Found while requiring npm >=8.6.0.

Closes #13

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@bernalde bernalde left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff, surrounding bootstrap/test code, and documented test commands. I found no blocking issues.

Comment thread notebooks_py/6-QCi_python.ipynb Outdated
" except (metadata.PackageNotFoundError, ValueError):\n",
" return None\n",
"\n",
"QCI_RUNTIME_READY = Path(\"/content/.quip_qci_runtime_ready\") if IN_COLAB else None\n",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonblocking: QCI_RUNTIME_READY is created and later touched, but nothing reads it when deciding whether to install or restart. That makes the marker look like an unfinished restart guard and adds a little maintenance ambiguity. Consider removing the marker, or wiring it into the condition if it is intended to suppress repeated restarts after a successful install.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bfbe336. I removed the unused QCI_RUNTIME_READY marker and the now-unused Path import, then updated the smoke/source test coverage to assert the marker stays absent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in bfbe336. No further change was needed in this pass; the marker remains removed and this thread is now outdated.

@bernalde

Copy link
Copy Markdown
Member Author

Pushed commit: bfbe336 Remove unused QCI Colab marker

Main changes made:

  • Removed the unused QCI_RUNTIME_READY marker from the QCI Colab setup cell.
  • Removed the now-unused Path import.
  • Updated the Colab runtime smoke and source regression test to assert the marker is not present.

Tests run and results:

  • jq empty notebooks_py/6-QCi_python.ipynb - passed.
  • python -m unittest tests.test_verify_notebooks - passed, 20 tests.
  • python -m py_compile scripts/verify_colab_runtime_smokes.py - passed.
  • UV_CACHE_DIR=.uv-cache uv run --group docs python -m unittest discover -s tests - passed, 64 tests.
  • python ./scripts/verify_colab_runtime_smokes.py --skip-julia - passed.
  • git diff --check - passed.

Comments intentionally not addressed:

  • The ReviewNB top-level bot comment is informational and does not require a code change.

Remaining risks or follow-up items:

  • UV_CACHE_DIR=.uv-cache uv run --group docs jupyter book build --html --ci still cannot run in this local environment because MyST reports npm as Package Not Found while requiring npm >=8.6.0.

@bernalde bernalde left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking issue: the new Julia Colab resolve behavior is not covered by an executable test. The current CI and local tests pass, but the regression coverage only checks for source snippets rather than exercising instantiate_project! under a manifest/runtime mismatch. I would not merge this until the blocking issue is addressed.

Tests run:

  • UV_CACHE_DIR=.uv-cache uv run --group docs python -m unittest discover -s tests - passed, 64 tests.
  • make verify-julia-colab-mismatch-smoke - passed under Julia 1.12.6.
  • python ./scripts/verify_colab_runtime_smokes.py --skip-julia - passed; printed dwave.samplers Colab smoke ok and QCI Colab setup policy ok.
  • git diff --check origin/main...HEAD - passed.

CI status from gh pr checks 14: build passed, julia-notebook-smokes passed, deploy skipped for pull_request.

self.assertIn("Colab will allow Pkg to re-resolve the notebook environment", source)
self.assertIn("should_resolve_project_for_current_julia", source)
self.assertIn("Resolving Julia packages for current runtime Julia", source)
self.assertIn("Pkg.resolve()", source)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: This test only asserts that the bootstrap source contains Pkg.resolve(). It would still pass if instantiate_project! stopped calling it, called it before project activation, or gated it on the wrong runtime condition. Since the Julia fix depends on actually re-resolving stale manifests in Colab, please add an executable smoke test, for example in verify_colab_runtime_smokes.py, that creates a temporary project with an old julia_version, runs instantiate_project! with Colab detection enabled, and verifies the manifest is resolved for the current Julia version or that the resolve step ran.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 924c5eb. Added an executable Julia Colab resolve smoke in scripts/verify_colab_runtime_smokes.py; make verify-julia-colab-mismatch-smoke now creates a stale temp project, runs instantiate_project!, and checks the manifest version matches VERSION.

@bernalde

Copy link
Copy Markdown
Member Author

Commits pushed:

Main changes made:

  • Added an executable Julia Colab resolve smoke in scripts/verify_colab_runtime_smokes.py. It creates a temporary stale Julia project, runs instantiate_project! with Colab detection enabled, and verifies the manifest version matches the active Julia runtime.
  • Kept the isolated smoke writable in this local sandbox by placing a temporary depot first in JULIA_DEPOT_PATH while preserving existing depots for registry reuse.
  • Updated tests/test_verify_notebooks.py to cover the new smoke script path.

Tests run and results:

  • python -m unittest tests.test_verify_notebooks - passed, 20 tests.
  • python -m py_compile scripts/verify_colab_runtime_smokes.py - passed.
  • make verify-julia-colab-mismatch-smoke - passed under Julia 1.12.6; output included Julia Colab resolve smoke ok.
  • UV_CACHE_DIR=.uv-cache uv run --group docs python -m unittest discover -s tests - passed, 64 tests.
  • git diff --check - passed.
  • git diff --cached --check - passed before commit.

Comments intentionally not addressed:

  • The ReviewNB top-level bot comment is informational and does not require a code change.
  • The outdated QCI_RUNTIME_READY inline thread was already addressed by bfbe336; no further code change was needed.

Remaining risks or follow-up items:

  • UV_CACHE_DIR=.uv-cache uv run --group docs jupyter book build --html --ci still cannot run in this local environment because MyST reports npm as Package Not Found and requires npm >=8.6.0.

@bernalde bernalde left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found in this pass. I would approve this PR, but GitHub does not allow me to approve a PR authored by this account, so I am submitting this as a comment review.

Review summary:

  1. Blocking issues: none.
  2. Nonblocking issues: none.
  3. Questions: none.
  4. Tests run:
    • python -m unittest tests.test_verify_notebooks tests.test_notebook3_pair_sync - passed, 43 tests.
    • python -m py_compile scripts/verify_colab_runtime_smokes.py - passed.
    • jq empty notebooks_py/6-QCi_python.ipynb notebooks_jl/1-MathProg.ipynb notebooks_jl/2-QUBO.ipynb notebooks_jl/3-GAMA.ipynb notebooks_jl/4-DWave.ipynb notebooks_jl/5-Benchmarking.ipynb - passed.
    • make verify-julia-colab-mismatch-smoke - passed under Julia 1.12.6, including the resolve smoke.
    • UV_CACHE_DIR=.uv-cache uv run --group docs python -m unittest discover -s tests - passed, 64 tests.
    • make verify-colab-python-runtime-smoke - initial sandbox run failed on DNS while downloading PyPI packages; rerun with network access passed and printed dwave.samplers Colab smoke ok and QCI Colab setup policy ok.
    • git diff --check origin/main...HEAD - passed.
    • UV_CACHE_DIR=.uv-cache uv run --group docs jupyter book build --html --ci - not runnable locally because MyST reports npm as Package Not Found and requires npm >=8.6.0; the PR build CI job ran this successfully.
    • gh pr checks 14 - build passed, julia-notebook-smokes passed, deploy skipped for pull_request.
  5. Merge recommendation: merge as-is.

@bernalde

Copy link
Copy Markdown
Member Author

Notebook rerun update:

  • I reran the documented Julia notebook validation path because this PR edits the Julia notebook bootstrap cells.
  • make verify-julia-colab passed locally.
    • Executed notebooks_jl/1-MathProg.ipynb into .nbverify/1-MathProg.ipynb.
    • Executed notebooks_jl/2-QUBO.ipynb into .nbverify/2-QUBO.ipynb.
    • Ran Julia import/bootstrap smokes for 3-GAMA, 4-DWave, and 5-Benchmarking.
    • Ran the Notebook 5 cache smoke.
  • I did not commit .nbverify/ outputs because .gitignore intentionally excludes .nbverify/; the repository’s documented verifier writes rerun copies there instead of mutating source notebooks.
  • I did not rerun the full QCI notebook in place because it contains live QCI cloud solver calls and requires a valid QCI API token. The PR’s QCI setup behavior is covered by make verify-colab-python-runtime-smoke, which passed earlier with dwave.samplers Colab smoke ok and QCI Colab setup policy ok.

No additional commit was needed.

@bernalde bernalde merged commit 9506c98 into main May 17, 2026
3 checks passed
@bernalde bernalde deleted the fix/issue-13-colab-notebook-warnings branch May 17, 2026 02:16
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.

Gathering colab warnings and error to be fixed

1 participant