MCPcopy
hub / github.com/IBM/AssetOpsBench / run_sdk_cli

Function run_sdk_cli

src/agent/_cli_common.py:130–155  ·  view source on GitHub ↗

Run the standard SDK-CLI lifecycle. Loads ``.env``, parses args with the caller's parser factory, configures stderr logging, initialises OTEL tracing under *service_name*, auto-fills ``args.run_id`` with a UUID4 when the user omitted ``--run-id``, seeds the ambient run context so th

(
    service_name: str,
    build_parser: Callable[[], argparse.ArgumentParser],
    run_coro: Callable[[argparse.Namespace], Awaitable[None]],
)

Source from the content-addressed store, hash-verified

128
129
130def run_sdk_cli(
131 service_name: str,
132 build_parser: Callable[[], argparse.ArgumentParser],
133 run_coro: Callable[[argparse.Namespace], Awaitable[None]],
134) -> None:
135 """Run the standard SDK-CLI lifecycle.
136
137 Loads ``.env``, parses args with the caller's parser factory, configures
138 stderr logging, initialises OTEL tracing under *service_name*, auto-fills
139 ``args.run_id`` with a UUID4 when the user omitted ``--run-id``, seeds
140 the ambient run context so the root span gets
141 ``agent.run_id`` / ``agent.scenario_id`` attributes, and runs *run_coro*
142 to completion via :func:`asyncio.run`.
143 """
144 from dotenv import load_dotenv
145
146 from observability import init_tracing, set_run_context
147
148 load_dotenv()
149 args = build_parser().parse_args()
150 setup_logging(args.verbose)
151 init_tracing(service_name)
152 if getattr(args, "run_id", None) is None:
153 args.run_id = str(uuid.uuid4())
154 set_run_context(run_id=args.run_id, scenario_id=getattr(args, "scenario_id", None))
155 asyncio.run(run_coro(args))

Callers 7

mainFunction · 0.90
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

init_tracingFunction · 0.90
set_run_contextFunction · 0.90
setup_loggingFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected