Skip to content

Commit 5b87a49

Browse files
committed
added install-hooks to make it easier to lint and regen examples becuase i keep forgetting this!
1 parent e3c37f9 commit 5b87a49

6 files changed

Lines changed: 53 additions & 11 deletions

File tree

EXAMPLES.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ uv run pytest -m smoketest tests/smoketests/examples/
4444
<a id="devbox-from-blueprint-lifecycle"></a>
4545
## Devbox From Blueprint (Run Command, Shutdown)
4646

47-
**Use case:** Create a devbox from a blueprint, run a command, validate output, and cleanly tear everything down.
47+
**Use case:** Create a devbox from a blueprint, run a command, fetch logs, validate output, and cleanly tear everything down.
4848

49-
**Tags:** `devbox`, `blueprint`, `commands`, `cleanup`
49+
**Tags:** `devbox`, `blueprint`, `commands`, `logs`, `cleanup`
5050

5151
### Workflow
5252
- Create a blueprint
53+
- Fetch blueprint build logs
5354
- Create a devbox from the blueprint
5455
- Execute a command in the devbox
55-
- Validate exit code and stdout
56+
- Fetch devbox logs
57+
- Validate exit code, stdout, and logs
5658
- Shutdown devbox and delete blueprint
5759

5860
### Prerequisites

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,17 @@ print(runloop_api_client.__version__)
497497

498498
Python 3.9 or higher.
499499

500+
## Development
501+
502+
After cloning the repository, run the bootstrap script and install git hooks:
503+
504+
```sh
505+
./scripts/bootstrap
506+
./scripts/install-hooks
507+
```
508+
509+
This installs pre-push hooks that run linting and verify generated files are up to date.
510+
500511
## Contributing
501512

502513
See [the contributing documentation](./CONTRIBUTING.md).

examples/devbox_from_blueprint_lifecycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def recipe(ctx: RecipeContext) -> RecipeOutput:
8282
),
8383
ExampleCheck(
8484
name="blueprint build logs are retrievable",
85-
passed=blueprint_logs is not None and hasattr(blueprint_logs, "logs"),
85+
passed=hasattr(blueprint_logs, "logs"),
8686
details=f"blueprint_log_count={len(blueprint_logs.logs)}",
8787
),
8888
ExampleCheck(
8989
name="devbox logs are retrievable",
90-
passed=devbox_logs is not None and hasattr(devbox_logs, "logs"),
90+
passed=hasattr(devbox_logs, "logs"),
9191
details=f"devbox_log_count={len(devbox_logs.logs)}",
9292
),
9393
],

scripts/install-hooks

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
echo "==> Installing git hooks..."
8+
9+
mkdir -p .git/hooks
10+
11+
cat > .git/hooks/pre-push << 'EOF'
12+
#!/usr/bin/env bash
13+
set -e
14+
cd "$(git rev-parse --show-toplevel)"
15+
16+
echo "==> Running lint checks..."
17+
./scripts/lint
18+
19+
echo "==> Checking EXAMPLES.md is up to date..."
20+
uv run python scripts/generate_examples_md.py --check
21+
22+
echo "==> All checks passed!"
23+
EOF
24+
25+
chmod +x .git/hooks/pre-push
26+
27+
echo "==> Git hooks installed successfully!"

src/runloop_api_client/sdk/async_devbox.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
DevboxExecutionDetailView,
1616
DevboxCreateSSHKeyResponse,
1717
)
18-
from ..types.devboxes.devbox_logs_list_view import DevboxLogsListView
1918
from ._types import (
2019
LogCallback,
2120
BaseRequestOptions,
@@ -34,6 +33,7 @@
3433
SDKDevboxSnapshotDiskAsyncParams,
3534
SDKDevboxWriteFileContentsParams,
3635
)
36+
from .._types import omit
3737
from .._client import AsyncRunloop
3838
from ._helpers import filter_params
3939
from .._streaming import AsyncStream
@@ -42,6 +42,7 @@
4242
from .async_execution import AsyncExecution, _AsyncStreamingGroup
4343
from .async_execution_result import AsyncExecutionResult
4444
from ..types.devbox_execute_async_params import DevboxNiceExecuteAsyncParams
45+
from ..types.devboxes.devbox_logs_list_view import DevboxLogsListView
4546
from ..types.devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
4647

4748
StreamFactory = Callable[[], Awaitable[AsyncStream[ExecutionUpdateChunk]]]
@@ -191,8 +192,8 @@ async def logs(
191192
"""
192193
return await self._client.devboxes.logs.list(
193194
self._id,
194-
execution_id=execution_id,
195-
shell_name=shell_name,
195+
execution_id=execution_id if execution_id is not None else omit,
196+
shell_name=shell_name if shell_name is not None else omit,
196197
**options,
197198
)
198199

src/runloop_api_client/sdk/devbox.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
DevboxExecutionDetailView,
1616
DevboxCreateSSHKeyResponse,
1717
)
18-
from ..types.devboxes.devbox_logs_list_view import DevboxLogsListView
1918
from ._types import (
2019
LogCallback,
2120
BaseRequestOptions,
@@ -35,6 +34,7 @@
3534
SDKDevboxSnapshotDiskAsyncParams,
3635
SDKDevboxWriteFileContentsParams,
3736
)
37+
from .._types import omit
3838
from .._client import Runloop
3939
from ._helpers import filter_params
4040
from .execution import Execution, _StreamingGroup
@@ -43,6 +43,7 @@
4343
from ..types.devboxes import ExecutionUpdateChunk
4444
from .execution_result import ExecutionResult
4545
from ..types.devbox_execute_async_params import DevboxNiceExecuteAsyncParams
46+
from ..types.devboxes.devbox_logs_list_view import DevboxLogsListView
4647
from ..types.devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
4748

4849
if TYPE_CHECKING:
@@ -190,8 +191,8 @@ def logs(
190191
"""
191192
return self._client.devboxes.logs.list(
192193
self._id,
193-
execution_id=execution_id,
194-
shell_name=shell_name,
194+
execution_id=execution_id if execution_id is not None else omit,
195+
shell_name=shell_name if shell_name is not None else omit,
195196
**options,
196197
)
197198

0 commit comments

Comments
 (0)