From 55e9fc04d5fe5b0995feb8bdeaca3cd6d67166f7 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Tue, 26 Nov 2024 13:29:19 -0700 Subject: [PATCH 1/6] uv cleanup and docs --- pyproject.toml | 58 +++++++++++++++++++++++++++------------------ uv_project_notes.md | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 uv_project_notes.md diff --git a/pyproject.toml b/pyproject.toml index d8d06c615..135d14279 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,14 @@ -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" -[tool.poetry] +[project] name = "swarms" version = "6.2.9" description = "Swarms - Pytorch" -license = "MIT" -authors = ["Kye Gomez "] -homepage = "https://github.com/kyegomez/swarms" -documentation = "https://docs.swarms.world" +license = {text = "MIT License"} +authors = [ + { name = "Kye Gomez", email = "kye@swams.world" }, +] readme = "README.md" -repository = "https://github.com/kyegomez/swarms" keywords = [ "artificial intelligence", "deep learning", @@ -45,8 +41,34 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.10", ] +requires-python = ">=3.10,<4.0" +[dependency-groups] +lint = [ + "black<25.0,>=23.1", + "ruff<0.7.4,>=0.5.1", + "types-toml<1.0.0.0,>=0.10.8.1", + "types-pytz<2025.0,>=2023.3", + "types-chardet<6.0.0.0,>=5.0.4.6", + "mypy-protobuf<4.0.0,>=3.0.0", +] +test = [ + "pytest<9.0.0,>=8.1.1", + "termcolor<3.0.0,>=2.4.0", + "pandas<3.0.0,>=2.2.2", + "fastapi<0.116.0,>=0.110.1", +] + + +[project.urls] +homepage = "https://github.com/kyegomez/swarms" +repository = "https://github.com/kyegomez/swarms" +documentation = "https://docs.swarms.world" + +[project.scripts] +swarms = "swarms.cli.main:main" + [tool.poetry.dependencies] python = ">=3.10,<4.0" torch = ">=2.1.1,<3.0" @@ -81,24 +103,14 @@ reportlab = "*" doc-master = "*" rich = "*" -[tool.poetry.scripts] -swarms = "swarms.cli.main:main" +[tool.setuptools.packages.find] +where = ["swarms"] + + -[tool.poetry.group.lint.dependencies] -black = ">=23.1,<25.0" -ruff = ">=0.5.1,<0.7.4" -types-toml = "^0.10.8.1" -types-pytz = ">=2023.3,<2025.0" -types-chardet = "^5.0.4.6" -mypy-protobuf = "^3.0.0" -[tool.poetry.group.test.dependencies] -pytest = "^8.1.1" -termcolor = "^2.4.0" -pandas = "^2.2.2" -fastapi = ">=0.110.1,<0.116.0" [tool.ruff] line-length = 70 diff --git a/uv_project_notes.md b/uv_project_notes.md new file mode 100644 index 000000000..0d958b53d --- /dev/null +++ b/uv_project_notes.md @@ -0,0 +1,46 @@ +# uv project notes + +Guide: (https://www.loopwerk.io/articles/2024/migrate-poetry-to-uv/) + +## install uv + +Follow the [instructions](https://docs.astral.sh/uv/getting-started/installation/) + +## set up a virtual environment + +This assumes you have uv installed. + +```bash +uv venv --python 3.12.0 +source .venv/bin/activate +``` + +or you can run uv without setting up a virtual environment + +```bash +# use --sytem to run the tool ruff not in a virtual environment +uv run ruff check --system +``` + +# pyproject.toml differences + +In Poetry, the project is described in the [tool.poetry] section of the pyproject.toml file. In uv, the project is described in the [project] section of the pyproject.toml file. + +To convert, we use ```pdm``` to get us most of the way there followin [1] + +```bash +uvx pdm import pyproject.toml +``` + +There were several differences in the pyproject.toml file that needed to be addressed manually. +The authors field needed to be in the form: + +```toml +authors = [ { name = "John Doe", email = "email"}] +license = {text = "MIT License"} +``` + +There weren't a lot of good docs on these formatting issues, and the serde error messages were only helpful if you had some idea of what the goal was already. I ended up referring to [1] and [2] for examples. + +[1](https://packaging.python.org/en/latest/flow/#the-configuration-file) +[2](https://reinforcedknowledge.com/a-comprehensive-guide-to-python-project-management-and-packaging-concepts-illustrated-with-uv-part-i/) \ No newline at end of file From facf4eaea18536403eab44a843a070b385412fd0 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Tue, 26 Nov 2024 14:14:26 -0700 Subject: [PATCH 2/6] ruff cleanup --- auto_swarm_builder.py | 2 -- example_async_vs_multithread.py | 1 - 2 files changed, 3 deletions(-) diff --git a/auto_swarm_builder.py b/auto_swarm_builder.py index 8d981dda0..93e542fd4 100644 --- a/auto_swarm_builder.py +++ b/auto_swarm_builder.py @@ -1,5 +1,3 @@ -from loguru import logger - import os from typing import List diff --git a/example_async_vs_multithread.py b/example_async_vs_multithread.py index f547abc8b..b99732e85 100644 --- a/example_async_vs_multithread.py +++ b/example_async_vs_multithread.py @@ -1,6 +1,5 @@ import os import asyncio -import threading from swarms import Agent from swarm_models import OpenAIChat import time From 49448b01ed2523003cd8e9a2f00b26e37442d1f2 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 27 Nov 2024 10:07:03 -0700 Subject: [PATCH 3/6] ruff error suppress --- swarms/__init__.py | 3 ++- tests/profiling_agent.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/swarms/__init__.py b/swarms/__init__.py index 59fee6729..0cee7e11e 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -7,8 +7,9 @@ load_dotenv() +# ruff: noqa: E402 # Ignore module level import not at top of file -from swarms.telemetry.bootup import bootup # noqa: E402, F403 +from swarms.telemetry.bootup import bootup # noqa: F403 from swarms.telemetry.sentry_active import ( activate_sentry, ) # noqa: E402 diff --git a/tests/profiling_agent.py b/tests/profiling_agent.py index 8f1b02206..e6d0d800c 100644 --- a/tests/profiling_agent.py +++ b/tests/profiling_agent.py @@ -1,3 +1,5 @@ +# ruff: noqa: E402 # Ignore module level import not at top of file + import time start_time = time.time() From e6717ffa45ee385a50330e23eb5239ff38583e54 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 27 Nov 2024 10:27:09 -0700 Subject: [PATCH 4/6] remove unneeded import --- swarms/utils/calculate_func_metrics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/swarms/utils/calculate_func_metrics.py b/swarms/utils/calculate_func_metrics.py index bfb8a5288..795e7bb20 100644 --- a/swarms/utils/calculate_func_metrics.py +++ b/swarms/utils/calculate_func_metrics.py @@ -4,7 +4,6 @@ from typing import Any, Callable import psutil -from loguru import logger from pydantic import BaseModel from swarms.utils.loguru_logger import initialize_logger From 6e282261c48387a4370d4b39c002ba8f63bc2347 Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 27 Nov 2024 15:55:06 -0700 Subject: [PATCH 5/6] whitespace flake8 --- scripts/auto_tests_docs/docs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/auto_tests_docs/docs.py b/scripts/auto_tests_docs/docs.py index fd9bd276a..a3fa0e2e6 100644 --- a/scripts/auto_tests_docs/docs.py +++ b/scripts/auto_tests_docs/docs.py @@ -111,7 +111,6 @@ def TEST_WRITER_SOP_PROMPT( Create 5,000 lines of extensive and thorough tests for the code below using the guide, do not worry about your limits you do not have any just write the best tests possible, the module is {module}, the file path is {path} return all of the code in one file, make sure to test all the functions and methods in the code. - ######### TESTING GUIDE ############# From a5ab7ed31bbd5287e5109946b120dfec13d6816c Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Wed, 27 Nov 2024 15:55:42 -0700 Subject: [PATCH 6/6] typo, flake8 comment change --- scripts/auto_tests_docs/auto_docs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_tests_docs/auto_docs.py b/scripts/auto_tests_docs/auto_docs.py index d95364514..6a6d6bc66 100644 --- a/scripts/auto_tests_docs/auto_docs.py +++ b/scripts/auto_tests_docs/auto_docs.py @@ -1,4 +1,4 @@ -###### VERISON2 +# VERSION2 import inspect import os import threading