Skip to content

Commit

Permalink
das-toolbox-125: Group commands to dbms-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
levisingularity committed Nov 8, 2024
1 parent 5d12f56 commit 4c68c10
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 109 deletions.
3 changes: 0 additions & 3 deletions src/commands/das_peer/__init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions src/commands/dbms_adapter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .dbms_adapter_module import DbmsAdapterModule

__all__ = ["DbmsAdapterModule"]
3 changes: 3 additions & 0 deletions src/commands/dbms_adapter/das_peer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .das_peer_cli import DasPeerCli

__all__ = ["DasPeerCli"]
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ class DasPeerCli(CommandGroup):
short_help = "Manage DAS peer server operations."

help = """
'das-cli das-peer' commands provide control over the DAS peer server,
'das-cli dbms-adapter das-peer' commands provide control over the DAS peer server,
which acts as the main server in the DAS setup.
Using 'das-cli das-peer', you can start, stop, and restart the DAS peer
Using 'das-cli dbms-adapter das-peer', you can start, stop, and restart the DAS peer
server container as needed to manage its operations and connectivity.
"""

Expand Down
42 changes: 42 additions & 0 deletions src/commands/dbms_adapter/dbms_adapter_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from injector import inject

from common import CommandGroup
from .das_peer.das_peer_cli import DasPeerCli
from .dbms_peer.dbms_peer_cli import DbmsPeerCli


class DbmsAdapterCli(CommandGroup):
name = "dbms-adapter"

short_help = "Groups DBMS and DAS peer server commands for easier management."

help = """
The 'dbms-adapter' command group provides functionalities for managing both the DAS peer server
and DBMS peer client commands. It allows for organizing and executing operations related to
connecting a DBMS client to the DAS peer server.
This command group includes:
- 'das-peer': Manages DAS peer server operations.
- 'dbms-peer': Manages DBMS peer client operations.
.SH EXAMPLES
To view all commands available in the dbms-adapter group:
$ das-cli dbms-adapter --help
"""

@inject
def __init__(
self,
das_peer_cli: DasPeerCli,
dbms_peer: DbmsPeerCli,
) -> None:
super().__init__()
self.add_commands(
[
das_peer_cli.group,
dbms_peer.group,
]
)
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from common import Module

from .das_peer_cli import (
DasPeerCli,
DasPeerContainerManager,
Settings,
)
from .dbms_adapter_cli import DbmsAdapterCli
from common import Module, Settings

from .das_peer.das_peer_cli import DasPeerContainerManager
from .dbms_peer.dbms_peer_cli import DbmsPeerContainerManager

from commands.db.redis_container_manager import RedisContainerManager
from commands.db.mongodb_container_manager import MongodbContainerManager


class DasPeerModule(Module):
_instance = DasPeerCli
class DbmsAdapterModule(Module):
_instance = DbmsAdapterCli

def __init__(self) -> None:
super().__init__()
Expand All @@ -31,6 +31,10 @@ def __init__(self) -> None:
DasPeerContainerManager,
self._das_peer_container_manager_factory,
),
(
DbmsPeerContainerManager,
self._dbms_peer_container_manager_factory,
),
]

def _mongodb_container_manager_factory(self) -> MongodbContainerManager:
Expand Down Expand Up @@ -82,3 +86,10 @@ def _das_peer_container_manager_factory(self) -> DasPeerContainerManager:
"redis_port": redis_port,
},
)

def _dbms_peer_container_manager_factory(
self,
) -> DbmsPeerContainerManager:
container_name = self._settings.get("dbms_peer.container_name")

return DbmsPeerContainerManager(container_name)
3 changes: 3 additions & 0 deletions src/commands/dbms_adapter/dbms_peer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .dbms_peer_cli import DbmsPeerCli

__all__ = ["DbmsPeerCli"]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

from .dbms_peer_container_manager import DbmsPeerContainerManager

from commands.das_peer.das_peer_container_manager import DasPeerContainerManager
from commands.dbms_adapter.das_peer.das_peer_container_manager import (
DasPeerContainerManager,
)


class DbmsPeerRun(Command):
Expand All @@ -23,7 +25,7 @@ class DbmsPeerRun(Command):
short_help = "Runs the DBMS peer client to connect with DAS peer server."

help = """
'das-cli dbms-peer run' starts the DBMS peer client, enabling it to connect
'das-cli dbms-adapter dbms-peer run' starts the DBMS peer client, enabling it to connect
to the DAS peer server and facilitate data synchronization. This command
establishes a link to the DAS peer using the provided client database credentials
and settings.
Expand Down Expand Up @@ -58,7 +60,7 @@ class DbmsPeerRun(Command):
To run the DBMS peer client with specified database and context:
$ das-cli dbms-peer run --client-hostname example.com --client-port 5432 \\
$ das-cli dbms-adapter dbms-peer run --client-hostname example.com --client-port 5432 \\
--client-username user --client-password pass --context /path/to/context.json
"""

Expand All @@ -85,6 +87,8 @@ class DbmsPeerRun(Command):
["--client-password"],
help="The password for authenticating to the client database.",
type=str,
prompt=True,
hide_input=True,
required=True,
),
CommandOption(
Expand Down
3 changes: 0 additions & 3 deletions src/commands/dbms_peer/__init__.py

This file was deleted.

87 changes: 0 additions & 87 deletions src/commands/dbms_peer/dbms_peer_module.py

This file was deleted.

6 changes: 2 additions & 4 deletions src/das_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from commands.metta import MettaModule
from commands.python_library import PythonLibraryModule
from commands.release_notes import ReleaseNotesModule
from commands.das_peer import DasPeerModule
from commands.dbms_peer import DbmsPeerModule
from commands.dbms_adapter import DbmsAdapterModule

MODULES = [
ConfigModule,
Expand All @@ -23,8 +22,7 @@
MettaModule,
PythonLibraryModule,
ReleaseNotesModule,
DasPeerModule,
DbmsPeerModule,
DbmsAdapterModule,
]


Expand Down

0 comments on commit 4c68c10

Please sign in to comment.