Skip to content

Rename init function#1266

Merged
guibeira merged 5 commits intomainfrom
rename-init-function
Mar 9, 2026
Merged

Rename init function#1266
guibeira merged 5 commits intomainfrom
rename-init-function

Conversation

@guibeira
Copy link
Contributor

@guibeira guibeira commented Mar 9, 2026

Summary by CodeRabbit

  • Refactor
    • The SDK initialization method has been updated across all supported language implementations (JavaScript, Python, and Rust). Users upgrading to this version must update their initialization code. All configuration parameters and runtime behavior remain unchanged. Example applications and supporting materials have been updated to reflect the new initialization approach.

@vercel
Copy link
Contributor

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
iii-docs Ready Ready Preview, Comment Mar 9, 2026 2:54pm
motia-docs Ready Ready Preview, Comment Mar 9, 2026 2:54pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This PR renames the SDK initialization function from init to registerWorker across multiple language packages (Node.js, Python, Rust) and their corresponding examples and tests, maintaining identical function signatures and behavior.

Changes

Cohort / File(s) Summary
Node.js SDK Core Library
sdk/packages/node/iii/src/iii.ts, sdk/packages/node/iii/src/index.ts
Renamed exported function from init to registerWorker; maintains identical function signature, return type, and behavior.
Node.js SDK Tests & Examples
sdk/packages/node/iii-example/src/iii.ts, sdk/packages/node/iii/tests/exports.test.ts, sdk/packages/node/iii/tests/utils.ts
Updated example code and test files to import and use registerWorker instead of init; test assertions updated accordingly.
Python SDK Core Library
sdk/packages/python/iii/src/iii/__init__.py
Renamed function from init to register_worker; updated docstrings, error messages, and __all__ export to reflect new function name.
Python SDK Tests & Examples
sdk/packages/python/iii-example/src/main.py, sdk/packages/python/iii/tests/test_init_api.py
Updated example code and test files to import and call register_worker instead of init.
Rust SDK Core Library
sdk/packages/rust/iii/src/lib.rs
Renamed public function from init to register_worker; updated error messages and log references to reflect new function name.
Rust SDK Tests & Examples
sdk/packages/rust/iii-example/src/main.rs, sdk/packages/rust/iii/tests/init_api.rs
Updated example code and test files to use register_worker instead of init; test messages and error expectations updated accordingly.
Motia Framework Integration
frameworks/motia/motia-js/packages/motia/src/new/iii.ts
Updated Motia framework wrapper to call registerWorker instead of init from iii-sdk.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • ytallo
  • sergiofilhowz
  • andersonleal

Poem

🐰 From init to registerWorker we hop,
A rename so graceful, we'll never stop,
Across all the languages, clean and bright,
Same function, new name—everything right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming the init function to registerWorker across multiple language SDKs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rename-init-function

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

🧹 Nitpick comments (5)
sdk/packages/python/iii/tests/test_init_api.py (3)

28-30: Consider renaming test function for consistency.

Similarly, test_init_requires_running_loop should be renamed to test_register_worker_requires_running_loop.

♻️ Suggested rename
-def test_init_requires_running_loop() -> None:
+def test_register_worker_requires_running_loop() -> None:
     with pytest.raises(RuntimeError, match="active asyncio event loop"):
         register_worker("ws://fake")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/python/iii/tests/test_init_api.py` around lines 28 - 30, Rename
the test function test_init_requires_running_loop to
test_register_worker_requires_running_loop to match naming consistency; update
the function definition in the test file (the def that calls
register_worker("ws://fake") and asserts the RuntimeError about active asyncio
event loop) so the function name reflects register_worker.

13-25: Consider renaming test functions for consistency.

Test function names still reference init but now test register_worker. Consider renaming for consistency:

  • test_init_schedules_connecttest_register_worker_schedules_connect
♻️ Suggested rename
 `@pytest.mark.anyio`
-async def test_init_schedules_connect(monkeypatch: pytest.MonkeyPatch) -> None:
+async def test_register_worker_schedules_connect(monkeypatch: pytest.MonkeyPatch) -> None:
     called = asyncio.Event()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/python/iii/tests/test_init_api.py` around lines 13 - 25, Rename
the test function to reflect the behavior under test: change the test name
`test_init_schedules_connect` to `test_register_worker_schedules_connect` so it
matches the use of `register_worker` and the patched `III.connect`; update the
test definition line for the async test and any references to the old name in
the file accordingly.

33-62: Consider renaming test function for consistency.

test_connect_consumes_otel_from_init_options could be renamed to test_connect_consumes_otel_from_register_worker_options or similar.

♻️ Suggested rename
 `@pytest.mark.anyio`
