From e152840e5af0f30aca542284ac7a48323a7bd936 Mon Sep 17 00:00:00 2001 From: Nigel Jones Date: Fri, 31 Jan 2025 13:29:49 +0000 Subject: [PATCH 1/2] fix(cli): Package cli for execution in dependent projects Signed-off-by: Nigel Jones --- bee-hive/bee_hive/__init__.py | 7 ++++--- bee-hive/cli/beeAI.py | 15 ++++++++++----- bee-hive/cli/cli.py | 5 +---- bee-hive/cli/commands.py | 4 ++-- bee-hive/cli/common.py | 1 - bee-hive/pyproject.toml | 8 +++++++- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/bee-hive/bee_hive/__init__.py b/bee-hive/bee_hive/__init__.py index d7efe68..a8fb447 100644 --- a/bee-hive/bee_hive/__init__.py +++ b/bee-hive/bee_hive/__init__.py @@ -1,5 +1,6 @@ + __all__ = [ - "agent", - "workflow", - "interface", + "Agent", + "Workflow", + "Interface", ] diff --git a/bee-hive/cli/beeAI.py b/bee-hive/cli/beeAI.py index e9fd1fa..d09de06 100755 --- a/bee-hive/cli/beeAI.py +++ b/bee-hive/cli/beeAI.py @@ -32,21 +32,26 @@ -v --version Show version. """ -import os, sys, traceback +import sys from docopt import docopt +from cli.common import Console +from cli.cli import CLI -from cli import * - -if __name__ == '__main__': +def run_cli(): + """ + run CLI command + """ args = docopt(__doc__, version='beeAI CLI v0.0.1') command = CLI(args).command() try: rc = command.execute() if rc != 0: - Console.error("executing command: {rc}".format(rc=rc)) + Console.error(f"executing command: {rc}".format(rc=rc)) sys.exit(rc) except Exception as e: Console.error(str(e)) sys.exit(1) +if __name__ == '__main__': + run_cli() \ No newline at end of file diff --git a/bee-hive/cli/cli.py b/bee-hive/cli/cli.py index 1fd9397..ddc0baf 100644 --- a/bee-hive/cli/cli.py +++ b/bee-hive/cli/cli.py @@ -12,10 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import io, sys - -from commands import * -from common import * +from cli.commands import Validate class CLI: def __init__(self, args): diff --git a/bee-hive/cli/commands.py b/bee-hive/cli/commands.py index 566a062..4b5c2d5 100644 --- a/bee-hive/cli/commands.py +++ b/bee-hive/cli/commands.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import io, sys, yaml, json, jsonschema +import yaml, json, jsonschema from jsonschema.exceptions import ValidationError -from common import Console +from cli.common import Console # Base class for all commands class Command: diff --git a/bee-hive/cli/common.py b/bee-hive/cli/common.py index 3f32006..d11aec6 100644 --- a/bee-hive/cli/common.py +++ b/bee-hive/cli/common.py @@ -13,7 +13,6 @@ # limitations under the License. import sys -from random import randint VERBOSE=False diff --git a/bee-hive/pyproject.toml b/bee-hive/pyproject.toml index c32f593..734705c 100644 --- a/bee-hive/pyproject.toml +++ b/bee-hive/pyproject.toml @@ -5,6 +5,10 @@ description = "A multi-agent platform with the vision to facilitate deploy and r authors = ["IBM"] license = "Apache 2.0" readme = "README.md" +packages = [ + { include = "bee_hive", from = "." }, + { include = "cli", from = "." } +] [tool.poetry.dependencies] python = ">= 3.11, < 3.13" @@ -14,7 +18,6 @@ python-dotenv = "^1.0.1" jsonschema = "^4.23.0" docopt-ng = "^0.9.0" - [tool.poetry.group.dev.dependencies] [tool.poetry.group.test.dependencies] @@ -27,3 +30,6 @@ build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] addopts = "-v -s" + +[tool.poetry.scripts] +"beeAI" = "cli.beeAI:run_cli" From 8dce9f61ff06691436169df1f8b2bc4d4b777a97 Mon Sep 17 00:00:00 2001 From: Nigel Jones Date: Tue, 4 Feb 2025 15:27:07 +0000 Subject: [PATCH 2/2] fix(cli): revert console error fstring update Signed-off-by: Nigel Jones --- bee-hive/cli/beeAI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bee-hive/cli/beeAI.py b/bee-hive/cli/beeAI.py index d09de06..cb7aee2 100755 --- a/bee-hive/cli/beeAI.py +++ b/bee-hive/cli/beeAI.py @@ -47,7 +47,7 @@ def run_cli(): try: rc = command.execute() if rc != 0: - Console.error(f"executing command: {rc}".format(rc=rc)) + Console.error("executing command: {rc}".format(rc=rc)) sys.exit(rc) except Exception as e: Console.error(str(e))