Skip to content

Commit

Permalink
feat(autogpt,autogpt_server): Build AutoGPT's Constituent Parts for d…
Browse files Browse the repository at this point in the history
…eployment (#7188)
  • Loading branch information
ntindle committed Jun 5, 2024
1 parent 4de0fd8 commit 23dfdad
Show file tree
Hide file tree
Showing 12 changed files with 720 additions and 459 deletions.
Binary file added assets/gpt_dark_RGB.icns
Binary file not shown.
Binary file added assets/gpt_dark_RGB.ico
Binary file not shown.
334 changes: 258 additions & 76 deletions autogpt/poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions autogpt/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ openapi-python-client = "^0.14.0"
agbenchmark = { path = "../benchmark", optional = true }
# agbenchmark = {git = "https://github.com/Significant-Gravitas/AutoGPT.git", subdirectory = "benchmark", optional = true}
psycopg2-binary = "^2.9.9"
multidict = "6.0.5"
cx-freeze = "7.0.0"

[tool.poetry.extras]
benchmark = ["agbenchmark"]
Expand Down
60 changes: 60 additions & 0 deletions autogpt/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from pkgutil import iter_modules
from shutil import which

from cx_Freeze import Executable, setup

packages = [
m.name
for m in iter_modules()
if m.ispkg
and m.module_finder
and ("poetry" in m.module_finder.path) # type: ignore
]

icon = (
"../../assets/gpt_dark_RGB.icns"
if which("sips")
else "../../assets/gpt_dark_RGB.ico"
)


setup(
executables=[
Executable(
"autogpt/__main__.py", target_name="autogpt", base="console", icon=icon
),
],
options={
"build_exe": {
"packages": packages,
"includes": [
"autogpt",
"spacy",
"spacy.lang",
"spacy.vocab",
"spacy.lang.lex_attrs",
"uvicorn.loops.auto",
"srsly.msgpack.util",
"blis",
"uvicorn.protocols.http.auto",
"uvicorn.protocols.websockets.auto",
"uvicorn.lifespan.on",
],
"excludes": ["readability.compat.two"],
},
"bdist_mac": {
"bundle_name": "AutoGPT",
"iconfile": "../assets/gpt_dark_RGB.icns",
"include_resources": [""],
},
"bdist_dmg": {
"applications_shortcut": True,
"volume_label": "AutoGPT",
},
"bdist_msi": {
"target_name": "AutoGPT",
"add_to_path": True,
"install_icon": "../assets/gpt_dark_RGB.ico",
},
},
)
1 change: 1 addition & 0 deletions rnd/autogpt_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
13 changes: 11 additions & 2 deletions rnd/autogpt_server/autogpt_server/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from autogpt_server.server import start_server
from autogpt_server.executor import start_executor_manager
from multiprocessing import freeze_support
from multiprocessing.spawn import freeze_support as freeze_support_spawn

from autogpt_server.data import ExecutionQueue
from autogpt_server.executor import start_executor_manager
from autogpt_server.server import start_server


def main() -> None:
Expand All @@ -10,4 +13,10 @@ def main() -> None:


if __name__ == "__main__":
# These directives are required to make multiprocessing work with cx_Freeze
# and are both required and safe across platforms (Windows, macOS, Linux)
# They must be placed at the beginning of the executions before any other
# multiprocessing code is run
freeze_support()
freeze_support_spawn()
main()
2 changes: 1 addition & 1 deletion rnd/autogpt_server/autogpt_server/server/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uvicorn
from fastapi import FastAPI, APIRouter
from fastapi import APIRouter, FastAPI

from autogpt_server.data import ExecutionQueue

Expand Down
663 changes: 289 additions & 374 deletions rnd/autogpt_server/poetry.lock

Large diffs are not rendered by default.

44 changes: 40 additions & 4 deletions rnd/autogpt_server/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[tool.poetry]
name = "autogpt_server"
version = "0.1.0"
description = ""
authors = ["SwiftyOS <craigswift13@gmail.com>"]
description = "An Agentic Experience"
authors = [
"SwiftyOS <craig.swift@agpt.co>",
"Nicholas Tindle <nicholas.tindle@agpt.co>",
]
readme = "README.md"

[tool.poetry.dependencies]
Expand All @@ -11,13 +14,46 @@ click = "^8.1.7"
pydantic = "^2.7.2"
prisma = "^0.13.1"
pytest = "^8.2.1"
uvicorn = "^0.30.1"
fastapi = "^0.111.0"
uvicorn = { extras = ["standard"], version = "^0.30.1" }
fastapi = "^0.109.0"


[tool.poetry.group.dev.dependencies]
cx-freeze = "7.0.0"
poethepoet = "^0.26.1"
httpx = "^0.27.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
app = "autogpt_server.app:main"

# https://poethepoet.natn.io/index.html
[tool.poe]
poetry_command = ""

# poetry run poe xxx
[tool.poe.tasks]
test = "pytest"
build = ["test", "_dbuild"]

# This might break your python install :)
install = ["build", "_dinstall"]

# https://cx-freeze.readthedocs.io/en/stable/index.html
[tool.poe.tasks._dbuild]
cmd = "python setup.py build"

[tool.poe.tasks.dist_mac]
cmd = "python setup.py bdist_mac"

[tool.poe.tasks.dist_dmg]
cmd = "python setup.py bdist_dmg"

[tool.poe.tasks.dist_msi]
cmd = "python setup.py bdist_msi"

[tool.poe.tasks._dinstall]
cmd = "python setup.py install"
56 changes: 56 additions & 0 deletions rnd/autogpt_server/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from pkgutil import iter_modules
from shutil import which

from cx_Freeze import Executable, setup

packages = [
m.name
for m in iter_modules()
if m.ispkg and m.module_finder and "poetry" in m.module_finder.path # type: ignore
]
packages.append("collections")

# if mac use the icns file, otherwise use the ico file
icon = (
"../../assets/gpt_dark_RGB.icns"
if which("sips")
else "../../assets/gpt_dark_RGB.ico"
)

setup(
name="AutoGPT Server",
url="https://agpt.co",
executables=[
Executable(
"autogpt_server/app.py", target_name="server", base="console", icon=icon
),
],
options={
"build_exe": {
"packages": packages,
"includes": [
"autogpt_server",
"uvicorn.loops.auto",
"uvicorn.protocols.http.auto",
"uvicorn.protocols.websockets.auto",
"uvicorn.lifespan.on",
],
"excludes": ["readability.compat.two"],
},
"bdist_mac": {
"bundle_name": "AutoGPT",
"iconfile": "../../assets/gpt_dark_RGB.icns",
# "include_resources": ["IMG_3775.jpeg"],
},
"bdist_dmg": {
"applications_shortcut": True,
"volume_label": "AutoGPT Server",
},
"bdist_msi": {
"target_name": "AutoGPTServer",
"add_to_path": True,
"install_icon": "../../assets/gpt_dark_RGB.ico",
},
"bdist_appimage": {},
},
)
4 changes: 2 additions & 2 deletions rnd/autogpt_server/test/test_app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
from fastapi.testclient import TestClient

from autogpt_server.server import start_server
from autogpt_server.executor import start_executor_manager
from autogpt_server.data import ExecutionQueue
from autogpt_server.executor import start_executor_manager
from autogpt_server.server import start_server


@pytest.fixture
Expand Down

0 comments on commit 23dfdad

Please sign in to comment.