Skip to content

Commit 3e06c09

Browse files
committed
reviews
1 parent 57bf15f commit 3e06c09

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

scripts/maintenance/computational-clusters/autoscaled_monitor/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import os
23
from pathlib import Path
34
from typing import Annotated, Optional
45

@@ -40,7 +41,7 @@ def _parse_repo_config(deploy_config: Path) -> dict[str, str | None]:
4041
rich.print(
4142
f"[red]{repo_config} does not exist! Please run `make repo.config` in {deploy_config} to generate it[/red]"
4243
)
43-
raise typer.Exit(1)
44+
raise typer.Exit(os.EX_DATAERR)
4445

4546
environment = dotenv_values(repo_config)
4647

@@ -54,7 +55,7 @@ def _parse_inventory(deploy_config: Path) -> BastionHost:
5455
rich.print(
5556
f"[red]{inventory_path} does not exist! Please run `make inventory` in {deploy_config} to generate it[/red]"
5657
)
57-
raise typer.Exit(1)
58+
raise typer.Exit(os.EX_DATAERR)
5859

5960
loader = DataLoader()
6061
inventory = InventoryManager(loader=loader, sources=[f"{inventory_path}"])
@@ -65,8 +66,10 @@ def _parse_inventory(deploy_config: Path) -> BastionHost:
6566
user_name=inventory.groups["CAULDRON_UNIX"].get_vars()["bastion_user"],
6667
)
6768
except KeyError as err:
68-
msg = "Unable to find bastion_ip in the inventory file."
69-
raise RuntimeError(msg) from err
69+
rich.print(
70+
f"[red]{inventory_path} invalid! Unable to find bastion_ip in the inventory file. TIP: Please run `make inventory` in {deploy_config} to generate it[/red]"
71+
)
72+
raise typer.Exit(os.EX_DATAERR) from err
7073

7174

7275
@app.callback()
@@ -183,9 +186,9 @@ def trigger_cluster_termination(
183186

184187

185188
@app.command()
186-
def test_database_connection() -> None:
189+
def check_database_connection() -> None:
187190
"""this will check the connection to simcore database is ready"""
188-
asyncio.run(api.test_database_connection(state))
191+
asyncio.run(api.check_database_connection(state))
189192

190193

191194
if __name__ == "__main__":

scripts/maintenance/computational-clusters/autoscaled_monitor/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,5 +649,5 @@ async def trigger_cluster_termination(
649649
rich.print("not deleting anything")
650650

651651

652-
async def test_database_connection(state: AppState) -> None:
653-
await db.test_db_connection(state)
652+
async def check_database_connection(state: AppState) -> None:
653+
await db.check_db_connection(state)

scripts/maintenance/computational-clusters/autoscaled_monitor/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def abort_job_in_db(
8080
rich.print(f"set comp_tasks for {project_id=}/{node_id=} set to ABORTED")
8181

8282

83-
async def test_db_connection(state: AppState) -> bool:
83+
async def check_db_connection(state: AppState) -> bool:
8484
try:
8585
async with contextlib.AsyncExitStack() as stack:
8686
engine = await stack.enter_async_context(db_engine(state))

0 commit comments

Comments
 (0)