Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d02297b
Refactored and standardized stdout method parameters to always emit a…
levisingularity Aug 11, 2026
48c9d1c
Applying changes to STDOUT to all available commands.
levisingularity Aug 11, 2026
75ab839
Added treatment to PortBindingError exception.
levisingularity Aug 11, 2026
9dfb6b0
Added missing severity parameter
levisingularity Aug 11, 2026
2caef2e
Db command refactor
levisingularity Aug 11, 2026
ce5938d
Fixed remaining CLI commands.
levisingularity Aug 11, 2026
6672a20
disabled inference agent
levisingularity Aug 12, 2026
ac85e1a
added JSON support to metta_cli and config_cli. Small fix on db_cli
levisingularity Aug 12, 2026
e616750
WEB API changes:
levisingularity Aug 12, 2026
165a301
Front-end changes:
levisingularity Aug 12, 2026
2883a0a
Small final corrections on messages and exception handlers
levisingularity Aug 12, 2026
397fdfb
make lint
levisingularity Aug 12, 2026
4455a65
CodeRabbit fixes
levisingularity Aug 12, 2026
a08e88a
restore inference agent
levisingularity Aug 13, 2026
400c916
Resolving terminal exit code status 1
levisingularity Aug 13, 2026
2ba974c
make lint
levisingularity Aug 13, 2026
01a2142
Fix tests with new message standard
levisingularity Aug 13, 2026
5cffd2c
Fix inference agent setup.
levisingularity Aug 13, 2026
8b459fb
fix remote command stdout to avoid misleading messages.
levisingularity Aug 13, 2026
f6395c1
removed conditional status_code 127 validation
levisingularity Aug 13, 2026
5940757
added 'run_subcommand' method to avoid keeping the error flag inside …
levisingularity Aug 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 45 additions & 39 deletions das-cli/src/commands/atomdb_broker/atomdb_broker_cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from injector import inject

from common import Command, CommandGroup, CommandOption, Settings, StdoutSeverity, StdoutType
from common import Command, CommandGroup, CommandOption, Settings, StdoutSeverity
from common.container_manager.busnode_container_manager import BusNodeContainerManager
from common.decorators import ensure_container_running
from common.docker.exceptions import (
DockerContainerDuplicateError,
DockerContainerNotFoundError,
DockerError,
)
from common.exceptions import PortBindingError
from common.factory.atomdb.atomdb_backend import AtomdbBackend
from common.prompt_types import PortRangeType
from common.service_response import CONTAINER_START_FAILURE_MESSAGE, ServiceResponse, StdoutStatus

from .atomdb_broker_docs import (
HELP_ATOMDB_BROKER,
Expand All @@ -21,7 +23,8 @@
SHORT_HELP_START,
SHORT_HELP_STOP,
)
from .atomdb_broker_service_response import AtomDbBrokerServiceReponse

CLI_SERVICE_NAME = "atomdb_broker"


class AtomDbBrokerStart(Command):
Expand Down Expand Up @@ -59,46 +62,51 @@ def _start_container(self, port_range, **kwargs):
container = self._get_container()
port = container.port

self.stdout("Starting AtomDB Broker service...")
self.log("Starting AtomDB Broker service...", severity=StdoutSeverity.INFO)

try:
self._atomdb_broker_bus_manager.start_container(port_range, **kwargs)
message = f"AtomDB Broker started on port {port}"

self.stdout(message, severity=StdoutSeverity.SUCCESS)

