Skip to content

Conversation

@NiveditJain
Copy link
Member

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a sample script demonstrating how to create and run a custom node using the SDK.
    • Expanded documentation with detailed usage instructions and support contact information.
  • Improvements

    • Updated the node execution interface to accept and return dictionaries, improving flexibility.
    • Enhanced the runtime to require an API key and improved error handling and logging.
    • Adjusted runtime configuration for more responsive operation.
  • Other Changes

    • Updated version to 0.0.4b.

Walkthrough

The changes update the ExosphereHost Python SDK with expanded usage documentation, restructured public API exports, and a sample usage script. The Runtime and BaseNode APIs are refactored for improved authentication, error handling, and control flow. The package versioning approach is updated, and a sample node implementation is provided.

Changes

Cohort / File(s) Change Summary
Documentation Updates
python-sdk/README.md
Expanded the README with detailed usage instructions, a new "Node Creation" section with sample code, and a "Support" section with contact information.
Public API Restructuring
python-sdk/exospherehost/__init__.py, python-sdk/exospherehost/_version.py, python-sdk/exospherehost/node/__init__.py
Updated public exports: now explicitly exposes Runtime, BaseNode, and VERSION (aliased from version). Imports and aliasing adjusted for version variable. Removed the test() function and import of BaseNode from node's __init__.py. Version variable renamed and incremented.
Node API Refactor
python-sdk/exospherehost/node/BaseNode.py
Changed the BaseNode class's execute method signature to accept an inputs dictionary and return a dictionary. Updated imports accordingly.
Runtime Refactor & API Key Support
python-sdk/exospherehost/runtime.py
Refactored the Runtime class: added required key parameter, changed polling and version defaults, made connect and start synchronous, added API key authentication to HTTP requests, improved error handling, adjusted polling to continuous, fixed state ID key usage, and ensured proper queue task completion. Split start into internal async and external sync methods.
Sample Script Addition
python-sdk/sample.py
Added a sample script defining a SampleNode class, demonstrating runtime initialization, connection, and execution using environment variables for configuration.
Build Configuration Update
python-sdk/pyproject.toml
Changed the dynamic version attribute for setuptools to reference the new version variable location.

Sequence Diagram(s)

sequenceDiagram
    participant UserScript
    participant Runtime
    participant BaseNode
    participant StateManager

    UserScript->>Runtime: Initialize (namespace, state_manager_uri, key, ...)
    UserScript->>Runtime: connect([BaseNode])
    UserScript->>Runtime: start()
    loop Polling
        Runtime->>StateManager: POST /enqueue (with x-api-key)
        StateManager-->>Runtime: Response (state batch)
        Runtime->>BaseNode: execute(inputs)
        BaseNode-->>Runtime: result dict
        Runtime->>StateManager: POST /notify_executed (with x-api-key)
        alt On error
            Runtime->>StateManager: POST /notify_errored (with x-api-key)
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

In the warren of code, a new path unfurled,
Nodes now take inputs, their logic unfurled.
With keys in our paws, we hop through the gate,
Polling more swiftly, no longer we wait.
A sample to guide you, support at your side—
In the Exosphere garden, let your rabbits reside! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 927bb06 and ebb34ec.

📒 Files selected for processing (3)
  • python-sdk/README.md (1 hunks)
  • python-sdk/exospherehost/runtime.py (3 hunks)
  • python-sdk/sample.py (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
python-sdk/README.md

4-4: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


5-5: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)


23-23: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


24-24: Files should end with a single newline character

(MD047, single-trailing-newline)

🔇 Additional comments (3)
python-sdk/exospherehost/runtime.py (3)

46-58: Good implementation of API key authentication and error logging.

The method properly includes the API key header and logs errors without disrupting the flow, which is appropriate for a polling mechanism.


84-94: API key authentication properly implemented.

The method follows the same pattern as other API calls with proper authentication and error logging.


108-119: Proper queue management with task_done().

Good addition of task_done() call which is essential for proper queue synchronization. The change from "id" to "state_id" aligns with the state manager API.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 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 generate unit tests to generate unit tests for 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.

Copy link
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: 8

🔭 Outside diff range comments (1)
python-sdk/exospherehost/runtime.py (1)

96-107: Ensure task_done() is always called.

The task_done() call should be in a finally block to ensure it's called even if an unexpected exception occurs. This prevents the queue from getting stuck.

 async def _worker(self):
     while True:
         state = await self._state_queue.get()
-
         try:
