-
Notifications
You must be signed in to change notification settings - Fork 83
feat(deployment): Add --setup-only flag to start-clp.sh to set up the package without starting components (resolves #1475).
#1502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
218d32e
e2772c4
e732f78
83d2d80
70b2b14
3f9fcc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -87,22 +87,22 @@ def __init__(self, clp_config: CLPConfig) -> None: | |||||
| self._conf_dir = self._clp_home / "etc" | ||||||
|
|
||||||
| @abstractmethod | ||||||
| def start(self) -> None: | ||||||
| def set_up_env(self) -> None: | ||||||
| """ | ||||||
| Starts the components. | ||||||
| Sets up all components to run by preparing environment variables, directories, and | ||||||
| configuration files. | ||||||
| """ | ||||||
|
|
||||||
| @abstractmethod | ||||||
| def stop(self) -> None: | ||||||
| def start(self) -> None: | ||||||
| """ | ||||||
| Stops the components. | ||||||
| Starts the components. | ||||||
| """ | ||||||
|
|
||||||
| @abstractmethod | ||||||
| def _set_up_env(self) -> None: | ||||||
| def stop(self) -> None: | ||||||
| """ | ||||||
| Sets up all components to run by preparing environment variables, directories, and | ||||||
| configuration files. | ||||||
| Stops the components. | ||||||
| """ | ||||||
|
|
||||||
| def _set_up_env_for_database(self) -> EnvVarsDict: | ||||||
|
|
@@ -642,75 +642,7 @@ def __init__(self, clp_config: CLPConfig, instance_id: str) -> None: | |||||
| self._project_name = f"clp-package-{instance_id}" | ||||||
| super().__init__(clp_config) | ||||||
|
|
||||||
| def start(self) -> None: | ||||||
| """ | ||||||
| Starts CLP's components using Docker Compose. | ||||||
|
|
||||||
| :raise: Propagates `check_docker_dependencies`'s exceptions. | ||||||
| :raise: Propagates `subprocess.run`'s exceptions. | ||||||
| """ | ||||||
| check_docker_dependencies( | ||||||
| should_compose_project_be_running=False, project_name=self._project_name | ||||||
| ) | ||||||
| self._set_up_env() | ||||||
|
|
||||||
| deployment_type = self._clp_config.get_deployment_type() | ||||||
| logger.info(f"Starting CLP using Docker Compose ({deployment_type} deployment)...") | ||||||
|
|
||||||
| cmd = ["docker", "compose", "--project-name", self._project_name] | ||||||
| if deployment_type == DeploymentType.BASE: | ||||||
| cmd += ["--file", "docker-compose.base.yaml"] | ||||||
| if self._clp_config.mcp_server is not None: | ||||||
| cmd += ["--profile", "mcp"] | ||||||
| cmd += ["up", "--detach", "--wait"] | ||||||
| subprocess.run( | ||||||
| cmd, | ||||||
| cwd=self._clp_home, | ||||||
| check=True, | ||||||
| ) | ||||||
| logger.info("Started CLP.") | ||||||
|
|
||||||
| def stop(self) -> None: | ||||||
| """ | ||||||
| Stops CLP components deployed via Docker Compose. | ||||||
|
|
||||||
| :raise: Propagates `subprocess.run`'s exceptions. | ||||||
| """ | ||||||
| try: | ||||||
| check_docker_dependencies( | ||||||
| should_compose_project_be_running=True, project_name=self._project_name | ||||||
| ) | ||||||
| except DockerComposeProjectNotRunningError: | ||||||
| logger.info( | ||||||
| "Docker Compose project '%s' is not running. Nothing to stop.", | ||||||
| self._project_name, | ||||||
| ) | ||||||
| return | ||||||
| except DockerDependencyError as e: | ||||||
| logger.warning( | ||||||
| 'Docker dependencies check failed: "%s". Attempting to stop CLP containers ' | ||||||
| "anyway...", | ||||||
| e, | ||||||
| ) | ||||||
| else: | ||||||
| logger.info("Stopping all CLP containers using Docker Compose...") | ||||||
|
|
||||||
| subprocess.run( | ||||||
| ["docker", "compose", "--project-name", self._project_name, "down"], | ||||||
| cwd=self._clp_home, | ||||||
| check=True, | ||||||
| ) | ||||||
| logger.info("Stopped CLP.") | ||||||
|
|
||||||
| @staticmethod | ||||||
| def _get_num_workers() -> int: | ||||||
| """ | ||||||
| :return: Number of worker processes to run. | ||||||
| """ | ||||||
| # This will change when we move from single to multi-container workers. See y-scope/clp#1424 | ||||||
| return multiprocessing.cpu_count() // 2 | ||||||
|
|
||||||
| def _set_up_env(self) -> None: | ||||||
| def set_up_env(self) -> None: | ||||||
| # Generate container-specific config. | ||||||
| container_clp_config = generate_docker_compose_container_config(self._clp_config) | ||||||
| num_workers = self._get_num_workers() | ||||||
|
|
@@ -796,6 +728,73 @@ def _set_up_env(self) -> None: | |||||
| continue | ||||||
| env_file.write(f"{key}={value}\n") | ||||||
|
|
||||||
| def start(self) -> None: | ||||||
| """ | ||||||
| Starts CLP's components using Docker Compose. | ||||||
|
|
||||||
| :raise: Propagates `check_docker_dependencies`'s exceptions. | ||||||
| :raise: Propagates `subprocess.run`'s exceptions. | ||||||
| """ | ||||||
| check_docker_dependencies( | ||||||
| should_compose_project_be_running=False, project_name=self._project_name | ||||||
| ) | ||||||
|
|
||||||
| deployment_type = self._clp_config.get_deployment_type() | ||||||
| logger.info(f"Starting CLP using Docker Compose ({deployment_type} deployment)...") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Parameterise logs instead of f‑strings. Satisfies Ruff G004 and avoids interpolation when log level is higher. Apply: - logger.info(f"Starting CLP using Docker Compose ({deployment_type} deployment)...")
+ logger.info("Starting CLP using Docker Compose (%s deployment)...", deployment_type)📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.1)743-743: Logging statement uses f-string (G004) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| cmd = ["docker", "compose", "--project-name", self._project_name] | ||||||
| if deployment_type == DeploymentType.BASE: | ||||||
| cmd += ["--file", "docker-compose.base.yaml"] | ||||||
| if self._clp_config.mcp_server is not None: | ||||||
| cmd += ["--profile", "mcp"] | ||||||
| cmd += ["up", "--detach", "--wait"] | ||||||
| subprocess.run( | ||||||
| cmd, | ||||||
| cwd=self._clp_home, | ||||||
| check=True, | ||||||
| ) | ||||||
| logger.info("Started CLP.") | ||||||
|
|
||||||
| def stop(self) -> None: | ||||||
| """ | ||||||
| Stops CLP components deployed via Docker Compose. | ||||||
|
|
||||||
| :raise: Propagates `subprocess.run`'s exceptions. | ||||||
| """ | ||||||
| try: | ||||||
| check_docker_dependencies( | ||||||
| should_compose_project_be_running=True, project_name=self._project_name | ||||||
| ) | ||||||
| except DockerComposeProjectNotRunningError: | ||||||
| logger.info( | ||||||
| "Docker Compose project '%s' is not running. Nothing to stop.", | ||||||
| self._project_name, | ||||||
| ) | ||||||
| return | ||||||
| except DockerDependencyError as e: | ||||||
| logger.warning( | ||||||
| 'Docker dependencies check failed: "%s". Attempting to stop CLP containers ' | ||||||
| "anyway...", | ||||||
| e, | ||||||
| ) | ||||||
| else: | ||||||
| logger.info("Stopping all CLP containers using Docker Compose...") | ||||||
|
|
||||||
| subprocess.run( | ||||||
| ["docker", "compose", "--project-name", self._project_name, "down"], | ||||||
| cwd=self._clp_home, | ||||||
| check=True, | ||||||
| ) | ||||||
| logger.info("Stopped CLP.") | ||||||
|
|
||||||
| @staticmethod | ||||||
| def _get_num_workers() -> int: | ||||||
| """ | ||||||
| :return: Number of worker processes to run. | ||||||
| """ | ||||||
| # This will change when we move from single to multi-container workers. See y-scope/clp#1424 | ||||||
| return multiprocessing.cpu_count() // 2 | ||||||
|
|
||||||
|
Comment on lines
+791
to
+797
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Ensure at least one worker on single‑CPU hosts.
Apply: - return multiprocessing.cpu_count() // 2
+ return max(1, multiprocessing.cpu_count() // 2)🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you're right. let's create an issue and fix in another PR
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @junhaoliao, would you like me to create a GitHub issue to track this fix? I can include the relevant context about ensuring at least one worker on single-CPU hosts.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes please
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 42 @junhaoliao, I've created issue #1509 to track this fix. The issue includes:
🧬 Code Graph Analysis Results[Relevant code snippets that could help understand the file and user comment]
|
||||||
|
|
||||||
| def get_or_create_instance_id(clp_config: CLPConfig) -> str: | ||||||
| """ | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactor made
set_up_env()public butDockerComposeController.start()no longer calls it. The normal CLI path instart_clp.pyonly invokescontroller.start()unless--setup-onlyis passed, so a defaultsbin/start-clp.shrun never writes the.envfile or prepares per-component directories. Docker Compose will therefore launch with unset credentials and paths, causing startup to fail on a clean install.start()should still invokeset_up_env()when not in setup-only mode.Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codex good point - i forgot to move
controller.set_up_env()outside theif parsed_args.setup_only:block. Could you help me move the call so it appears right before theif parsed_args.setup_only:check?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems i have too much stuff running on codex at the moment. i'll do the change on my own then