Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various changes to get all pytest running GREEN #219

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 1 addition & 7 deletions maestro/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,4 @@

import dotenv

dotenv.load_dotenv()

from .cli import CLI

__all__ = {
"CLI"
}
dotenv.load_dotenv()
36 changes: 0 additions & 36 deletions maestro/cli/cli.py

This file was deleted.

28 changes: 25 additions & 3 deletions maestro/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,33 @@
import os, yaml, json, jsonschema

from openai import OpenAI
from maestro.workflow import Workflow

from jsonschema.exceptions import ValidationError

from .common import Console, parse_yaml
from common import Console, parse_yaml

from src.workflow import Workflow

# Root CLI class
class CLI:
def __init__(self, args):
self.args = args
VERBOSE, DRY_RUN = False, False
if self.args['--verbose']:
VERBOSE = True
if self.args['--dry-run']:
DRY_RUN = True

def command(self):
if self.args.get('validate') and self.args['validate']:
return Validate(self.args)
elif self.args.get('create') and self.args['create']:
return Create(self.args)
elif self.args.get('run') and self.args['run']:
return Run(self.args)
elif self.args.get('deploy') and self.args['deploy']:
return Deploy(self.args)
else:
raise Exception("Invalid command")

# Base class for all commands
class Command:
Expand Down
4 changes: 2 additions & 2 deletions maestro/cli/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

from docopt import docopt

from .cli import CLI
from .common import Console
from commands import CLI
from common import Console

def __execute(command):
try:
Expand Down
1 change: 0 additions & 1 deletion maestro/demos/workflows/activity-planner-crewai.ai/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
sys.path.append("maestro/demos/agents/crewai/activity_planner")
sys.path.append("demos/agents/crewai/activity_planner")


def test_agent_runs() -> None:
"""
Verify the test agent runs correctly
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions maestro/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ authors = ["IBM"]
license = "Apache 2.0"
readme = "README.md"
packages = [
{include = "maestro", from="."},
{include = "src", from="."},
{include = "cli", from="."},
#{ include = "activity_planner", from = "demos/agents/crewai" }
# TODO - Packaging demos allows them to be run after a pip install
]

[tool.poetry.dependencies]
Expand Down
23 changes: 22 additions & 1 deletion maestro/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2025 IBM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import dotenv

dotenv.load_dotenv()

from .workflow import Workflow
from .bee_agent import BeeAgent
from .agent import save_agent, restore_agent, remove_agent

__all__ = {
"Workflow"
}
1 change: 1 addition & 0 deletions maestro/src/agent_factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
from enum import Enum
from typing import Callable, Type, Union

from .bee_agent import BeeAgent
from .crewai_agent import CrewAIAgent

Expand Down
5 changes: 2 additions & 3 deletions maestro/src/bee_agent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#! /usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0

import os
import os, dotenv

import dotenv
from openai import AssistantEventHandler, OpenAI
from openai.types.beta import AssistantStreamEvent
from openai.types.beta.threads.runs import RunStep, RunStepDelta, ToolCall

from .agent import Agent
from src.agent import Agent

dotenv.load_dotenv()

Expand Down
Empty file modified maestro/src/mock_agent.py
100644 → 100755
Empty file.
20 changes: 8 additions & 12 deletions maestro/src/workflow.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
#! /usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0

import os
import dotenv
from .step import Step
from .agent_factory import AgentFramework
import os, dotenv

# TODO: Refactor later to factory or similar
from .crewai_agent import CrewAIAgent
from .bee_agent import BeeAgent
from .mock_agent import MockAgent
from .agent import restore_agent
from src.step import Step
from src.agent_factory import AgentFramework

dotenv.load_dotenv()
from src.crewai_agent import CrewAIAgent
from src.bee_agent import BeeAgent
from src.mock_agent import MockAgent
from src.agent import restore_agent

dotenv.load_dotenv()

def find_index(steps, name):
for step in steps:
if step.get("name") == name:
return steps.index(step)


@staticmethod
def get_agent_class(framework: str) -> type:
if os.getenv("DRY_RUN"):
Expand All @@ -30,7 +27,6 @@ def get_agent_class(framework: str) -> type:
else:
return BeeAgent


class Workflow:
agents = {}
steps = {}
Expand Down
19 changes: 18 additions & 1 deletion maestro/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2025 IBM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os, sys

sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../src")
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../cli")
12 changes: 5 additions & 7 deletions maestro/tests/bee/test_bee.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0

import os, dotenv, yaml

from unittest import TestCase
import dotenv
import yaml
import os
from pytest_mock import mocker

# TODO consider moving to same directory as BeeAgent source
from maestro import Workflow
from maestro import BeeAgent
from src.workflow import Workflow
from src.bee_agent import BeeAgent

dotenv.load_dotenv()

Expand Down Expand Up @@ -43,5 +42,4 @@ def parse_yaml(file_path):
print(result)

assert result is not None
# This gets returned by the mock function which uses the prompt from the workflow
assert (result["final_prompt"]=="Mock agent: answer for Welcome")
assert result["final_prompt"].startswith("OK:Welcome")
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

from unittest import TestCase

from .cli import CLI
from cli.commands import CLI

class TestCommand(TestCase):
TEST_FIXTURES_ROOT_PATH = os.path.join(os.path.dirname(__file__), "../tests")
SCHEMAS_ROOT_PATH = os.path.join(os.path.dirname(__file__), "../schemas")
TEST_FIXTURES_ROOT_PATH = os.path.join(os.path.dirname(__file__), "..")
SCHEMAS_ROOT_PATH = os.path.join(os.path.dirname(__file__), "../../schemas")

def get_fixture(self, file_name):
return os.path.join(self.TEST_FIXTURES_ROOT_PATH, file_name)
Expand Down
3 changes: 1 addition & 2 deletions maestro/tests/crewai/test_crewai.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import os
import yaml

from maestro import Workflow
from src.workflow import Workflow

dotenv.load_dotenv()

# TODO: consider moving setup here
# @pytest.fixture(scope="module")


class CrewAITest(TestCase):

def test_agent_runs(self) -> None:
Expand Down
12 changes: 3 additions & 9 deletions maestro/tests/examples/test_condition.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
#! /usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0

import json
import os
import sys
import os, sys, json, dotenv, yaml

import dotenv
from openai import OpenAI
import yaml
from maestro import Workflow

dotenv.load_dotenv()
from src.workflow import Workflow

dotenv.load_dotenv()

def parse_yaml(file_path):
with open(file_path, "r") as file:
yaml_data = list(yaml.safe_load_all(file))
return yaml_data



if __name__ == "__main__":
agents_yaml = parse_yaml(os.path.join(os.path.dirname(__file__),"condition_agents.yaml"))
workflow_yaml = parse_yaml(os.path.join(os.path.dirname(__file__),"condition_workflow.yaml"))
Expand Down
4 changes: 2 additions & 2 deletions maestro/tests/workflow/test_sequence.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pytest_mock import mocker
import os

from maestro import Workflow
from maestro import BeeAgent
from workflow import Workflow
from bee_agent import BeeAgent

dotenv.load_dotenv()

Expand Down
Loading