From 9762ee2b03d127c4b095545b66a2d387512ed40d Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 27 Nov 2024 20:38:47 -0700 Subject: [PATCH 01/13] remove yamllint --- .github/workflows/lint.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f2295d07a..8787d7727 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,14 +1,7 @@ --- name: Lint -on: [push, pull_request] # yamllint disable-line rule:truthy +on: [push, pull_request] jobs: - yaml-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - run: pip install yamllint - - run: yamllint . flake8-lint: runs-on: ubuntu-latest steps: From b81af2e29f7464063a7cbc8de3f3b1e63f5769f6 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 11:42:38 -0700 Subject: [PATCH 02/13] added pathos to fix #691 --- pyproject.toml | 1 + requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2818e7f57..ce37b7709 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,7 @@ doc-master = "*" rich = "*" # sentence-transformers = "*" swarm-models = "*" +pathos = "*" # [tool.poetry.extras] diff --git a/requirements.txt b/requirements.txt index 74c171eac..20a985b6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,3 +27,4 @@ aiofiles clusterops reportlab doc-master +pathos \ No newline at end of file From 822e35e3b7504f0c36ee86fc2b9ba3affb724291 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:22:26 -0700 Subject: [PATCH 03/13] remove duplicate function --- new_features_examples/microstructure.py | 35 ------------------------- 1 file changed, 35 deletions(-) diff --git a/new_features_examples/microstructure.py b/new_features_examples/microstructure.py index c13d2e3f1..f40035e5a 100644 --- a/new_features_examples/microstructure.py +++ b/new_features_examples/microstructure.py @@ -418,41 +418,6 @@ def __init__(self, api_key: str): exchange_manager = ExchangeManager() self.exchange = exchange_manager.get_primary_exchange() - def calculate_tick_metrics( - self, ticks: List[Dict] - ) -> Dict[str, float]: - df = pd.DataFrame(ticks) - df["price"] = pd.to_numeric(df["price"]) - df["volume"] = pd.to_numeric(df["amount"]) - - # Calculate key metrics - metrics = {} - - # Volume-weighted average price (VWAP) - metrics["vwap"] = (df["price"] * df["volume"]).sum() / df[ - "volume" - ].sum() - - # Price momentum - metrics["price_momentum"] = df["price"].diff().mean() - - # Volume profile - metrics["volume_mean"] = df["volume"].mean() - metrics["volume_std"] = df["volume"].std() - - # Trade intensity - time_diff = ( - df["timestamp"].max() - df["timestamp"].min() - ) / 1000 # Convert to seconds - metrics["trade_intensity"] = ( - len(df) / time_diff if time_diff > 0 else 0 - ) - - # Microstructure indicators - metrics["kyle_lambda"] = self.calculate_kyle_lambda(df) - metrics["roll_spread"] = self.calculate_roll_spread(df) - - return metrics def calculate_kyle_lambda(self, df: pd.DataFrame) -> float: """Calculate Kyle's Lambda (price impact coefficient)""" From dd107f2804290900657b8b98f3097c31cfbc3ce9 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:25:25 -0700 Subject: [PATCH 04/13] silence F821 --- new_features_examples/multi_tool_usage_agent.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/new_features_examples/multi_tool_usage_agent.py b/new_features_examples/multi_tool_usage_agent.py index 1af421e25..4d922c4b3 100644 --- a/new_features_examples/multi_tool_usage_agent.py +++ b/new_features_examples/multi_tool_usage_agent.py @@ -111,8 +111,7 @@ class ExecutionContext: history: List[Dict[str, Any]] = field(default_factory=list) -hints = get_type_hints(func) - +hints = get_type_hints(func) # noqa: F821 class ToolAgent: def __init__( From e70ec9db58e1e84bb977b6c02fe2d6ba604d3c31 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:26:39 -0700 Subject: [PATCH 05/13] Fix F811 --- swarms/tools/py_func_to_openai_func_str.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarms/tools/py_func_to_openai_func_str.py b/swarms/tools/py_func_to_openai_func_str.py index db40ed45b..9a9df87ce 100644 --- a/swarms/tools/py_func_to_openai_func_str.py +++ b/swarms/tools/py_func_to_openai_func_str.py @@ -19,7 +19,7 @@ from pydantic import BaseModel, Field from pydantic.version import VERSION as PYDANTIC_VERSION -from typing_extensions import Annotated, Literal, get_args, get_origin +from typing_extensions import Annotated, Literal, get_origin T = TypeVar("T") From 182829831ecdc6666c1ba82aa6644b40bace1068 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:28:31 -0700 Subject: [PATCH 06/13] Fixed bare except E722 --- tests/agent_evals/auto_test_eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index b9c770fab..4c6985d45 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -98,7 +98,7 @@ def _get_swarms_version(self) -> str: import swarms return swarms.__version__ - except: + except ImportError: return "Unknown" def _get_gpu_info(self) -> Tuple[bool, Optional[str]]: From 09ae2866fde5eb79d6bf95b48fec95239e84505e Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:29:50 -0700 Subject: [PATCH 07/13] fix bare except and log the error E722 --- tests/agent_evals/auto_test_eval.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index 4c6985d45..7a4bb9f65 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -108,10 +108,13 @@ def _get_gpu_info(self) -> Tuple[bool, Optional[str]]: cuda_available = torch.cuda.is_available() if cuda_available: - gpu_info = torch.cuda.get_device_name(0) - return cuda_available, gpu_info + gpu_info = torch.cuda.get_device_name(0) + return cuda_available, gpu_info return False, None - except: + except ImportError: + return False, None + except Exception as e: + logger.error(f"Error getting GPU info: {str(e)}") return False, None def _get_system_info(self) -> SwarmSystemInfo: From 90f27e48a1e57e25323574f73c0ccbb0b854f9cf Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:30:30 -0700 Subject: [PATCH 08/13] typo --- tests/agent_evals/auto_test_eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index 7a4bb9f65..e9d018fcc 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -108,7 +108,7 @@ def _get_gpu_info(self) -> Tuple[bool, Optional[str]]: cuda_available = torch.cuda.is_available() if cuda_available: - gpu_info = torch.cuda.get_device_name(0) + gpu_info = torch.cuda.get_device_name(0) return cuda_available, gpu_info return False, None except ImportError: From 716a9c0ba948997a72661eaf00906ee961e3f20a Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:31:39 -0700 Subject: [PATCH 09/13] fix bare except and log the error --- tests/agent_evals/auto_test_eval.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index e9d018fcc..9fc14e11c 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -208,9 +208,10 @@ def _get_dependencies_info(self) -> str: deps = [] for dist in pkg_resources.working_set: - deps.append(f"- {dist.key} {dist.version}") + deps.append(f"- {dist.key} {dist.version}") return "\n".join(deps) - except: + except Exception as e: + logger.error(f"Error fetching dependency information: {str(e)}") return "Unable to fetch dependency information" # First, add this method to your SwarmsIssueReporter class From 41ad7cabe938afcbcb44c136c7ac7be20c1e72a3 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:32:11 -0700 Subject: [PATCH 10/13] typo --- tests/agent_evals/auto_test_eval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/agent_evals/auto_test_eval.py b/tests/agent_evals/auto_test_eval.py index 9fc14e11c..d1ef01e75 100644 --- a/tests/agent_evals/auto_test_eval.py +++ b/tests/agent_evals/auto_test_eval.py @@ -208,7 +208,7 @@ def _get_dependencies_info(self) -> str: deps = [] for dist in pkg_resources.working_set: - deps.append(f"- {dist.key} {dist.version}") + deps.append(f"- {dist.key} {dist.version}") return "\n".join(deps) except Exception as e: logger.error(f"Error fetching dependency information: {str(e)}") From e011ac9f92cca2a9dfb5fafd58f6ce6992895ea9 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 19:34:06 -0700 Subject: [PATCH 11/13] Fix F811 redefinition --- tests/agents/test_agent_logging.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/agents/test_agent_logging.py b/tests/agents/test_agent_logging.py index 1439935ea..1d63fd4d3 100644 --- a/tests/agents/test_agent_logging.py +++ b/tests/agents/test_agent_logging.py @@ -1,11 +1,14 @@ +""" +Unit tests for the Agent logging functionality. +""" + from unittest.mock import MagicMock import unittest from swarms.structs.agent import Agent -from swarms.tools.tool_parse_exec import parse_and_execute_json # Mock parse_and_execute_json for testing -parse_and_execute_json = MagicMock() -parse_and_execute_json.return_value = { +mock_parse_and_execute_json = MagicMock() +mock_parse_and_execute_json.return_value = { "tool_name": "calculator", "args": {"numbers": [2, 2]}, "output": "4", From c2b1dd0bc77a6099f333786678cdcdab1faf966a Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 20:02:27 -0700 Subject: [PATCH 12/13] Revert "added pathos to fix #691" This reverts commit b81af2e29f7464063a7cbc8de3f3b1e63f5769f6. --- pyproject.toml | 1 - requirements.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ce37b7709..2818e7f57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,6 @@ doc-master = "*" rich = "*" # sentence-transformers = "*" swarm-models = "*" -pathos = "*" # [tool.poetry.extras] diff --git a/requirements.txt b/requirements.txt index 20a985b6d..74c171eac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,4 +27,3 @@ aiofiles clusterops reportlab doc-master -pathos \ No newline at end of file From 29218fd404f6288e86270b177c00a0b4d34705b6 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 18 Dec 2024 20:04:02 -0700 Subject: [PATCH 13/13] Revert "Fix F811 redefinition" This reverts commit e011ac9f92cca2a9dfb5fafd58f6ce6992895ea9. --- tests/agents/test_agent_logging.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/agents/test_agent_logging.py b/tests/agents/test_agent_logging.py index 1d63fd4d3..1439935ea 100644 --- a/tests/agents/test_agent_logging.py +++ b/tests/agents/test_agent_logging.py @@ -1,14 +1,11 @@ -""" -Unit tests for the Agent logging functionality. -""" - from unittest.mock import MagicMock import unittest from swarms.structs.agent import Agent +from swarms.tools.tool_parse_exec import parse_and_execute_json # Mock parse_and_execute_json for testing -mock_parse_and_execute_json = MagicMock() -mock_parse_and_execute_json.return_value = { +parse_and_execute_json = MagicMock() +parse_and_execute_json.return_value = { "tool_name": "calculator", "args": {"numbers": [2, 2]}, "output": "4",