Skip to content

Commit ab177ef

Browse files
committed
add formatting for sdk README
1 parent 28fcc88 commit ab177ef

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

README-SDK.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ print(obj.download_as_text())
7777
import asyncio
7878
from runloop_api_client import AsyncRunloopSDK
7979

80+
8081
async def main():
8182
runloop = AsyncRunloopSDK()
8283
async with await runloop.devbox.create(name="async-devbox") as devbox:
@@ -88,6 +89,7 @@ async def main():
8889

8990
await devbox.cmd.exec("ls", stdout=capture)
9091

92+
9193
asyncio.run(main())
9294
```
9395

@@ -194,7 +196,7 @@ print("Devbox ID:", execution.devbox_id)
194196
# Poll for current state
195197
state = execution.get_state()
196198
print("Status:", state.status) # "running", "completed", etc.
197-
print("Exit code:", state.exit_status) # only set when execution has completed
199+
print("Exit code:", state.exit_status) # only set when execution has completed
198200

199201
# Wait for completion and get results
200202
result = execution.result()
@@ -229,7 +231,7 @@ result = execution.result()
229231
# Access execution results
230232
print("Exit code:", result.exit_code)
231233
print("Success:", result.success) # True if exit code is 0
232-
print("Failed:", result.failed) # True if exit code is non-zero
234+
print("Failed:", result.failed) # True if exit code is non-zero
233235

234236
# Get output streams
235237
stdout = result.stdout()
@@ -261,6 +263,7 @@ Pass callbacks into `cmd.exec` / `cmd.exec_async` to process logs in real time:
261263
def handle_output(line: str) -> None:
262264
print("LOG:", line)
263265

266+
264267
result = devbox.cmd.exec(
265268
"python train.py",
266269
stdout=handle_output,
@@ -278,6 +281,7 @@ def capture(line: str) -> None:
278281
# Use thread-safe data structures if needed
279282
log_queue.put_nowait(line)
280283

284+
281285
await devbox.cmd.exec(
282286
"tail -f /var/log/app.log",
283287
stdout=capture,
@@ -299,6 +303,7 @@ print(content)
299303

300304
# Upload files
301305
from pathlib import Path
306+
302307
devbox.file.upload(
303308
path="/home/user/upload.txt",
304309
file=Path("local_file.txt"),
@@ -535,6 +540,7 @@ storage_object.complete()
535540

536541
# Upload from file
537542
from pathlib import Path
543+
538544
uploaded = runloop.storage_object.upload_from_file(
539545
Path("/path/to/file.txt"),
540546
name="my-file.txt",
@@ -584,7 +590,7 @@ obj = runloop.storage_object.create(
584590
name="data.bin",
585591
content_type="binary",
586592
)
587-
obj.upload_content(b"\xDE\xAD\xBE\xEF")
593+
obj.upload_content(b"\xde\xad\xbe\xef")
588594
obj.complete()
589595
```
590596

@@ -731,28 +737,30 @@ The async SDK has the same interface as the synchronous version, but all I/O ope
731737
import asyncio
732738
from runloop_api_client import AsyncRunloopSDK
733739

740+
734741
async def main():
735742
runloop = AsyncRunloopSDK()
736-
743+
737744
# All the same operations, but with await
738745
async with await runloop.devbox.create(name="async-devbox") as devbox:
739746
result = await devbox.cmd.exec("pwd")
740747
print(await result.stdout())
741-
748+
742749
# Streaming (note: callbacks must be synchronous)
743750
def capture(line: str) -> None:
744751
print(">>", line)
745-
752+
746753
await devbox.cmd.exec("ls", stdout=capture)
747-
754+
748755
# Async file operations
749756
await devbox.file.write(path="/tmp/test.txt", contents="Hello")
750757
content = await devbox.file.read(path="/tmp/test.txt")
751-
758+
752759
# Async network operations
753760
tunnel = await devbox.net.create_tunnel(port=8080)
754761
print("Tunnel URL:", tunnel.url)
755762

763+
756764
asyncio.run(main())
757765
```
758766

@@ -768,15 +776,15 @@ devbox = runloop.devbox.create(
768776
name="my-devbox",
769777
polling_config=PollingConfig(
770778
timeout_seconds=300.0, # Wait up to 5 minutes
771-
interval_seconds=2.0, # Poll every 2 seconds
779+
interval_seconds=2.0, # Poll every 2 seconds
772780
),
773781
)
774782

775783
# Wait for snapshot completion with custom polling
776784
snapshot.await_completed(
777785
polling_config=PollingConfig(
778786
timeout_seconds=600.0, # Wait up to 10 minutes
779-
interval_seconds=5.0, # Poll every 5 seconds
787+
interval_seconds=5.0, # Poll every 5 seconds
780788
),
781789
)
782790
```

scripts/format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ uv run ruff check --fix .
1111
uv run ruff format
1212

1313
echo "==> Formatting docs"
14-
uv run python scripts/utils/ruffen-docs.py README.md api.md
14+
uv run python scripts/utils/ruffen-docs.py README.md api.md README-SDK.md

0 commit comments

Comments
 (0)