Skip to content

Commit fe04fd6

Browse files
committed
update builder docstrings to use fluent pattern, replaced all references to RunloopSDK() to 'runloop' instead of 'sdk' or 'client'
1 parent b50ce5f commit fe04fd6

File tree

8 files changed

+71
-63
lines changed

8 files changed

+71
-63
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ For a higher-level, Pythonic interface, check out the new [`RunloopSDK`](README-
3333
```python
3434
from runloop_api_client import RunloopSDK
3535

36-
sdk = RunloopSDK() # Uses RUNLOOP_API_KEY environment variable by default
36+
runloop = RunloopSDK() # Uses RUNLOOP_API_KEY environment variable by default
3737

3838
# Create a devbox and execute commands with a clean, object-oriented interface
39-
with sdk.devbox.create(name="my-devbox") as devbox:
39+
with runloop.devbox.create(name="my-devbox") as devbox:
4040
result = devbox.cmd.exec("echo 'Hello from Runloop!'")
4141
print(result.stdout())
4242
```

src/runloop_api_client/sdk/async_.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,12 @@ class AsyncScenarioOps:
776776
>>> scenarios = await runloop.scenario.list()
777777
778778
Example using builder:
779-
>>> builder = runloop.scenario.builder("my-scenario")
780-
>>> builder.from_blueprint_id("bp-xxx")
781-
>>> builder.with_problem_statement("Fix the bug")
782-
>>> builder.add_test_scorer("tests", test_command="pytest")
779+
>>> builder = (
780+
... runloop.scenario.builder("my-scenario")
781+
... .from_blueprint(blueprint)
782+
... .with_problem_statement("Fix the bug")
783+
... .add_test_scorer("tests", test_command="pytest")
784+
... )
783785
>>> scenario = await builder.push()
784786
"""
785787

src/runloop_api_client/sdk/async_scenario_builder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ class AsyncScenarioBuilder:
3131
before pushing it to the platform.
3232
3333
Example:
34-
>>> builder = sdk.scenario.builder("my-scenario")
35-
>>> builder.from_blueprint(blueprint)
36-
>>> builder.with_working_directory("/app")
37-
>>> builder.with_problem_statement("Fix the bug in main.py")
38-
>>> builder.add_test_scorer("tests", test_command="pytest")
34+
>>> builder = (
35+
... runloop.scenario.builder("my-scenario")
36+
... .from_blueprint(blueprint)
37+
... .with_working_directory("/app")
38+
... .with_problem_statement("Fix the bug in main.py")
39+
... .add_test_scorer("tests", test_command="pytest")
40+
... )
3941
>>> scenario = await builder.push()
4042
"""
4143

src/runloop_api_client/sdk/scenario_builder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ class ScenarioBuilder:
3131
before pushing it to the platform.
3232
3333
Example:
34-
>>> builder = sdk.scenario.builder("my-scenario")
35-
>>> builder.from_blueprint(blueprint)
36-
>>> builder.with_working_directory("/app")
37-
>>> builder.with_problem_statement("Fix the bug in main.py")
38-
>>> builder.add_test_scorer("tests", test_command="pytest")
34+
>>> builder = (
35+
... runloop.scenario.builder("my-scenario")
36+
... .from_blueprint(blueprint)
37+
... .with_working_directory("/app")
38+
... .with_problem_statement("Fix the bug in main.py")
39+
... .add_test_scorer("tests", test_command="pytest")
40+
... )
3941
>>> scenario = builder.push()
4042
"""
4143

src/runloop_api_client/sdk/sync.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,12 @@ class ScenarioOps:
797797
>>> scenarios = runloop.scenario.list()
798798
799799
Example using builder:
800-
>>> builder = runloop.scenario.builder("my-scenario")
801-
>>> builder.from_blueprint_id("bp-xxx")
802-
>>> builder.with_problem_statement("Fix the bug")
803-
>>> builder.add_test_scorer("tests", test_command="pytest")
800+
>>> builder = (
801+
... runloop.scenario.builder("my-scenario")
802+
... .from_blueprint(blueprint)
803+
... .with_problem_statement("Fix the bug")
804+
... .add_test_scorer("tests", test_command="pytest")
805+
... )
804806
>>> scenario = builder.push()
805807
"""
806808

tests/sdk/test_async_ops.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,33 +1193,33 @@ class TestAsyncRunloopSDK:
11931193

11941194
def test_init(self) -> None:
11951195
"""Test AsyncRunloopSDK initialization."""
1196-
sdk = AsyncRunloopSDK(bearer_token="test-token")
1197-
assert sdk.api is not None
1198-
assert isinstance(sdk.agent, AsyncAgentOps)
1199-
assert isinstance(sdk.devbox, AsyncDevboxOps)
1200-
assert isinstance(sdk.scorer, AsyncScorerOps)
1201-
assert isinstance(sdk.snapshot, AsyncSnapshotOps)
1202-
assert isinstance(sdk.blueprint, AsyncBlueprintOps)
1203-
assert isinstance(sdk.storage_object, AsyncStorageObjectOps)
1196+
runloop = AsyncRunloopSDK(bearer_token="test-token")
1197+
assert runloop.api is not None
1198+
assert isinstance(runloop.agent, AsyncAgentOps)
1199+
assert isinstance(runloop.devbox, AsyncDevboxOps)
1200+
assert isinstance(runloop.scorer, AsyncScorerOps)
1201+
assert isinstance(runloop.snapshot, AsyncSnapshotOps)
1202+
assert isinstance(runloop.blueprint, AsyncBlueprintOps)
1203+
assert isinstance(runloop.storage_object, AsyncStorageObjectOps)
12041204

12051205
@pytest.mark.asyncio
12061206
async def test_aclose(self) -> None:
12071207
"""Test aclose method."""
1208-
sdk = AsyncRunloopSDK(bearer_token="test-token")
1208+
runloop = AsyncRunloopSDK(bearer_token="test-token")
12091209
# Verify aclose doesn't raise
1210-
await sdk.aclose()
1210+
await runloop.aclose()
12111211

12121212
@pytest.mark.asyncio
12131213
async def test_context_manager(self) -> None:
12141214
"""Test context manager behavior."""
1215-
async with AsyncRunloopSDK(bearer_token="test-token") as sdk:
1216-
assert sdk.api is not None
1215+
async with AsyncRunloopSDK(bearer_token="test-token") as runloop:
1216+
assert runloop.api is not None
12171217
# Verify context manager properly closes (implementation detail of context manager protocol)
12181218

12191219
def test_api_property(self) -> None:
12201220
"""Test api property access."""
1221-
sdk = AsyncRunloopSDK(bearer_token="test-token")
1222-
assert sdk.api is not None
1223-
assert hasattr(sdk.api, "devboxes")
1224-
assert hasattr(sdk.api, "blueprints")
1225-
assert hasattr(sdk.api, "objects")
1221+
runloop = AsyncRunloopSDK(bearer_token="test-token")
1222+
assert runloop.api is not None
1223+
assert hasattr(runloop.api, "devboxes")
1224+
assert hasattr(runloop.api, "blueprints")
1225+
assert hasattr(runloop.api, "objects")

tests/sdk/test_ops.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,36 +1070,36 @@ class TestRunloopSDK:
10701070

10711071
def test_init(self) -> None:
10721072
"""Test RunloopSDK initialization."""
1073-
sdk = RunloopSDK(bearer_token="test-token")
1074-
assert sdk.api is not None
1075-
assert isinstance(sdk.agent, AgentOps)
1076-
assert isinstance(sdk.devbox, DevboxOps)
1077-
assert isinstance(sdk.scorer, ScorerOps)
1078-
assert isinstance(sdk.snapshot, SnapshotOps)
1079-
assert isinstance(sdk.blueprint, BlueprintOps)
1080-
assert isinstance(sdk.storage_object, StorageObjectOps)
1073+
runloop = RunloopSDK(bearer_token="test-token")
1074+
assert runloop.api is not None
1075+
assert isinstance(runloop.agent, AgentOps)
1076+
assert isinstance(runloop.devbox, DevboxOps)
1077+
assert isinstance(runloop.scorer, ScorerOps)
1078+
assert isinstance(runloop.snapshot, SnapshotOps)
1079+
assert isinstance(runloop.blueprint, BlueprintOps)
1080+
assert isinstance(runloop.storage_object, StorageObjectOps)
10811081

10821082
def test_init_with_max_retries(self) -> None:
10831083
"""Test RunloopSDK initialization with max_retries."""
1084-
sdk = RunloopSDK(bearer_token="test-token", max_retries=3)
1085-
assert sdk.api is not None
1084+
runloop = RunloopSDK(bearer_token="test-token", max_retries=3)
1085+
assert runloop.api is not None
10861086

10871087
def test_close(self) -> None:
10881088
"""Test close method."""
1089-
sdk = RunloopSDK(bearer_token="test-token")
1089+
runloop = RunloopSDK(bearer_token="test-token")
10901090
# Verify close doesn't raise
1091-
sdk.close()
1091+
runloop.close()
10921092

10931093
def test_context_manager(self) -> None:
10941094
"""Test context manager behavior."""
1095-
with RunloopSDK(bearer_token="test-token") as sdk:
1096-
assert sdk.api is not None
1095+
with RunloopSDK(bearer_token="test-token") as runloop:
1096+
assert runloop.api is not None
10971097
# Verify context manager properly closes (implementation detail of context manager protocol)
10981098

10991099
def test_api_property(self) -> None:
11001100
"""Test api property access."""
1101-
sdk = RunloopSDK(bearer_token="test-token")
1102-
assert sdk.api is not None
1103-
assert hasattr(sdk.api, "devboxes")
1104-
assert hasattr(sdk.api, "blueprints")
1105-
assert hasattr(sdk.api, "objects")
1101+
runloop = RunloopSDK(bearer_token="test-token")
1102+
assert runloop.api is not None
1103+
assert hasattr(runloop.api, "devboxes")
1104+
assert hasattr(runloop.api, "blueprints")
1105+
assert hasattr(runloop.api, "objects")

tests/smoketests/sdk/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ def sdk_client() -> Iterator[RunloopSDK]:
2424
if not bearer_token:
2525
pytest.skip("RUNLOOP_API_KEY environment variable not set")
2626

27-
client = RunloopSDK(
27+
runloop = RunloopSDK(
2828
bearer_token=bearer_token,
2929
base_url=base_url,
3030
)
3131

3232
try:
33-
yield client
33+
yield runloop
3434
finally:
3535
try:
36-
client.close()
36+
runloop.close()
3737
except Exception:
3838
pass
3939

@@ -52,17 +52,17 @@ async def async_sdk_client() -> AsyncIterator[AsyncRunloopSDK]:
5252
if not bearer_token:
5353
pytest.skip("RUNLOOP_API_KEY environment variable not set")
5454

55-
client = AsyncRunloopSDK(
55+
runloop = AsyncRunloopSDK(
5656
bearer_token=bearer_token,
5757
base_url=base_url,
5858
)
5959

6060
try:
61-
async with client:
62-
yield client
61+
async with runloop:
62+
yield runloop
6363
except Exception:
6464
# If context manager fails, try manual cleanup
6565
try:
66-
await client.aclose()
66+
await runloop.aclose()
6767
except Exception:
6868
pass

0 commit comments

Comments
 (0)