From 6c3582570c0f5bb872886b5ee60582d759220ebb Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 14:31:00 -0700 Subject: [PATCH 1/8] tools pydan tic root remove --- swarms/tools/tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index 105a2541..89c09d53 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -268,7 +268,7 @@ class ChildTool(BaseTool): } return tool_input - @root_validator() + @model_validator(mode="after") def raise_deprecation(cls, values: Dict) -> Dict: """Raise deprecation warning if callback_manager is used.""" if values.get("callback_manager") is not None: From 0568eedfb24fd4ae16e1998f2f2b4622459b104c Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 14:35:08 -0700 Subject: [PATCH 2/8] fix import --- swarms/tools/tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index 89c09d53..fddead63 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -34,7 +34,7 @@ from pydantic import ( Extra, Field, create_model, - root_validator, + model_validator, validate_arguments, ) from langchain.schema.runnable import ( From 962788796f65905f0860a38bec46e6c9cce09ff8 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 18:16:28 -0700 Subject: [PATCH 3/8] flake8 assertTrue test_multi_agent_collab --- tests/swarms/test_multi_agent_collab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index bea2c795..2a3eb55c 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -26,7 +26,7 @@ def test_collaboration_initialization(collaboration): assert callable(collaboration.select_next_speaker) assert collaboration.max_iters == 10 assert collaboration.results == [] - assert collaboration.logging == True + assertTrue(collaboration.logging, "Collaboration logging is not enabled") def test_reset(collaboration): From 35bc090a37c6161c37b01fa63961224932c5eb16 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 18:19:47 -0700 Subject: [PATCH 4/8] bare assert for truthiness --- tests/swarms/test_multi_agent_collab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index 2a3eb55c..f5be9da8 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -26,7 +26,7 @@ def test_collaboration_initialization(collaboration): assert callable(collaboration.select_next_speaker) assert collaboration.max_iters == 10 assert collaboration.results == [] - assertTrue(collaboration.logging, "Collaboration logging is not enabled") + assert collaboration.logging def test_reset(collaboration): From 075a620de88338363bc9ce705bbb75e72dbefea9 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 18:22:10 -0700 Subject: [PATCH 5/8] remove duplicate code --- tests/swarms/test_multi_agent_collab.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index f5be9da8..d5b79fdf 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -100,14 +100,6 @@ def test_set_interaction_rules(collaboration): assert hasattr(collaboration, "interaction_rules") assert collaboration.interaction_rules == rules - -def test_set_interaction_rules(collaboration): - rules = {"rule1": "action1", "rule2": "action2"} - collaboration.set_interaction_rules(rules) - assert hasattr(collaboration, "interaction_rules") - assert collaboration.interaction_rules == rules - - def test_repr(collaboration): repr_str = repr(collaboration) assert isinstance(repr_str, str) From 3307e07f3a4dc18569dae56bae9bb0b1dda1990b Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 18:26:52 -0700 Subject: [PATCH 6/8] f8 clean tests --- tests/structs/test_flow.py | 2 -- tests/swarms/test_multi_agent_collab.py | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/structs/test_flow.py b/tests/structs/test_flow.py index 84034a08..494833fe 100644 --- a/tests/structs/test_flow.py +++ b/tests/structs/test_flow.py @@ -326,7 +326,6 @@ def test_flow_response_filtering(flow_instance): def test_flow_undo_last(flow_instance): # Test the undo functionality response1 = flow_instance.run("Task 1") - response2 = flow_instance.run("Task 2") previous_state, message = flow_instance.undo_last() assert response1 == previous_state assert "Restored to" in message @@ -552,7 +551,6 @@ def test_flow_rollback(flow_instance): # Test rolling back to a previous state state1 = flow_instance.get_state() flow_instance.change_prompt("New prompt") - state2 = flow_instance.get_state() flow_instance.rollback_to_state(state1) assert flow_instance.get_current_prompt() == state1["current_prompt"] assert flow_instance.get_instructions() == state1["instructions"] diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index d5b79fdf..8f140237 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -100,6 +100,7 @@ def test_set_interaction_rules(collaboration): assert hasattr(collaboration, "interaction_rules") assert collaboration.interaction_rules == rules + def test_repr(collaboration): repr_str = repr(collaboration) assert isinstance(repr_str, str) From e3123766a622b12da487673b861c19575eba50d2 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Mon, 27 Nov 2023 18:40:10 -0700 Subject: [PATCH 7/8] rename function for f8 --- tests/models/test_ssd_1b.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/models/test_ssd_1b.py b/tests/models/test_ssd_1b.py index 7a7a897f..0ed89106 100644 --- a/tests/models/test_ssd_1b.py +++ b/tests/models/test_ssd_1b.py @@ -105,12 +105,20 @@ def test_ssd1b_generate_uuid(ssd1b_model): assert len(uuid_str) == 36 # UUID format -def test_ssd1b_rate_limited_call(ssd1b_model): +def test_ssd1b_rate_limited_call_connect(ssd1b_model): task = "A painting of a dog" image_url = ssd1b_model.rate_limited_call(task) assert isinstance(image_url, str) assert image_url.startswith("https://") +def test_ssd1b_rate_limited_call_ratelimit(ssd1b_model, mocker): + task = "A painting of a dog" + mocker.patch.object( + ssd1b_model, "__call__", side_effect=Exception("Rate limit exceeded") + ) + with pytest.raises(Exception, match="Rate limit exceeded"): + ssd1b_model.rate_limited_call(task) + # Test cases for additional scenarios and behaviors def test_ssd1b_dashboard_printing(ssd1b_model, capsys): From 0ea531cca8fe9508c01b3d0ae954a79f13bd172a Mon Sep 17 00:00:00 2001 From: "deepsource-io[bot]" <42547082+deepsource-io[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 22:16:47 +0000 Subject: [PATCH 8/8] ci: add .deepsource.toml --- .deepsource.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..3bfe71eb --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,10 @@ +version = 1 + +[[analyzers]] +name = "shell" + +[[analyzers]] +name = "python" + + [analyzers.meta] + runtime_version = "3.x.x" \ No newline at end of file