-            node = self._node_mapping[state["node_name"]]
-            outputs = await node.execute(state["inputs"]) # type: ignore
-            await self._notify_executed(state["state_id"], outputs)
-        except Exception as e:
-            await self._notify_errored(state["state_id"], str(e))
-
-        self._state_queue.task_done() # type: ignore
+            try:
+                node = self._node_mapping[state["node_name"]]
+                outputs = await node.execute(state["inputs"]) # type: ignore
+                await self._notify_executed(state["state_id"], outputs)
+            except Exception as e:
+                await self._notify_errored(state["state_id"], str(e))
+        finally:
+            self._state_queue.task_done() # type: ignore
♻️ Duplicate comments (1)
python-sdk/exospherehost/runtime.py (1)

75-82: Apply consistent error handling.

Similar to _notify_executed, this method should handle non-200 responses.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e976328 and aa06bb3.

📒 Files selected for processing (8)
  • python-sdk/README.md (1 hunks)
  • python-sdk/exospherehost/__init__.py (1 hunks)
  • python-sdk/exospherehost/_version.py (1 hunks)
  • python-sdk/exospherehost/node/BaseNode.py (2 hunks)
  • python-sdk/exospherehost/node/__init__.py (0 hunks)
  • python-sdk/exospherehost/runtime.py (3 hunks)
  • python-sdk/pyproject.toml (1 hunks)
  • python-sdk/sample.py (1 hunks)
💤 Files with no reviewable changes (1)
  • python-sdk/exospherehost/node/init.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
python-sdk/exospherehost/node/BaseNode.py (1)
python-sdk/sample.py (1)
  • execute (5-7)
python-sdk/exospherehost/runtime.py (1)
python-sdk/exospherehost/node/BaseNode.py (2)
  • BaseNode (5-17)
  • get_unique_name (14-17)
🪛 LanguageTool
python-sdk/README.md

[grammar] ~2-~2: Use articles correctly
Context: # ExosphereHost Python SDK This SDK is official python SDK for ExosphereHost and intera...

(QB_NEW_EN_OTHER_ERROR_IDS_11)


[grammar] ~2-~2: Use proper capitalization
Context: ... for ExosphereHost and interacting with exospherehost. ## Node Creation You can simply connec...

(QB_NEW_EN_OTHER_ERROR_IDS_6)


[grammar] ~5-~5: Use articles correctly
Context: ...Node Creation You can simply connect to exosphere state manager and start creating your n...

(QB_NEW_EN_OTHER_ERROR_IDS_11)


