-
Notifications
You must be signed in to change notification settings - Fork 225
Add template debugging tooling and surface Jupyter logs #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
72c8ba8
Add template debugging tooling and surface Jupyter logs
mishushakov c78eb9b
Fix wait_for_timeout units in build_debug (ms, not s)
mishushakov 07cc51b
Harden debug_logs against command/sandbox timeouts
mishushakov 9eebd07
Drop redundant sleep in debug_logs
mishushakov 9d8a701
Type the make_template ready parameter
mishushakov 618c4ed
Add --max-time to debug_logs health probes
mishushakov f5999fb
Route Jupyter stdout to journal only in debug builds
mishushakov 22747f2
Drop redundant systemctl daemon-reload from template build
mishushakov 179e18f
Drop changeset; debug tooling needs no template release
mishushakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import os | ||
|
|
||
| from dotenv import load_dotenv | ||
| from e2b import Template, default_build_logger, wait_for_timeout | ||
| from template import make_template | ||
|
|
||
| load_dotenv() | ||
|
|
||
| alias = os.getenv("E2B_DEBUG_TEMPLATE", "code-interpreter-debug") | ||
|
|
||
| Template.build( | ||
| make_template( | ||
| kernels=["python", "javascript"], | ||
| ready=wait_for_timeout(60_000), | ||
| debug=True, | ||
| ), | ||
| alias=alias, | ||
| cpu_count=2, | ||
| memory_mb=2048, | ||
| on_build_logs=default_build_logger(min_level="debug"), | ||
| ) | ||
|
|
||
| print(f"Built debug template: {alias}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import os | ||
|
|
||
| from dotenv import load_dotenv | ||
| from e2b import Sandbox | ||
|
|
||
| load_dotenv() | ||
|
|
||
| alias = os.getenv("E2B_DEBUG_TEMPLATE", "code-interpreter-debug") | ||
|
|
||
| sbx = Sandbox.create(template=alias, timeout=600) | ||
| print(f"sandbox: {sbx.sandbox_id}") | ||
|
|
||
| CMDS = [ | ||
| "systemctl --no-pager status jupyter || true", | ||
| "systemctl --no-pager status code-interpreter || true", | ||
| "journalctl --no-pager -u jupyter || true", | ||
| "journalctl --no-pager -u code-interpreter || true", | ||
| "curl -s --max-time 3 -o /dev/null -w 'jupyter :8888 -> %{http_code}\\n' http://localhost:8888/api/status || true", | ||
| "curl -s --max-time 3 -o /dev/null -w 'server :49999 -> %{http_code}\\n' http://localhost:49999/health || true", | ||
| ] | ||
|
|
||
| try: | ||
| for cmd in CMDS: | ||
| print(f"\n===== $ {cmd} =====") | ||
| try: | ||
| result = sbx.commands.run(f"sudo bash -lc {cmd!r}", timeout=60) | ||
| if result.stdout: | ||
| print(result.stdout) | ||
| if result.stderr: | ||
| print("[stderr]", result.stderr) | ||
| except Exception as e: | ||
| # Keep going so one slow/failed command doesn't skip the rest. | ||
| print(f"[command failed] {e}") | ||
| finally: | ||
| sbx.kill() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Debug-only drop-in: route Jupyter's stdout to the journal (the base unit | ||
| # sends it to /dev/null) so ServerApp request/error logs are visible via | ||
| # `journalctl -u jupyter`. Applied only by `make_template(debug=True)`. | ||
| [Service] | ||
| StandardOutput=journal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.