self.stdout(
dict(
AtomDbBrokerServiceReponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status="success",
status=StdoutStatus.SUCCESS,
message=message,
container=self._get_container(),
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.SUCCESS,
)

except DockerContainerDuplicateError:
message = f"AtomDB Broker is already running. It's listening on port {port}"

self.stdout(message, severity=StdoutSeverity.WARNING)

self.stdout(
dict(
AtomDbBrokerServiceReponse(
action="start",
status="already_running",
message=message,
container=self._get_container(),
)
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status=StdoutStatus.INFO,
message=message,
container=self._get_container(),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.WARNING,
)

except DockerError as e:
error_message = f"Error occurred while trying to start Attention Broker on port {port}"
raise DockerError(f"{error_message}\nOriginal error: {e}")
except (DockerError, PortBindingError) as error:
self.stdout(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status=StdoutStatus.ERROR,
message=CONTAINER_START_FAILURE_MESSAGE,
error=error,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
container=self._get_container(),
),
severity=StdoutSeverity.ERROR,
)

@ensure_container_running(
[
Expand Down Expand Up @@ -132,42 +140,40 @@ def _get_container(self):
def _stop_container(self):
container = self._get_container()

self.stdout("Stopping AtomDB Broker service...")
self.log("Stopping AtomDB Broker service...", severity=StdoutSeverity.INFO)

try:
self._atomdb_broker_bus_manager.stop()
exec_message = "AtomDB Broker service stopped"

self.stdout(exec_message, severity=StdoutSeverity.SUCCESS)

self.stdout(
dict(
AtomDbBrokerServiceReponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="stop",
status="already_stopped",
status=StdoutStatus.SUCCESS,
message=exec_message,
container=container,
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.SUCCESS,
)
except DockerContainerNotFoundError:
container_name = self._get_container().name

message = f"The AtomDB Broker service named {container_name} is already stopped."

self.stdout(message, severity=StdoutSeverity.WARNING)

self.stdout(
dict(
AtomDbBrokerServiceReponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="stop",
status="already_stopped",
status=StdoutStatus.INFO,
message=message,
container=self._get_container(),
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.WARNING,
)

def run(self):
Expand All @@ -187,9 +193,9 @@ class AtomDbBrokerRestart(Command):
),
]

short_help = HELP_RESTART
short_help = SHORT_HELP_RESTART

help = SHORT_HELP_RESTART
help = HELP_RESTART

@inject
def __init__(
Expand All @@ -200,8 +206,8 @@ def __init__(
super().__init__()

def run(self, port_range, **kwargs):
self._atomdb_broker_stop.run()
self._atomdb_broker_start.run(port_range, **kwargs)
self.run_subcommand(self._atomdb_broker_stop)
self.run_subcommand(self._atomdb_broker_start, port_range, **kwargs)


class AtomDbBrokerCli(CommandGroup):
Expand Down

This file was deleted.

106 changes: 52 additions & 54 deletions das-cli/src/commands/attention_broker/attention_broker_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from injector import inject

from common import Command, CommandGroup, Settings, StdoutSeverity, StdoutType
from common import Command, CommandGroup, Settings, StdoutSeverity
from common.container_manager.agents.attention_broker_container_manager import (
AttentionBrokerManager,
)
Expand All @@ -9,6 +9,8 @@
DockerContainerNotFoundError,
DockerError,
)
from common.exceptions import PortBindingError
from common.service_response import CONTAINER_START_FAILURE_MESSAGE, ServiceResponse, StdoutStatus

from .attention_broker_docs import (
HELP_ATTENTION_BROKER,
Expand All @@ -20,7 +22,8 @@
SHORT_HELP_START,
SHORT_HELP_STOP,
)
from .attention_broker_service_response import AttentionBrokerServiceResponse

CLI_SERVICE_NAME = "attention_broker"


class AttentionBrokerStop(Command):
Expand All @@ -44,47 +47,40 @@ def _get_container(self):
return self._attention_broker_manager.get_container()

def _attention_broker(self):
self.log("Stopping Attention Broker service...", severity=StdoutSeverity.INFO)

try:
self.stdout("Stopping Attention Broker service...")
self._attention_broker_manager.stop()

success_message = "Attention Broker service stopped"
exec_message = "Attention Broker service stopped"

self.stdout(
success_message,
severity=StdoutSeverity.SUCCESS,
)
self.stdout(
dict(
AttentionBrokerServiceResponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="stop",
status="success",
message=success_message,
status=StdoutStatus.SUCCESS,
message=exec_message,
container=self._get_container(),
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.SUCCESS,
)

except DockerContainerNotFoundError:
container_name = self._attention_broker_manager.get_container().name
warning_message = (
f"The Attention Broker service named {container_name} is already stopped."
)
self.stdout(
warning_message,
severity=StdoutSeverity.WARNING,
)
message = f"The Attention Broker service named {container_name} is already stopped."

self.stdout(
dict(
AttentionBrokerServiceResponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="stop",
status="already_stopped",
message=warning_message,
status=StdoutStatus.INFO,
message=message,
container=self._get_container(),
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.WARNING,
)

def run(self):
Expand Down Expand Up @@ -113,52 +109,54 @@ def _get_container(self):
return self._attention_broker_container_manager.get_container()

def _attention_broker(self) -> None:
self.stdout("Starting Attention Broker service...")

container = self._attention_broker_container_manager.get_container()
port = container.port

self.log("Starting Attention Broker service...", severity=StdoutSeverity.INFO)

try:
self._attention_broker_container_manager.start_container()

success_message = f"Attention Broker started on port {port}"
message = f"Attention Broker started on port {port}"

self.stdout(
success_message,
severity=StdoutSeverity.SUCCESS,
)
self.stdout(
dict(
AttentionBrokerServiceResponse(
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status="success",
message=success_message,
status=StdoutStatus.SUCCESS,
message=message,
container=container,
)
),
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.SUCCESS,
)

except DockerContainerDuplicateError:
warning_message = f"Attention Broker is already running. It's listening on port {port}"
message = f"Attention Broker is already running. It's listening on port {port}"

self.stdout(
warning_message,
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status=StdoutStatus.INFO,
message=message,
container=container,
),
severity=StdoutSeverity.WARNING,
)

except (DockerError, PortBindingError) as e:
self.stdout(
dict(
AttentionBrokerServiceResponse(
action="start",
status="already_running",
message=warning_message,
container=container,
)
ServiceResponse(
service=CLI_SERVICE_NAME,
action="start",
status=StdoutStatus.ERROR,
message=CONTAINER_START_FAILURE_MESSAGE,
error=e,
container=container,
),
stdout_type=StdoutType.MACHINE_READABLE,
severity=StdoutSeverity.ERROR,
)
except DockerError as e:
error_message = f"Error occurred while trying to start Attention Broker on port {port}"
raise DockerError(f"{error_message}\nOriginal error: {e}")

def run(self):
self._settings.validate_configuration_file()
Expand All @@ -183,8 +181,8 @@ def __init__(
self._attention_broker_stop = attention_broker_stop

def run(self):
self._attention_broker_stop.run()
self._attention_broker_start.run()
self.run_subcommand(self._attention_broker_stop)
self.run_subcommand(self._attention_broker_start)


class AttentionBrokerCli(CommandGroup):
Expand Down
Loading
Loading