-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add init command * move local init * refactor command * add db init * add exceptions in other cmds * fix cli tests * add init local test * update README files * update docs
- Loading branch information
Showing
16 changed files
with
401 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import typing | ||
|
||
from ..models import Context | ||
from .util import init_db_auditor | ||
from .util import init_db_catalog | ||
from .util import init_local_activity | ||
from .util import init_local_catalog | ||
from agentc_core.util.models import CouchbaseConnect | ||
from agentc_core.util.models import Keyspace | ||
from agentc_core.util.publish import get_connection | ||
|
||
func_mappings = {"local": {"catalog": init_local_catalog, "auditor": init_local_activity}} | ||
|
||
|
||
def cmd_init( | ||
ctx: Context, | ||
catalog_type: typing.List[typing.Literal["catalog", "auditor"]], | ||
type_metadata: typing.List[typing.Literal["catalog", "auditor"]], | ||
connection_details_env: typing.Optional[CouchbaseConnect] = None, | ||
keyspace_details: typing.Optional[Keyspace] = None, | ||
): | ||
if ctx is None: | ||
ctx = Context() | ||
initialize_local = "local" in catalog_type | ||
initialize_db = "db" in catalog_type | ||
initialize_catalog = "catalog" in type_metadata | ||
initialize_auditor = "auditor" in type_metadata | ||
|
||
if initialize_local: | ||
if initialize_catalog: | ||
init_local_catalog(ctx) | ||
if initialize_auditor: | ||
init_local_activity(ctx) | ||
|
||
if initialize_db: | ||
# Get bucket ref | ||
err, cluster = get_connection(conn=connection_details_env) | ||
if err: | ||
raise ValueError(f"Unable to connect to Couchbase!\n{err}") | ||
|
||
if initialize_catalog: | ||
init_db_catalog(ctx, cluster, keyspace_details, connection_details_env) | ||
|
||
if initialize_auditor: | ||
init_db_auditor(ctx, cluster, keyspace_details) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.