MCPcopy Create free account
hub / github.com/openai/openai-agents-python / _ensure_container

Function _ensure_container

examples/memory/dapr_session_example.py:462–479  ·  view source on GitHub ↗
(name: str, run_args: list[str])

Source from the content-addressed store, hash-verified

460
461
462def _ensure_container(name: str, run_args: list[str]) -> None:
463 if not _docker_available():
464 raise SystemExit(
465 "Docker is required to automatically start containers for '"
466 + name
467 + "'.\nInstall Docker: https://docs.docker.com/get-docker/\n"
468 + "Alternatively, start the container manually and re-run with --setup-env."
469 )
470 status = _container_running(name)
471 if status is True:
472 print(f"Container '{name}' already running.")
473 return
474 if status is False:
475 subprocess.run(["docker", "start", name], check=False)
476 print(f"Started existing container '{name}'.")
477 return
478 subprocess.run(["docker", "run", "-d", "--name", name, *run_args], check=False)
479 print(f"Created and started container '{name}'.")
480
481
482def setup_environment(components_dir: str = "./components", overwrite: bool = False) -> None:

Callers 1

setup_environmentFunction · 0.85

Calls 3

_docker_availableFunction · 0.85
_container_runningFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected