Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Stream exporter logs in jmp shell#567

Merged
mangelajo merged 1 commit intomainfrom
exporter-logs-flag
Jul 15, 2025
Merged

Stream exporter logs in jmp shell#567
mangelajo merged 1 commit intomainfrom
exporter-logs-flag

Conversation

@mangelajo
Copy link
Copy Markdown
Member

@mangelajo mangelajo commented Jul 15, 2025

It's not enabled by default, now it requires the --exporter-logs flag, otherwise it becomes too annoying, for example when doing a serial console session or other activities.

Fixes-Issue: #554

Summary by CodeRabbit

  • New Features

    • Added a new command-line option to stream exporter logs during shell sessions.
  • Bug Fixes

    • Improved handling of log streaming to ensure compatibility with synchronous and asynchronous operations.

It's not enabled by default, now it requires the --exporter-logs flag,
otherwise it becomes too annoying, for example when doing a serial
console session or other activities.
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 15, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 97fd597
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/68763ddaed9fe80008255ec7
😎 Deploy Preview https://deploy-preview-567--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 15, 2025

Walkthrough

The changes remove an asynchronous log streaming context from the CLI execution and introduce a new --exporter-logs option to the shell command. When enabled, this option streams exporter logs during the shell session by conditionally wrapping the shell launch in a log stream context.

Changes

File(s) Change Summary
.../jumpstarter_cli/j.py Removed async log streaming context from around CLI invocation.
.../jumpstarter_cli/shell.py Added --exporter-logs option; updated function signature and logic to conditionally stream logs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Shell
    participant LeaseClient
    participant LogStream

    User->>CLI: Run `shell` command (with/without --exporter-logs)
    CLI->>Shell: Call shell(config, ..., exporter_logs)
    alt exporter_logs enabled
        Shell->>LeaseClient: Connect
        LeaseClient->>LogStream: Open log stream
        LogStream->>Shell: Stream logs
        Shell->>Shell: Launch shell session
        LogStream-->>LeaseClient: Close log stream
    else exporter_logs disabled
        Shell->>Shell: Launch shell session directly
    end
Loading

Possibly related PRs

Suggested reviewers

  • NickCao

Poem

A shell with logs, oh what a sight,
Exporter streams now shining bright.
With options new and code made neat,
The CLI’s journey is more complete.
🐇✨
Logs may flow, or stay at bay—
Jumpstarter hops a smoother way!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mangelajo mangelajo requested a review from bennyz July 15, 2025 11:39
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)

26-26: Add type annotation for the new parameter.

The function signature should include a type annotation for the exporter_logs parameter for better code clarity and IDE support.

-def shell(config, command: tuple[str, ...], lease_name, selector, duration, exporter_logs):
+def shell(config, command: tuple[str, ...], lease_name, selector, duration, exporter_logs: bool):
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5006a4d and 97fd597.

📒 Files selected for processing (2)
  • packages/jumpstarter-cli/jumpstarter_cli/j.py (1 hunks)
  • packages/jumpstarter-cli/jumpstarter_cli/shell.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (4)
packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.py (1)
  • handle_exceptions_with_reauthentication (49-72)
packages/jumpstarter-cli/jumpstarter_cli/login.py (1)
  • relogin_client (141-155)
packages/jumpstarter/jumpstarter/config/client.py (1)
  • lease (118-126)
packages/jumpstarter/jumpstarter/common/utils.py (1)
  • launch_shell (49-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: pytest-matrix (macos-15, 3.12)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.12)
  • GitHub Check: pytest-matrix (macos-15, 3.11)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.13)
  • GitHub Check: pytest-matrix (macos-15, 3.13)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
  • GitHub Check: e2e
🔇 Additional comments (2)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)

23-23: LGTM: Well-documented CLI option added.

The --exporter-logs flag is properly implemented with appropriate help text.

packages/jumpstarter-cli/jumpstarter_cli/j.py (1)

22-22: LGTM: Clean removal of unconditional log streaming.

The removal of the log_stream_async context manager aligns perfectly with the PR objective of making log streaming conditional rather than always-on. This change, combined with the conditional implementation in shell.py, provides better user control over log output.

Comment on lines +46 to +63
if exporter_logs:
with lease.connect() as client:
with client.log_stream():
exit_code = launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
command=command,
)
else:
exit_code = launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
command=command,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor to eliminate code duplication.

The conditional logic contains significant code duplication. The launch_shell call is identical in both branches, only the context differs.

-                        if exporter_logs:
-                            with lease.connect() as client:
-                                with client.log_stream():
-                                    exit_code = launch_shell(
-                                        path,
-                                        "remote",
-                                        config.drivers.allow,
-                                        config.drivers.unsafe,
-                                        command=command,
-                                    )
-                        else:
-                            exit_code = launch_shell(
-                                path,
-                                "remote",
-                                config.drivers.allow,
-                                config.drivers.unsafe,
-                                command=command,
-                            )
+                        def run_shell():
+                            return launch_shell(
+                                path,
+                                "remote",
+                                config.drivers.allow,
+                                config.drivers.unsafe,
+                                command=command,
+                            )
+                        
+                        if exporter_logs:
+                            with lease.connect() as client:
+                                with client.log_stream():
+                                    exit_code = run_shell()
+                        else:
+                            exit_code = run_shell()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if exporter_logs:
with lease.connect() as client:
with client.log_stream():
exit_code = launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
command=command,
)
else:
exit_code = launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
command=command,
)
def run_shell():
return launch_shell(
path,
"remote",
config.drivers.allow,
config.drivers.unsafe,
command=command,
)
if exporter_logs:
with lease.connect() as client:
with client.log_stream():
exit_code = run_shell()
else:
exit_code = run_shell()
🤖 Prompt for AI Agents
In packages/jumpstarter-cli/jumpstarter_cli/shell.py between lines 46 and 63,
the launch_shell function is called with the same arguments in both branches of
the if-else, causing code duplication. Refactor by moving the launch_shell call
outside the if-else block and only conditionally wrap it with the
lease.connect() and client.log_stream() context managers when exporter_logs is
true, to eliminate the duplicated launch_shell call.

@mangelajo mangelajo enabled auto-merge July 15, 2025 11:45
@mangelajo mangelajo merged commit ec9b9b7 into main Jul 15, 2025
18 checks passed
@mangelajo mangelajo deleted the exporter-logs-flag branch July 15, 2025 11:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants