Skip to content

Commit 00b7da4

Browse files
committed
fixed name issue when running examples (thanks sid!)
1 parent 809ebf6 commit 00b7da4

File tree

9 files changed

+15
-14
lines changed

9 files changed

+15
-14
lines changed

EXAMPLES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Runnable examples live in [`examples/`](./examples).
2929

3030
### Run
3131
```sh
32-
uv run examples/devbox_from_blueprint_lifecycle.py
32+
uv run python -m examples.devbox_from_blueprint_lifecycle
3333
```
3434

3535
### Test
@@ -61,7 +61,7 @@ uv run pytest -m smoketest tests/smoketests/examples/
6161

6262
### Run
6363
```sh
64-
GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx uv run examples/mcp_github_tools.py
64+
GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx uv run python -m examples.mcp_github_tools
6565
```
6666

6767
### Test

examples/_harness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Any, TypeVar, Callable, Awaitable
77
from dataclasses import asdict
88

9-
from .types import (
9+
from .example_types import (
1010
ExampleCheck,
1111
RecipeOutput,
1212
ExampleResult,

examples/devbox_from_blueprint_lifecycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- cleanup
1818
prerequisites:
1919
- RUNLOOP_API_KEY
20-
run: uv run examples/devbox_from_blueprint_lifecycle.py
20+
run: uv run python -m examples.devbox_from_blueprint_lifecycle
2121
test: uv run pytest -m smoketest tests/smoketests/examples/
2222
---
2323
"""
@@ -29,7 +29,7 @@
2929
from runloop_api_client import RunloopSDK
3030
from runloop_api_client.lib.polling import PollingConfig
3131

32-
from .types import ExampleCheck, RecipeOutput, RecipeContext
32+
from .example_types import ExampleCheck, RecipeOutput, RecipeContext
3333
from ._harness import run_as_cli, wrap_recipe
3434

3535

examples/mcp_github_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- RUNLOOP_API_KEY
2222
- GITHUB_TOKEN (GitHub PAT with repo scope)
2323
- ANTHROPIC_API_KEY
24-
run: GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx uv run examples/mcp_github_tools.py
24+
run: GITHUB_TOKEN=ghp_xxx ANTHROPIC_API_KEY=sk-ant-xxx uv run python -m examples.mcp_github_tools
2525
test: uv run pytest -m smoketest tests/smoketests/examples/
2626
---
2727
"""
@@ -34,7 +34,7 @@
3434

3535
from runloop_api_client import RunloopSDK
3636

37-
from .types import ExampleCheck, RecipeOutput, RecipeContext
37+
from .example_types import ExampleCheck, RecipeOutput, RecipeContext
3838
from ._harness import run_as_cli, wrap_recipe_with_options
3939

4040

examples/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from typing import Any, Callable, cast
99

10-
from .types import ExampleResult
10+
from .example_types import ExampleResult
1111
from .mcp_github_tools import run_mcp_github_tools_example
1212
from .devbox_from_blueprint_lifecycle import run_devbox_from_blueprint_lifecycle_example
1313

llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- Execute commands with `await devbox.cmd.exec('command')`, not raw API calls
2727
- Always call `await devbox.shutdown()` to clean up resources (or use context manager)
2828
- Streaming callbacks (`stdout`, `stderr`) must be synchronous functions even with async SDK
29-
- In example files, focus on the `recipe` function body for SDK usage patterns; ignore test harness files (`_harness.py`, `registry.py`, `types.py`)
29+
- In example files, focus on the `recipe` function body for SDK usage patterns; ignore test harness files (`_harness.py`, `registry.py`, `example_types.py`)
3030

3131
## Async vs Sync
3232

scripts/generate_examples_md.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
LLMS_FILE = ROOT / "llms.txt"
2424

2525
REQUIRED_FIELDS = ["title", "slug", "use_case", "workflow", "tags", "prerequisites", "run", "test"]
26-
EXCLUDED_FILES = {"_harness.py", "types.py", "registry.py", "__init__.py"}
26+
EXCLUDED_FILES = {"_harness.py", "example_types.py", "registry.py", "__init__.py"}
2727

2828

2929
def parse_example(path: Path) -> dict[str, Any]:
@@ -64,8 +64,9 @@ def validate_example(metadata: dict[str, Any], file_name: str, seen_slugs: set[s
6464
raise ValueError(f"{path}: duplicate slug")
6565
seen_slugs.add(slug)
6666

67-
if f"examples/{file_name}" not in metadata["run"]:
68-
raise ValueError(f"{path}: run command must reference the file")
67+
module_name = file_name.replace(".py", "")
68+
if f"examples.{module_name}" not in metadata["run"]:
69+
raise ValueError(f"{path}: run command must reference 'examples.{module_name}'")
6970

7071

7172
def ensure_llms_references(examples: list[dict[str, Any]]) -> None:
@@ -180,7 +181,7 @@ def generate_registry(examples: list[dict[str, Any]]) -> str:
180181
181182
from typing import Any, Callable, cast
182183
183-
from .types import ExampleResult
184+
from .example_types import ExampleResult
184185
{chr(10).join(imports)}
185186
186187
ExampleRegistryEntry = dict[str, Any]

tests/smoketests/examples/test_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# Add the root directory to the path so we can import examples
1717
sys.path.insert(0, str(Path(__file__).parents[3]))
1818

19-
from examples.types import ExampleResult # noqa: E402
2019
from examples.registry import example_registry # noqa: E402
20+
from examples.example_types import ExampleResult # noqa: E402
2121
from examples.mcp_github_tools import McpExampleOptions, run_mcp_github_tools_example # noqa: E402
2222

2323
LONG_TIMEOUT = 600 # 10 minutes for live tests

0 commit comments

Comments
 (0)