-async def test_connect_consumes_otel_from_init_options(monkeypatch: pytest.MonkeyPatch) -> None:
+async def test_connect_consumes_otel_from_register_worker_options(monkeypatch: pytest.MonkeyPatch) -> None:
     import iii.telemetry as telemetry
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/python/iii/tests/test_init_api.py` around lines 33 - 62, Rename
the test function test_connect_consumes_otel_from_init_options to a name that
reflects the actual API under test (e.g.,
test_connect_consumes_otel_from_register_worker_options) so it matches the usage
of register_worker and InitOptions in the test; update the function definition
and any references to the old name (the test function itself and any test
discovery references) to the new name to keep naming consistent with
register_worker and InitOptions.
sdk/packages/rust/iii/tests/init_api.rs (2)

12-19: Consider renaming test function for consistency.

The test function is still named init_with_runtime_returns_sdk_instance but it now tests register_worker. Consider renaming to register_worker_with_runtime_returns_sdk_instance for consistency with the first test function which was renamed.

♻️ Suggested rename
 #[tokio::test]
-async fn init_with_runtime_returns_sdk_instance() {
+async fn register_worker_with_runtime_returns_sdk_instance() {
     let client = register_worker("ws://127.0.0.1:49134", InitOptions::default())
         .expect("register_worker should succeed inside Tokio runtime");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/rust/iii/tests/init_api.rs` around lines 12 - 19, Rename the
test function init_with_runtime_returns_sdk_instance to
register_worker_with_runtime_returns_sdk_instance so the name reflects that it
tests register_worker; update the function signature fn
init_with_runtime_returns_sdk_instance() to fn
register_worker_with_runtime_returns_sdk_instance() and ensure the
#[tokio::test] annotated function and any references to it (if any) are updated
accordingly.

21-39: Consider renaming test function for consistency.

Similarly, init_applies_otel_config_before_auto_connect should be renamed to match the new API naming convention.

♻️ Suggested rename
 #[cfg(feature = "otel")]
 #[tokio::test]
-async fn init_applies_otel_config_before_auto_connect() {
+async fn register_worker_applies_otel_config_before_auto_connect() {
     use iii_sdk::OtelConfig;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/packages/rust/iii/tests/init_api.rs` around lines 21 - 39, Rename the
test function init_applies_otel_config_before_auto_connect to follow the
project's new test naming convention (keep the same test body using
register_worker, InitOptions and OtelConfig) — update the function declaration
name and any references so the test name matches other tests in the suite (e.g.,
use the new API-style name used elsewhere for init tests) while leaving
register_worker, InitOptions, OtelConfig and the test logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sdk/packages/python/iii/tests/test_init_api.py`:
- Around line 28-30: Rename the test function test_init_requires_running_loop to
test_register_worker_requires_running_loop to match naming consistency; update
the function definition in the test file (the def that calls
register_worker("ws://fake") and asserts the RuntimeError about active asyncio
event loop) so the function name reflects register_worker.
- Around line 13-25: Rename the test function to reflect the behavior under
test: change the test name `test_init_schedules_connect` to
`test_register_worker_schedules_connect` so it matches the use of
`register_worker` and the patched `III.connect`; update the test definition line
for the async test and any references to the old name in the file accordingly.
- Around line 33-62: Rename the test function
test_connect_consumes_otel_from_init_options to a name that reflects the actual
API under test (e.g., test_connect_consumes_otel_from_register_worker_options)
so it matches the usage of register_worker and InitOptions in the test; update
the function definition and any references to the old name (the test function
itself and any test discovery references) to the new name to keep naming
consistent with register_worker and InitOptions.

In `@sdk/packages/rust/iii/tests/init_api.rs`:
- Around line 12-19: Rename the test function
init_with_runtime_returns_sdk_instance to
register_worker_with_runtime_returns_sdk_instance so the name reflects that it
tests register_worker; update the function signature fn
init_with_runtime_returns_sdk_instance() to fn
register_worker_with_runtime_returns_sdk_instance() and ensure the
#[tokio::test] annotated function and any references to it (if any) are updated
accordingly.
- Around line 21-39: Rename the test function
init_applies_otel_config_before_auto_connect to follow the project's new test
naming convention (keep the same test body using register_worker, InitOptions
and OtelConfig) — update the function declaration name and any references so the
test name matches other tests in the suite (e.g., use the new API-style name
used elsewhere for init tests) while leaving register_worker, InitOptions,
OtelConfig and the test logic unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51c7b739-265f-46f3-9936-6e46a720465e

📥 Commits

Reviewing files that changed from the base of the PR and between ed672d7 and b7653cf.

📒 Files selected for processing (12)
  • frameworks/motia/motia-js/packages/motia/src/new/iii.ts
  • sdk/packages/node/iii-example/src/iii.ts
  • sdk/packages/node/iii/src/iii.ts
  • sdk/packages/node/iii/src/index.ts
  • sdk/packages/node/iii/tests/exports.test.ts
  • sdk/packages/node/iii/tests/utils.ts
  • sdk/packages/python/iii-example/src/main.py
  • sdk/packages/python/iii/src/iii/__init__.py
  • sdk/packages/python/iii/tests/test_init_api.py
  • sdk/packages/rust/iii-example/src/main.rs
  • sdk/packages/rust/iii/src/lib.rs
  • sdk/packages/rust/iii/tests/init_api.rs

@guibeira guibeira merged commit bc89b3f into main Mar 9, 2026
20 checks passed
@guibeira guibeira deleted the rename-init-function branch March 9, 2026 18:00
anthonyiscoding pushed a commit that referenced this pull request Mar 9, 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.

2 participants