Skip to content

Commit 09b1e16

Browse files
committed
update: bbdev Motia v0.17.x to 1.0-RC Migration
1 parent 61bcffd commit 09b1e16

37 files changed

+407
-7346
lines changed

api/config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
modules:
2+
# ── State Module ───────────────────────────────────────────────────────
3+
- class: modules::state::StateModule
4+
config:
5+
adapter:
6+
class: modules::state::adapters::KvStore
7+
config:
8+
store_method: file_based
9+
file_path: ./data/state_store.db
10+
11+
# ── REST API Module ────────────────────────────────────────────────────
12+
- class: modules::api::RestApiModule
13+
config:
14+
port: 3111
15+
host: 0.0.0.0
16+
default_timeout: 30000
17+
concurrency_request_limit: 1024
18+
cors:
19+
allowed_origins:
20+
- http://localhost:3000
21+
- http://localhost:5173
22+
allowed_methods:
23+
- GET
24+
- POST
25+
- PUT
26+
- DELETE
27+
- OPTIONS
28+
29+
# ── Queue Module ───────────────────────────────────────────────────────
30+
- class: modules::queue::QueueModule
31+
config:
32+
adapter:
33+
class: modules::queue::BuiltinQueueAdapter
34+
35+
# ── PubSub Module ──────────────────────────────────────────────────────
36+
- class: modules::pubsub::PubSubModule
37+
config:
38+
adapter:
39+
class: modules::pubsub::LocalAdapter
40+
41+
# ── Exec Module (Python) ───────────────────────────────────────────────
42+
- class: modules::shell::ExecModule
43+
config:
44+
watch:
45+
- steps/**/*.py
46+
exec:
47+
- motia dev --dir steps

api/motia.config.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

api/package.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

api/pnpm-lock.yaml

Lines changed: 0 additions & 6913 deletions
This file was deleted.

api/pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

api/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "bbdev"
3+
version = "0.1.0"
4+
description = "Agent-friendly developer toolchain backend powered by Motia"
5+
requires-python = ">=3.10"
6+
dependencies = [
7+
"motia[otel]==1.0.0rc17",
8+
"iii-sdk==0.2.0",
9+
"pydantic>=2.0",
10+
]
11+
12+
[project.optional-dependencies]
13+
dev = ["pytest>=8.0.0"]
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import asyncio
2+
3+
from motia import ApiRequest, ApiResponse, FlowContext, http
4+
25
from utils.event_common import wait_for_result
36

47
config = {
5-
"type": "api",
68
"name": "Build Compiler",
79
"description": "build bitstream",
8-
"path": "/compiler/build",
9-
"method": "POST",
10-
"emits": ["compiler.build"],
1110
"flows": ["compiler"],
11+
"triggers": [http("POST", "/compiler/build")],
12+
"enqueues": ["compiler.build"],
1213
}
1314

1415

15-
async def handler(req, context):
16-
body = req.get("body") or {}
17-
await context.emit({"topic": "compiler.build", "data": body})
16+
async def handler(request: ApiRequest, ctx: FlowContext) -> ApiResponse:
17+
body = request.body or {}
18+
await ctx.enqueue({"topic": "compiler.build", "data": body})
1819

1920
# ==================================================================================
2021
# Wait for build result
2122
# ==================================================================================
2223
while True:
23-
result = await wait_for_result(context)
24+
result = await wait_for_result(ctx)
2425
if result is not None:
2526
return result
2627
await asyncio.sleep(1)

api/steps/compiler/01_build_event_step.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
2-
import subprocess
32
import sys
43

4+
from motia import FlowContext, queue
5+
56
# Add the utils directory to the Python path
67
utils_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
78
if utils_path not in sys.path:
@@ -12,16 +13,15 @@
1213
from utils.event_common import check_result
1314

1415
config = {
15-
"type": "event",
1616
"name": "Build Compiler",
1717
"description": "build bitstream",
18-
"subscribes": ["compiler.build"],
19-
"emits": [],
2018
"flows": ["compiler"],
19+
"triggers": [queue("compiler.build")],
20+
"enqueues": [],
2121
}
2222

2323

24-
async def handler(data, context):
24+
async def handler(input_data: dict, ctx: FlowContext) -> None:
2525
bbdir = get_buckyball_path()
2626
script_dir = f"{bbdir}/workflow/steps/compiler/scripts"
2727
yaml_dir = f"{script_dir}/yaml"
@@ -31,14 +31,14 @@ async def handler(data, context):
3131
command = f"mkdir -p {bbdir}/compiler/build"
3232
result = stream_run_logger(
3333
cmd=command,
34-
logger=context.logger,
34+
logger=ctx.logger,
3535
stdout_prefix="compiler build",
3636
stderr_prefix="compiler build",
3737
)
3838
command = f"cd {bbdir}/compiler/build && ninja -j{os.cpu_count()}"
3939
result = stream_run_logger(
4040
cmd=command,
41-
logger=context.logger,
41+
logger=ctx.logger,
4242
stdout_prefix="compiler build",
4343
stderr_prefix="compiler build",
4444
)
@@ -47,7 +47,7 @@ async def handler(data, context):
4747
# Return result to API
4848
# ==================================================================================
4949
success_result, failure_result = await check_result(
50-
context, result.returncode, continue_run=False
50+
ctx, result.returncode, continue_run=False
5151
)
5252

5353
# ==================================================================================
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import asyncio
2+
3+
from motia import ApiRequest, ApiResponse, FlowContext, http
4+
25
from utils.event_common import wait_for_result
36

47
config = {
5-
"type": "api",
68
"name": "Firesim Buildbitstream",
79
"description": "build bitstream",
8-
"path": "/firesim/buildbitstream",
9-
"method": "POST",
10-
"emits": ["firesim.buildbitstream"],
1110
"flows": ["firesim"],
11+
"triggers": [http("POST", "/firesim/buildbitstream")],
12+
"enqueues": ["firesim.buildbitstream"],
1213
}
1314

1415

15-
async def handler(req, context):
16-
body = req.get("body") or {}
17-
await context.emit({"topic": "firesim.buildbitstream", "data": body})
16+
async def handler(request: ApiRequest, ctx: FlowContext) -> ApiResponse:
17+
body = request.body or {}
18+
await ctx.enqueue({"topic": "firesim.buildbitstream", "data": body})
1819

1920
# ==================================================================================
2021
# Wait for simulation result
2122
# ==================================================================================
2223
while True:
23-
result = await wait_for_result(context)
24+
result = await wait_for_result(ctx)
2425
if result is not None:
2526
return result
2627
await asyncio.sleep(1)

api/steps/firesim/01_buildbitstream_event_step.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
2-
import subprocess
32
import sys
43

4+
from motia import FlowContext, queue
5+
56
# Add the utils directory to the Python path
67
utils_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
78
if utils_path not in sys.path:
@@ -12,16 +13,15 @@
1213
from utils.event_common import check_result
1314

1415
config = {
15-
"type": "event",
1616
"name": "Firesim Buildbitstream",
1717
"description": "build bitstream",
18-
"subscribes": ["firesim.buildbitstream"],
19-
"emits": [],
2018
"flows": ["firesim"],
19+
"triggers": [queue("firesim.buildbitstream")],
20+
"enqueues": [],
2121
}
2222

2323

24-
async def handler(data, context):
24+
async def handler(input_data: dict, ctx: FlowContext) -> None:
2525
bbdir = get_buckyball_path()
2626
script_dir = f"{bbdir}/workflow/steps/firesim/scripts"
2727
yaml_dir = f"{script_dir}/yaml"
@@ -35,7 +35,7 @@ async def handler(data, context):
3535
command += f" -c {yaml_dir}/config_runtime.yaml"
3636
result = stream_run_logger(
3737
cmd=command,
38-
logger=context.logger,
38+
logger=ctx.logger,
3939
stdout_prefix="firesim buildbitstream",
4040
stderr_prefix="firesim buildbitstream",
4141
)
@@ -44,7 +44,7 @@ async def handler(data, context):
4444
# Return result to API
4545
# ==================================================================================
4646
success_result, failure_result = await check_result(
47-
context, result.returncode, continue_run=False
47+
ctx, result.returncode, continue_run=False
4848
)
4949

5050
# ==================================================================================

0 commit comments

Comments
 (0)