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

uv cleanup and docs #645

Open
wants to merge 6 commits into
base: master
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
2 changes: 0 additions & 2 deletions auto_swarm_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from loguru import logger

import os
from typing import List

Expand Down
1 change: 0 additions & 1 deletion example_async_vs_multithread.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import asyncio
import threading
from swarms import Agent
from swarm_models import OpenAIChat
import time
Expand Down
58 changes: 35 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
homepage = "https://github.com/kyegomez/swarms"
documentation = "https://docs.swarms.world"
license = {text = "MIT License"}
authors = [
{ name = "Kye Gomez", email = "[email protected]" },
]
readme = "README.md"
repository = "https://github.com/kyegomez/swarms"
keywords = [
"artificial intelligence",
"deep learning",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/auto_tests_docs/auto_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###### VERISON2
# VERSION2
import inspect
import os
import threading
Expand Down
1 change: 0 additions & 1 deletion scripts/auto_tests_docs/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 #############
Expand Down
3 changes: 2 additions & 1 deletion swarms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion swarms/utils/calculate_func_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/profiling_agent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ruff: noqa: E402 # Ignore module level import not at top of file

import time

start_time = time.time()
Expand Down
46 changes: 46 additions & 0 deletions uv_project_notes.md
Original file line number Diff line number Diff line change
@@ -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/)