[grammar] ~5-~5: There might be a problem here.
Context: ... start creating your nodes, as shown in sample below: python from exospherehost import Runtime, BaseNode import os class SampleNode(BaseNode): async def execute(self, inputs): print(inputs) return {"message": "success"} runtime = Runtime("SampleNamespace", os.getenv("EXOSPHERE_STATE_MANAGER_URI", "http://localhost:8000"), os.getenv("EXOSPHERE_API_KEY", "")) runtime.connect([SampleNode()]) runtime.start() ## Support For first party ...

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~23-~23: Use hyphens correctly
Context: ...)]) runtime.start() ``` ## Support For first party support and questions do not hesit...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~23-~23: Use a period to end declarative sentences
Context: ...s do not hesitate to reach out to us at nivedit@exosphere.host

(QB_NEW_EN_OTHER_ERROR_IDS_25)

🪛 markdownlint-cli2 (0.17.2)
python-sdk/README.md

4-4: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


5-5: Trailing spaces
Expected: 0 or 2; Actual: 1

(MD009, no-trailing-spaces)


22-22: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


23-23: Bare URL used

(MD034, no-bare-urls)


23-23: Files should end with a single newline character

(MD047, single-trailing-newline)

🔇 Additional comments (10)
python-sdk/exospherehost/_version.py (1)

1-1: LGTM! Version update is consistent with the broader refactoring.

The change from uppercase VERSION to lowercase version aligns with Python naming conventions for variables, and the version bump to "0.0.4b" is appropriate for this beta release.

python-sdk/pyproject.toml (1)

28-28: LGTM! Dynamic version reference updated correctly.

The change from exospherehost.__version__ to exospherehost._version.version correctly aligns with the version management refactoring and maintains consistency across the build configuration.

python-sdk/sample.py (1)

9-9: Consider security implications of empty API key default.

The default empty string for EXOSPHERE_API_KEY could lead to authentication issues or security vulnerabilities. Consider requiring the API key or providing a more explicit error message when it's missing.

-runtime = Runtime("SampleNamespace", os.getenv("EXOSPHERE_STATE_MANAGER_URI", "http://localhost:8000"), os.getenv("EXOSPHERE_API_KEY", ""))
+api_key = os.getenv("EXOSPHERE_API_KEY")
+if not api_key:
+    raise ValueError("EXOSPHERE_API_KEY environment variable is required")
+runtime = Runtime("SampleNamespace", os.getenv("EXOSPHERE_STATE_MANAGER_URI", "http://localhost:8000"), api_key)
python-sdk/exospherehost/node/BaseNode.py (2)

2-2: LGTM! Import addition supports enhanced type annotations.

The addition of Any to the typing imports is necessary for the updated method signature and improves type safety.


11-11: Excellent improvement to the abstract method signature.

The updated execute method signature with explicit type annotations (inputs: dict[str, Any] and return type dict[str, Any]) provides clear guidance for implementers and improves type safety throughout the SDK.

python-sdk/exospherehost/__init__.py (1)

1-7: LGTM! Clean public API definition.

The restructured imports and explicit __all__ declaration properly define the SDK's public interface. The backward compatibility for VERSION is maintained while following the more conventional __version__ pattern.

python-sdk/exospherehost/runtime.py (4)

10-10: Consider the performance impact of reduced polling interval.

The default poll_interval was reduced from 10 to 1 second, which will significantly increase the polling frequency. This could lead to increased API calls and resource consumption. Consider if this aggressive polling is necessary for all use cases, or if it should be configurable based on the workload characteristics.


38-42: Good API simplification.

Converting connect to synchronous improves the developer experience since this method doesn't perform any I/O operations that would benefit from being asynchronous.


44-56: Proper API authentication and error handling implemented.

The addition of the x-api-key header and explicit error handling for non-200 responses improves the robustness of the API calls.


109-116: Well-structured async task management.

The separation of the enqueue poller and worker tasks with asyncio.gather provides clean concurrent execution.

Copy link
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: 2

♻️ Duplicate comments (3)
python-sdk/exospherehost/runtime.py (3)

60-70: Error handling successfully implemented as previously suggested.

The try-except block now properly handles exceptions from _enqueue_call, preventing the enqueue task from crashing.


72-94: Consistent error handling implemented across notification methods.

Both _notify_executed and _notify_errored now have consistent error handling with logging for non-200 responses, as previously suggested.


130-131: Known limitation: asyncio.run() incompatibility with existing event loops.

As previously noted, asyncio.run() will fail if called from within an existing event loop. This limitation should be documented or addressed with alternative implementation.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa06bb3 and 8a26d91.

📒 Files selected for processing (1)
  • python-sdk/exospherehost/runtime.py (3 hunks)
🔇 Additional comments (3)
python-sdk/exospherehost/runtime.py (3)

4-8: Good improvements to imports and logging setup.

The more specific import path for BaseNode and the addition of proper logging infrastructure are welcome improvements.


48-58: Well-implemented API authentication and error handling.

Good additions:

  • API key authentication via headers
  • Error logging while still returning the response for caller handling

115-119: Critical fix: Added missing task_done() call.

Excellent addition of self._state_queue.task_done() - this was a critical omission that could have caused queue blocking and memory issues. The key change from "id" to "state_id" correctly aligns with the API schema.

Copy link
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: 2

♻️ Duplicate comments (2)
python-sdk/exospherehost/runtime.py (2)

12-12: Consider the impact of the aggressive default polling interval.

The default poll_interval of 1 second could lead to excessive API calls and potential rate limiting issues in production. Consider using a more conservative default (e.g., 5-10 seconds) or clearly documenting the implications.


40-44: Breaking change: connect is now synchronous.

The connect method has been changed from async to sync. This is a breaking API change that should be clearly documented in the changelog and migration guide.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8a26d91 and 927bb06.

📒 Files selected for processing (1)
  • python-sdk/exospherehost/runtime.py (3 hunks)
🔇 Additional comments (6)
python-sdk/exospherehost/runtime.py (6)

46-58: Good addition of authentication and error logging.

The inclusion of the API key header and error logging for non-200 responses improves security and debugging capabilities.


60-70: Excellent implementation of error handling.

The addition of try-except block ensures the enqueue task continues running despite transient errors, addressing the concern raised in previous reviews.


72-83: Consistent error handling implemented.

The addition of error logging for non-200 responses provides better visibility into failures, addressing the consistency concern from previous reviews.


84-94: Good consistency in error handling across notification methods.

Both notification methods now have uniform error handling and authentication patterns.


119-119: Good addition of queue task completion.

Adding task_done() ensures proper queue management and allows for join operations if needed.


115-117: Confirmed: state_id usage matches the API
The SDK’s switch from state["id"] to state["state_id"] aligns with the Pydantic ResponseStateModel (which defines state_id) and the executed_state/errored_state controllers expecting state_id. No further changes needed.

@exospherehost exospherehost deleted a comment from coderabbitai bot Jul 31, 2025
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.

1 participant