(name: str, run_args: list[str])
| 460 | |
| 461 | |
| 462 | def _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 | |
| 482 | def setup_environment(components_dir: str = "./components", overwrite: bool = False) -> None: |
no test coverage detected