Skip to content

Commit a97a197

Browse files
committed
fix: fix bug when bbdev used in buckyball
1 parent 48cfefb commit a97a197

File tree

10 files changed

+1603
-409
lines changed

10 files changed

+1603
-409
lines changed

api/motia.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from '@motiadev/core'
2+
import endpointPlugin from '@motiadev/plugin-endpoint/plugin'
3+
import logsPlugin from '@motiadev/plugin-logs/plugin'
4+
import observabilityPlugin from '@motiadev/plugin-observability/plugin'
5+
import statesPlugin from '@motiadev/plugin-states/plugin'
6+
import bullmqPlugin from '@motiadev/plugin-bullmq/plugin'
7+
8+
export default defineConfig({
9+
plugins: [observabilityPlugin, statesPlugin, endpointPlugin, logsPlugin, bullmqPlugin],
10+
})

api/package.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
"start": "motia start",
1111
"clean": "rm -rf dist node_modules python_modules .motia .mermaid"
1212
},
13-
"keywords": ["motia"],
13+
"keywords": [
14+
"motia"
15+
],
1416
"dependencies": {
15-
"motia": "0.8.2-beta.139",
16-
"zod": "^3.24.4"
17+
"motia": "0.17.14-beta.196",
18+
"zod": "^3.24.4",
19+
"@motiadev/core": "0.17.14-beta.196",
20+
"@motiadev/plugin-logs": "0.17.14-beta.196",
21+
"@motiadev/plugin-states": "0.17.14-beta.196",
22+
"@motiadev/plugin-endpoint": "0.17.14-beta.196",
23+
"@motiadev/plugin-observability": "0.17.14-beta.196",
24+
"@motiadev/plugin-bullmq": "0.17.14-beta.196",
25+
"@motiadev/plugin-streams": "0.17.14-beta.196",
26+
"@motiadev/plugin-cron": "0.17.14-beta.196",
27+
"@motiadev/plugin-ws": "0.17.14-beta.196"
1728
}
1829
}

api/pnpm-lock.yaml

Lines changed: 1511 additions & 387 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/steps/sardine/01_run_event_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def handler(data, context):
2929

3030
sardine_dir = f"{bbdir}/bb-tests/sardine"
3131

32-
command = f"python run_tests.py --allure -m \"({data.get('workload', '')})\""
32+
command = f"python3 run_tests.py --allure -m \"({data.get('workload', '')})\""
3333
context.logger.info(
3434
"Executing sardine command", {"command": command, "cwd": sardine_dir}
3535
)

api/steps/verilator/03_build_event_step.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ async def handler(data, context):
6767
cflags += " -DCOSIM"
6868
ldflags = (
6969
f"-lreadline -ldramsim -lfesvr -lstdc++ "
70+
f"-L{bebop_isa_sim}/install/lib "
71+
f"-L{bbdir}/result/lib "
7072
f"-L{arch_dir}/thirdparty/chipyard/tools/DRAMSim2 "
7173
f"-L{arch_dir}/thirdparty/chipyard/toolchains/riscv-tools/riscv-isa-sim/build "
72-
f"-L{arch_dir}/thirdparty/chipyard/toolchains/riscv-tools/riscv-isa-sim/build/lib "
73-
f"-L{bebop_isa_sim}/install/lib"
74+
f"-L{arch_dir}/thirdparty/chipyard/toolchains/riscv-tools/riscv-isa-sim/build/lib"
7475
)
7576

7677
obj_dir = f"{build_dir}/obj_dir"

api/steps/verilator/04_cosim_event_step.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ async def handler(data, context):
6767
# ==================================================================================
6868
# Execute simulation script with streaming output
6969
# ==================================================================================
70-
# batch_param = "True" if batch else "False"
71-
# sim_cmd = f"./scripts/sim.sh {bin_path} {binary_path} {log_dir}/stdout.log \
72-
# {log_dir}/disasm.log {batch_param} {vcd_path} {log_path}"
70+
bebop_isa_sim = f"{bbdir}/bebop/host/spike/riscv-isa-sim"
71+
ld_lib_path = (
72+
f"{bebop_isa_sim}/install/lib:"
73+
f"{bbdir}/result/lib:"
74+
f"{arch_dir}/thirdparty/chipyard/tools/DRAMSim2"
75+
)
7376
sim_cmd = (
77+
f"export LD_LIBRARY_PATH=\"{ld_lib_path}:$LD_LIBRARY_PATH\"; "
7478
f"{bin_path} +permissive +loadmem={binary_path} +loadmem_addr=800000000 "
7579
f"{'+batch ' if batch else ''} "
7680
f"+fst={fst_path} +log={log_path} +permissive-off "

api/steps/verilator/04_sim_event_step.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ async def handler(data, context):
6767
# ==================================================================================
6868
# Execute simulation script with streaming output
6969
# ==================================================================================
70-
# batch_param = "True" if batch else "False"
71-
# sim_cmd = f"./scripts/sim.sh {bin_path} {binary_path} {log_dir}/stdout.log \
72-
# {log_dir}/disasm.log {batch_param} {vcd_path} {log_path}"
70+
bebop_isa_sim = f"{bbdir}/bebop/host/spike/riscv-isa-sim"
71+
ld_lib_path = (
72+
f"{bebop_isa_sim}/install/lib:"
73+
f"{bbdir}/result/lib:"
74+
f"{arch_dir}/thirdparty/chipyard/tools/DRAMSim2"
75+
)
7376
sim_cmd = (
77+
f"export LD_LIBRARY_PATH=\"{ld_lib_path}:$LD_LIBRARY_PATH\"; "
7478
f"{bin_path} +permissive +loadmem={binary_path} +loadmem_addr=800000000 "
7579
f"{'+batch ' if batch else ''} "
7680
f"+fst={fst_path} +log={log_path} +permissive-off "

api/utils/path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
def get_buckyball_path():
55
current_dir = os.path.dirname(__file__)
6-
return os.path.dirname(os.path.dirname(current_dir))
6+
# bbdev/api/utils -> bbdev/api -> bbdev -> buckyball
7+
return os.path.dirname(os.path.dirname(os.path.dirname(current_dir)))

bbdev

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,41 @@ if __name__ == "__main__":
449449
available_port = find_available_port(start_port=5100, end_port=5500)
450450
print(f"Starting server on port {available_port}...")
451451
proc = subprocess.Popen(
452-
["pnpm", "dev", "--port", str(available_port)], cwd=workflow_dir
452+
["pnpm", "dev", "--port", str(available_port)],
453+
cwd=workflow_dir,
454+
start_new_session=True,
455+
stdout=subprocess.PIPE,
456+
stderr=subprocess.PIPE,
453457
)
454458

459+
# Forward stdout/stderr in background threads; stopped before
460+
# shutdown to suppress BullMQ teardown errors and pnpm's
461+
# ELIFECYCLE message (Motia framework limitation).
462+
import threading
463+
464+
output_active = threading.Event()
465+
output_active.set()
466+
467+
def forward_stream(stream, dest):
468+
for line in iter(stream.readline, b""):
469+
if not output_active.is_set():
470+
break
471+
dest.write(line)
472+
dest.flush()
473+
474+
threading.Thread(
475+
target=forward_stream,
476+
args=(proc.stdout, sys.stdout.buffer),
477+
daemon=True,
478+
).start()
479+
threading.Thread(
480+
target=forward_stream,
481+
args=(proc.stderr, sys.stderr.buffer),
482+
daemon=True,
483+
).start()
484+
455485
# Wait for service to start
456-
max_retries = 30
486+
max_retries = 600
457487
for i in range(max_retries):
458488
try:
459489
# Disable proxy, connect directly to localhost
@@ -506,10 +536,22 @@ if __name__ == "__main__":
506536
)
507537

508538
# 3. Shutdown service ================================
509-
# Give observability plugin time to finish async operations (e.g., Redis writes)
539+
output_active.clear()
540+
import signal
541+
510542
time.sleep(1)
511-
proc.terminate()
512-
proc.wait()
543+
try:
544+
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
545+
except ProcessLookupError:
546+
pass
547+
try:
548+
proc.wait(timeout=10)
549+
except subprocess.TimeoutExpired:
550+
try:
551+
os.killpg(os.getpgid(proc.pid), signal.SIGKILL)
552+
except ProcessLookupError:
553+
pass
554+
proc.wait()
513555
print(
514556
f"\nTask completed. Command running on http://localhost:{available_port} is finished"
515557
)

flake.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@
2929

3030
shellHook = ''
3131
export PATH="$PWD:$PATH"
32+
source "$PWD/init.sh"
3233
3334
echo "bbdev dev environment ready"
3435
echo " Node.js: $(node --version)"
3536
echo " Python: $(python3 --version)"
3637
echo " pnpm: $(pnpm --version)"
3738
echo " bbdev: $(which bbdev)"
38-
echo ""
39-
echo "Quick start:"
40-
echo " pnpm install # install node deps + motia install"
41-
echo " pnpm dev # start motia dev server"
4239
'';
4340
};
4441
}

0 commit comments

Comments
 (0)