agentscope-runtime 0.1.5b2__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentscope_runtime/common/__init__.py +0 -0
- agentscope_runtime/common/collections/in_memory_mapping.py +27 -0
- agentscope_runtime/common/collections/redis_mapping.py +42 -0
- agentscope_runtime/common/container_clients/__init__.py +0 -0
- agentscope_runtime/common/container_clients/agentrun_client.py +1098 -0
- agentscope_runtime/common/container_clients/docker_client.py +250 -0
- agentscope_runtime/{sandbox/manager → common}/container_clients/kubernetes_client.py +6 -13
- agentscope_runtime/engine/__init__.py +12 -0
- agentscope_runtime/engine/agents/agentscope_agent.py +567 -0
- agentscope_runtime/engine/agents/agno_agent.py +26 -27
- agentscope_runtime/engine/agents/autogen_agent.py +13 -8
- agentscope_runtime/engine/agents/langgraph_agent.py +52 -9
- agentscope_runtime/engine/agents/utils.py +53 -0
- agentscope_runtime/engine/app/__init__.py +6 -0
- agentscope_runtime/engine/app/agent_app.py +239 -0
- agentscope_runtime/engine/app/base_app.py +181 -0
- agentscope_runtime/engine/app/celery_mixin.py +92 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +5 -1
- agentscope_runtime/engine/deployers/base.py +1 -0
- agentscope_runtime/engine/deployers/cli_fc_deploy.py +39 -20
- agentscope_runtime/engine/deployers/kubernetes_deployer.py +12 -5
- agentscope_runtime/engine/deployers/local_deployer.py +61 -3
- agentscope_runtime/engine/deployers/modelstudio_deployer.py +201 -40
- agentscope_runtime/engine/deployers/utils/docker_image_utils/runner_image_factory.py +9 -0
- agentscope_runtime/engine/deployers/utils/package_project_utils.py +234 -3
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +567 -7
- agentscope_runtime/engine/deployers/utils/service_utils/standalone_main.py.j2 +211 -0
- agentscope_runtime/engine/deployers/utils/wheel_packager.py +1 -1
- agentscope_runtime/engine/helpers/helper.py +60 -41
- agentscope_runtime/engine/runner.py +40 -24
- agentscope_runtime/engine/schemas/agent_schemas.py +42 -0
- agentscope_runtime/engine/schemas/modelstudio_llm.py +14 -14
- agentscope_runtime/engine/services/sandbox_service.py +62 -70
- agentscope_runtime/engine/services/tablestore_memory_service.py +307 -0
- agentscope_runtime/engine/services/tablestore_rag_service.py +143 -0
- agentscope_runtime/engine/services/tablestore_session_history_service.py +293 -0
- agentscope_runtime/engine/services/utils/__init__.py +0 -0
- agentscope_runtime/engine/services/utils/tablestore_service_utils.py +352 -0
- agentscope_runtime/engine/tracing/__init__.py +9 -3
- agentscope_runtime/engine/tracing/asyncio_util.py +24 -0
- agentscope_runtime/engine/tracing/base.py +66 -34
- agentscope_runtime/engine/tracing/local_logging_handler.py +45 -31
- agentscope_runtime/engine/tracing/message_util.py +528 -0
- agentscope_runtime/engine/tracing/tracing_metric.py +20 -8
- agentscope_runtime/engine/tracing/tracing_util.py +130 -0
- agentscope_runtime/engine/tracing/wrapper.py +794 -169
- agentscope_runtime/sandbox/__init__.py +2 -0
- agentscope_runtime/sandbox/box/base/__init__.py +4 -0
- agentscope_runtime/sandbox/box/base/base_sandbox.py +6 -4
- agentscope_runtime/sandbox/box/browser/__init__.py +4 -0
- agentscope_runtime/sandbox/box/browser/browser_sandbox.py +10 -14
- agentscope_runtime/sandbox/box/dummy/__init__.py +4 -0
- agentscope_runtime/sandbox/box/dummy/dummy_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/filesystem/__init__.py +4 -0
- agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +10 -7
- agentscope_runtime/sandbox/box/gui/__init__.py +4 -0
- agentscope_runtime/sandbox/box/gui/box/__init__.py +0 -0
- agentscope_runtime/sandbox/box/gui/gui_sandbox.py +81 -0
- agentscope_runtime/sandbox/box/sandbox.py +5 -2
- agentscope_runtime/sandbox/box/shared/routers/generic.py +20 -1
- agentscope_runtime/sandbox/box/training_box/__init__.py +4 -0
- agentscope_runtime/sandbox/box/training_box/training_box.py +7 -54
- agentscope_runtime/sandbox/build.py +143 -58
- agentscope_runtime/sandbox/client/http_client.py +87 -59
- agentscope_runtime/sandbox/client/training_client.py +0 -1
- agentscope_runtime/sandbox/constant.py +27 -1
- agentscope_runtime/sandbox/custom/custom_sandbox.py +7 -6
- agentscope_runtime/sandbox/custom/example.py +4 -3
- agentscope_runtime/sandbox/enums.py +1 -1
- agentscope_runtime/sandbox/manager/sandbox_manager.py +212 -106
- agentscope_runtime/sandbox/manager/server/app.py +82 -14
- agentscope_runtime/sandbox/manager/server/config.py +50 -3
- agentscope_runtime/sandbox/model/container.py +12 -23
- agentscope_runtime/sandbox/model/manager_config.py +93 -5
- agentscope_runtime/sandbox/registry.py +1 -1
- agentscope_runtime/sandbox/tools/gui/__init__.py +7 -0
- agentscope_runtime/sandbox/tools/gui/tool.py +77 -0
- agentscope_runtime/sandbox/tools/mcp_tool.py +6 -2
- agentscope_runtime/sandbox/tools/tool.py +4 -0
- agentscope_runtime/sandbox/utils.py +124 -0
- agentscope_runtime/version.py +1 -1
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/METADATA +246 -111
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/RECORD +96 -80
- agentscope_runtime/engine/agents/agentscope_agent/__init__.py +0 -6
- agentscope_runtime/engine/agents/agentscope_agent/agent.py +0 -401
- agentscope_runtime/engine/agents/agentscope_agent/hooks.py +0 -169
- agentscope_runtime/engine/agents/llm_agent.py +0 -51
- agentscope_runtime/engine/llms/__init__.py +0 -3
- agentscope_runtime/engine/llms/base_llm.py +0 -60
- agentscope_runtime/engine/llms/qwen_llm.py +0 -47
- agentscope_runtime/sandbox/manager/collections/in_memory_mapping.py +0 -22
- agentscope_runtime/sandbox/manager/collections/redis_mapping.py +0 -26
- agentscope_runtime/sandbox/manager/container_clients/__init__.py +0 -10
- agentscope_runtime/sandbox/manager/container_clients/docker_client.py +0 -422
- /agentscope_runtime/{sandbox/manager → common}/collections/__init__.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_mapping.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/container_clients/base_client.py +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/WHEEL +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/entry_points.txt +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import inspect
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
from typing import Callable, Optional, List
|
|
6
|
+
from celery import Celery
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CeleryMixin:
|
|
12
|
+
"""
|
|
13
|
+
Celery task processing mixin that provides core Celery functionality.
|
|
14
|
+
Can be reused by BaseApp and FastAPIAppFactory.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
broker_url: Optional[str] = None,
|
|
20
|
+
backend_url: Optional[str] = None,
|
|
21
|
+
):
|
|
22
|
+
if broker_url and backend_url:
|
|
23
|
+
self.celery_app = Celery(
|
|
24
|
+
"agentscope_runtime",
|
|
25
|
+
broker=broker_url,
|
|
26
|
+
backend=backend_url,
|
|
27
|
+
)
|
|
28
|
+
else:
|
|
29
|
+
self.celery_app = None
|
|
30
|
+
|
|
31
|
+
self._registered_queues: set[str] = set()
|
|
32
|
+
|
|
33
|
+
def get_registered_queues(self) -> set[str]:
|
|
34
|
+
return self._registered_queues
|
|
35
|
+
|
|
36
|
+
def register_celery_task(self, func: Callable, queue: str = "celery"):
|
|
37
|
+
"""Register a Celery task for the given function."""
|
|
38
|
+
if self.celery_app is None:
|
|
39
|
+
raise RuntimeError("Celery is not configured.")
|
|
40
|
+
|
|
41
|
+
self._registered_queues.add(queue)
|
|
42
|
+
|
|
43
|
+
@self.celery_app.task(queue=queue)
|
|
44
|
+
def wrapper(*args, **kwargs):
|
|
45
|
+
if inspect.iscoroutinefunction(func):
|
|
46
|
+
return asyncio.run(func(*args, **kwargs))
|
|
47
|
+
else:
|
|
48
|
+
return func(*args, **kwargs)
|
|
49
|
+
|
|
50
|
+
return wrapper
|
|
51
|
+
|
|
52
|
+
def run_task_processor(
|
|
53
|
+
self,
|
|
54
|
+
loglevel: str = "INFO",
|
|
55
|
+
concurrency: Optional[int] = None,
|
|
56
|
+
queues: Optional[List[str]] = None,
|
|
57
|
+
):
|
|
58
|
+
"""Run Celery worker in this process."""
|
|
59
|
+
if self.celery_app is None:
|
|
60
|
+
raise RuntimeError("Celery is not configured.")
|
|
61
|
+
|
|
62
|
+
cmd = ["worker", f"--loglevel={loglevel}"]
|
|
63
|
+
if concurrency:
|
|
64
|
+
cmd.append(f"--concurrency={concurrency}")
|
|
65
|
+
if queues:
|
|
66
|
+
cmd.append(f"-Q {','.join(queues)}")
|
|
67
|
+
|
|
68
|
+
self.celery_app.worker_main(cmd)
|
|
69
|
+
|
|
70
|
+
def get_task_status(self, task_id: str):
|
|
71
|
+
"""Get task status from Celery result backend."""
|
|
72
|
+
if self.celery_app is None:
|
|
73
|
+
return {"error": "Celery not configured"}
|
|
74
|
+
|
|
75
|
+
result = self.celery_app.AsyncResult(task_id)
|
|
76
|
+
if result.state == "PENDING":
|
|
77
|
+
return {"status": "pending", "result": None}
|
|
78
|
+
elif result.state == "SUCCESS":
|
|
79
|
+
return {"status": "finished", "result": result.result}
|
|
80
|
+
elif result.state == "FAILURE":
|
|
81
|
+
return {"status": "error", "result": str(result.info)}
|
|
82
|
+
else:
|
|
83
|
+
return {"status": result.state, "result": None}
|
|
84
|
+
|
|
85
|
+
def submit_task(self, func: Callable, *args, **kwargs):
|
|
86
|
+
"""Submit task directly to Celery queue."""
|
|
87
|
+
if not hasattr(func, "celery_task"):
|
|
88
|
+
raise RuntimeError(
|
|
89
|
+
f"Function {func.__name__} is not registered as a task",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return func.celery_task.delay(*args, **kwargs)
|
|
@@ -71,6 +71,10 @@ from openai.types.responses.response_reasoning_item import (
|
|
|
71
71
|
ResponseReasoningItem,
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
+
from openai.types.responses.response_reasoning_item import (
|
|
75
|
+
Content as ReasoningContent,
|
|
76
|
+
)
|
|
77
|
+
|
|
74
78
|
from agentscope_runtime.engine.schemas.agent_schemas import (
|
|
75
79
|
AgentRequest,
|
|
76
80
|
BaseResponse,
|
|
@@ -1399,7 +1403,7 @@ class ResponsesAdapter:
|
|
|
1399
1403
|
id=message.id,
|
|
1400
1404
|
summary=[], # Empty summary
|
|
1401
1405
|
content=(
|
|
1402
|
-
[
|
|
1406
|
+
[ReasoningContent(type="reasoning_text", text=reasoning_text)]
|
|
1403
1407
|
if reasoning_text
|
|
1404
1408
|
else None
|
|
1405
1409
|
),
|
|
@@ -4,6 +4,10 @@ import asyncio
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import Optional
|
|
6
6
|
|
|
7
|
+
from rich.console import Console
|
|
8
|
+
from rich.panel import Panel
|
|
9
|
+
from rich.table import Table
|
|
10
|
+
|
|
7
11
|
from .modelstudio_deployer import ModelstudioDeployManager
|
|
8
12
|
from .utils.wheel_packager import build_wheel
|
|
9
13
|
|
|
@@ -152,32 +156,47 @@ def main() -> None:
|
|
|
152
156
|
agent_desc=args.agent_desc,
|
|
153
157
|
),
|
|
154
158
|
)
|
|
155
|
-
|
|
159
|
+
|
|
160
|
+
console = Console()
|
|
161
|
+
|
|
162
|
+
# Create a table for basic information
|
|
163
|
+
info_table = Table(show_header=False, box=None, padding=(0, 2))
|
|
164
|
+
info_table.add_column("Key", style="bold cyan")
|
|
165
|
+
info_table.add_column("Value", style="white")
|
|
166
|
+
|
|
167
|
+
if result.get("wheel_path"):
|
|
168
|
+
info_table.add_row("Built wheel at", result.get("wheel_path", ""))
|
|
169
|
+
|
|
156
170
|
if result.get("artifact_url"):
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
info_table.add_row("Artifact URL", result.get("artifact_url"))
|
|
172
|
+
|
|
173
|
+
if result.get("resource_name"):
|
|
174
|
+
info_table.add_row("Resource Name", result.get("resource_name"))
|
|
175
|
+
|
|
159
176
|
if result.get("workspace_id"):
|
|
160
|
-
|
|
177
|
+
info_table.add_row("Workspace", result.get("workspace_id"))
|
|
178
|
+
|
|
179
|
+
console.print(info_table)
|
|
161
180
|
|
|
181
|
+
# Display deploy result in a panel
|
|
162
182
|
console_url = result.get("url")
|
|
163
183
|
deploy_id = result.get("deploy_id")
|
|
164
184
|
if console_url and deploy_id:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
print(
|
|
180
|
-
print("")
|
|
185
|
+
console.print() # Add spacing
|
|
186
|
+
panel_content = (
|
|
187
|
+
f"[bold cyan]Console URL:[/bold cyan] {console_url}\n"
|
|
188
|
+
f"[bold cyan]Deploy ID:[/bold cyan] {deploy_id}"
|
|
189
|
+
)
|
|
190
|
+
console.print(
|
|
191
|
+
Panel(
|
|
192
|
+
panel_content,
|
|
193
|
+
title="[bold green]Deploy Result[/bold green]",
|
|
194
|
+
title_align="center",
|
|
195
|
+
expand=False,
|
|
196
|
+
border_style="green",
|
|
197
|
+
),
|
|
198
|
+
)
|
|
199
|
+
console.print() # Add spacing
|
|
181
200
|
|
|
182
201
|
|
|
183
202
|
if __name__ == "__main__": # pragma: no cover
|
|
@@ -6,10 +6,6 @@ from typing import Optional, Dict, List, Union, Any
|
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel, Field
|
|
8
8
|
|
|
9
|
-
from agentscope_runtime.engine.runner import Runner
|
|
10
|
-
from agentscope_runtime.sandbox.manager.container_clients import (
|
|
11
|
-
KubernetesClient,
|
|
12
|
-
)
|
|
13
9
|
from .adapter.protocol_adapter import ProtocolAdapter
|
|
14
10
|
from .base import DeployManager
|
|
15
11
|
from .utils.docker_image_utils import (
|
|
@@ -19,6 +15,10 @@ from .utils.docker_image_utils import (
|
|
|
19
15
|
from .utils.service_utils import (
|
|
20
16
|
ServicesConfig,
|
|
21
17
|
)
|
|
18
|
+
from ..runner import Runner
|
|
19
|
+
from ...common.container_clients.kubernetes_client import (
|
|
20
|
+
KubernetesClient,
|
|
21
|
+
)
|
|
22
22
|
|
|
23
23
|
logger = logging.getLogger(__name__)
|
|
24
24
|
|
|
@@ -77,6 +77,7 @@ class KubernetesDeployManager(DeployManager):
|
|
|
77
77
|
endpoint_path: str = "/process",
|
|
78
78
|
stream: bool = True,
|
|
79
79
|
services_config: Optional[Union[ServicesConfig, dict]] = None,
|
|
80
|
+
custom_endpoints: Optional[List[Dict]] = None,
|
|
80
81
|
protocol_adapters: Optional[list[ProtocolAdapter]] = None,
|
|
81
82
|
requirements: Optional[Union[str, List[str]]] = None,
|
|
82
83
|
extra_packages: Optional[List[str]] = None,
|
|
@@ -100,6 +101,7 @@ class KubernetesDeployManager(DeployManager):
|
|
|
100
101
|
endpoint_path: API endpoint path
|
|
101
102
|
stream: Enable streaming responses
|
|
102
103
|
services_config: Services configuration for context manager
|
|
104
|
+
custom_endpoints: Custom endpoints from agent app
|
|
103
105
|
protocol_adapters: protocol adapters
|
|
104
106
|
requirements: PyPI dependencies (following _agent_engines.py
|
|
105
107
|
pattern)
|
|
@@ -156,6 +158,7 @@ class KubernetesDeployManager(DeployManager):
|
|
|
156
158
|
port=port,
|
|
157
159
|
services_config=services_config, # type: ignore[arg-type]
|
|
158
160
|
protocol_adapters=protocol_adapters,
|
|
161
|
+
custom_endpoints=custom_endpoints,
|
|
159
162
|
**kwargs,
|
|
160
163
|
)
|
|
161
164
|
if not built_image_name:
|
|
@@ -205,7 +208,11 @@ class KubernetesDeployManager(DeployManager):
|
|
|
205
208
|
f"{resource_name}, {traceback.format_exc()}",
|
|
206
209
|
)
|
|
207
210
|
|
|
208
|
-
|
|
211
|
+
if ports:
|
|
212
|
+
url = f"http://{ip}:{ports[0]}"
|
|
213
|
+
else:
|
|
214
|
+
url = f"http://{ip}:8080"
|
|
215
|
+
|
|
209
216
|
logger.info(f"Deployment {deploy_id} successful: {url}")
|
|
210
217
|
|
|
211
218
|
self._deployed_resources[deploy_id] = {
|
|
@@ -29,7 +29,8 @@ class LocalDeployManager(DeployManager):
|
|
|
29
29
|
self,
|
|
30
30
|
host: str = "127.0.0.1",
|
|
31
31
|
port: int = 8000,
|
|
32
|
-
shutdown_timeout: int =
|
|
32
|
+
shutdown_timeout: int = 30,
|
|
33
|
+
startup_timeout: int = 30,
|
|
33
34
|
logger: Optional[logging.Logger] = None,
|
|
34
35
|
):
|
|
35
36
|
"""Initialize LocalDeployManager.
|
|
@@ -44,6 +45,7 @@ class LocalDeployManager(DeployManager):
|
|
|
44
45
|
self.host = host
|
|
45
46
|
self.port = port
|
|
46
47
|
self._shutdown_timeout = shutdown_timeout
|
|
48
|
+
self._startup_timeout = startup_timeout
|
|
47
49
|
self._logger = logger or logging.getLogger(__name__)
|
|
48
50
|
|
|
49
51
|
# State management
|
|
@@ -66,6 +68,7 @@ class LocalDeployManager(DeployManager):
|
|
|
66
68
|
|
|
67
69
|
async def deploy(
|
|
68
70
|
self,
|
|
71
|
+
app=None,
|
|
69
72
|
runner: Optional[Any] = None,
|
|
70
73
|
endpoint_path: str = "/process",
|
|
71
74
|
request_model: Optional[Type] = None,
|
|
@@ -75,7 +78,11 @@ class LocalDeployManager(DeployManager):
|
|
|
75
78
|
after_finish: Optional[Callable] = None,
|
|
76
79
|
mode: DeploymentMode = DeploymentMode.DAEMON_THREAD,
|
|
77
80
|
services_config: Optional[ServicesConfig] = None,
|
|
81
|
+
custom_endpoints: Optional[List[Dict]] = None,
|
|
78
82
|
protocol_adapters: Optional[list[ProtocolAdapter]] = None,
|
|
83
|
+
broker_url: Optional[str] = None,
|
|
84
|
+
backend_url: Optional[str] = None,
|
|
85
|
+
enable_embedded_worker: bool = False,
|
|
79
86
|
**kwargs: Any,
|
|
80
87
|
) -> Dict[str, str]:
|
|
81
88
|
"""Deploy using unified FastAPI architecture.
|
|
@@ -90,7 +97,12 @@ class LocalDeployManager(DeployManager):
|
|
|
90
97
|
after_finish: Callback function called after server finishes
|
|
91
98
|
mode: Deployment mode
|
|
92
99
|
services_config: Services configuration
|
|
100
|
+
custom_endpoints: Custom endpoints from agent app
|
|
93
101
|
protocol_adapters: Protocol adapters
|
|
102
|
+
broker_url: Celery broker URL for background task processing
|
|
103
|
+
backend_url: Celery backend URL for result storage
|
|
104
|
+
enable_embedded_worker: Whether to run Celery worker
|
|
105
|
+
embedded in the app
|
|
94
106
|
**kwargs: Additional keyword arguments
|
|
95
107
|
|
|
96
108
|
Returns:
|
|
@@ -102,6 +114,19 @@ class LocalDeployManager(DeployManager):
|
|
|
102
114
|
if self.is_running:
|
|
103
115
|
raise RuntimeError("Service is already running")
|
|
104
116
|
|
|
117
|
+
self._app = app
|
|
118
|
+
if self._app is not None:
|
|
119
|
+
runner = self._app._runner
|
|
120
|
+
endpoint_path = self._app.endpoint_path
|
|
121
|
+
response_type = self._app.response_type
|
|
122
|
+
stream = self._app.stream
|
|
123
|
+
request_model = self._app.request_model
|
|
124
|
+
before_start = self._app.before_start
|
|
125
|
+
after_finish = self._app.after_finish
|
|
126
|
+
backend_url = self._app.backend_url
|
|
127
|
+
broker_url = self._app.broker_url
|
|
128
|
+
custom_endpoints = self._app.custom_endpoints
|
|
129
|
+
protocol_adapters = self._app.protocol_adapters
|
|
105
130
|
try:
|
|
106
131
|
if mode == DeploymentMode.DAEMON_THREAD:
|
|
107
132
|
return await self._deploy_daemon_thread(
|
|
@@ -113,7 +138,11 @@ class LocalDeployManager(DeployManager):
|
|
|
113
138
|
before_start=before_start,
|
|
114
139
|
after_finish=after_finish,
|
|
115
140
|
services_config=services_config,
|
|
141
|
+
custom_endpoints=custom_endpoints,
|
|
116
142
|
protocol_adapters=protocol_adapters,
|
|
143
|
+
broker_url=broker_url,
|
|
144
|
+
backend_url=backend_url,
|
|
145
|
+
enable_embedded_worker=enable_embedded_worker,
|
|
117
146
|
**kwargs,
|
|
118
147
|
)
|
|
119
148
|
elif mode == DeploymentMode.DETACHED_PROCESS:
|
|
@@ -126,6 +155,7 @@ class LocalDeployManager(DeployManager):
|
|
|
126
155
|
before_start=before_start,
|
|
127
156
|
after_finish=after_finish,
|
|
128
157
|
services_config=services_config,
|
|
158
|
+
custom_endpoints=custom_endpoints,
|
|
129
159
|
protocol_adapters=protocol_adapters,
|
|
130
160
|
**kwargs,
|
|
131
161
|
)
|
|
@@ -143,16 +173,22 @@ class LocalDeployManager(DeployManager):
|
|
|
143
173
|
self,
|
|
144
174
|
runner: Optional[Any] = None,
|
|
145
175
|
protocol_adapters: Optional[list[ProtocolAdapter]] = None,
|
|
176
|
+
broker_url: Optional[str] = None,
|
|
177
|
+
backend_url: Optional[str] = None,
|
|
178
|
+
enable_embedded_worker: bool = False,
|
|
146
179
|
**kwargs,
|
|
147
180
|
) -> Dict[str, str]:
|
|
148
181
|
"""Deploy in daemon thread mode."""
|
|
149
182
|
self._logger.info("Deploying FastAPI service in daemon thread mode...")
|
|
150
183
|
|
|
151
|
-
# Create FastAPI app using factory
|
|
184
|
+
# Create FastAPI app using factory with Celery support
|
|
152
185
|
app = FastAPIAppFactory.create_app(
|
|
153
186
|
runner=runner,
|
|
154
187
|
mode=DeploymentMode.DAEMON_THREAD,
|
|
155
188
|
protocol_adapters=protocol_adapters,
|
|
189
|
+
broker_url=broker_url,
|
|
190
|
+
backend_url=backend_url,
|
|
191
|
+
enable_embedded_worker=enable_embedded_worker,
|
|
156
192
|
**kwargs,
|
|
157
193
|
)
|
|
158
194
|
|
|
@@ -174,7 +210,7 @@ class LocalDeployManager(DeployManager):
|
|
|
174
210
|
self._server_thread.start()
|
|
175
211
|
|
|
176
212
|
# Wait for server to start
|
|
177
|
-
await self._wait_for_server_ready()
|
|
213
|
+
await self._wait_for_server_ready(self._startup_timeout)
|
|
178
214
|
|
|
179
215
|
self.is_running = True
|
|
180
216
|
self.deploy_id = f"daemon_{self.host}_{self.port}"
|
|
@@ -207,6 +243,8 @@ class LocalDeployManager(DeployManager):
|
|
|
207
243
|
)
|
|
208
244
|
|
|
209
245
|
agent = runner._agent
|
|
246
|
+
if "agent" in kwargs:
|
|
247
|
+
kwargs.pop("agent")
|
|
210
248
|
|
|
211
249
|
# Create package project for detached deployment
|
|
212
250
|
project_dir = await self.create_detached_project(
|
|
@@ -272,6 +310,13 @@ class LocalDeployManager(DeployManager):
|
|
|
272
310
|
extra_packages: Optional[List[str]] = None,
|
|
273
311
|
services_config: Optional[ServicesConfig] = None,
|
|
274
312
|
protocol_adapters: Optional[list[ProtocolAdapter]] = None,
|
|
313
|
+
custom_endpoints: Optional[
|
|
314
|
+
List[Dict]
|
|
315
|
+
] = None, # New parameter for custom endpoints
|
|
316
|
+
# Celery parameters
|
|
317
|
+
broker_url: Optional[str] = None,
|
|
318
|
+
backend_url: Optional[str] = None,
|
|
319
|
+
enable_embedded_worker: bool = False,
|
|
275
320
|
**kwargs, # pylint: disable=unused-argument
|
|
276
321
|
) -> str:
|
|
277
322
|
"""Create detached project using package_project method."""
|
|
@@ -288,6 +333,11 @@ class LocalDeployManager(DeployManager):
|
|
|
288
333
|
extra_packages=extra_packages,
|
|
289
334
|
protocol_adapters=protocol_adapters,
|
|
290
335
|
services_config=services_config,
|
|
336
|
+
custom_endpoints=custom_endpoints, # Add custom endpoints
|
|
337
|
+
# Celery configuration
|
|
338
|
+
broker_url=broker_url,
|
|
339
|
+
backend_url=backend_url,
|
|
340
|
+
enable_embedded_worker=enable_embedded_worker,
|
|
291
341
|
requirements=requirements
|
|
292
342
|
+ (
|
|
293
343
|
["redis"]
|
|
@@ -301,6 +351,14 @@ class LocalDeployManager(DeployManager):
|
|
|
301
351
|
if config
|
|
302
352
|
)
|
|
303
353
|
else []
|
|
354
|
+
)
|
|
355
|
+
+ (
|
|
356
|
+
[
|
|
357
|
+
"celery",
|
|
358
|
+
"redis",
|
|
359
|
+
] # Add Celery and Redis if Celery is configured
|
|
360
|
+
if broker_url or backend_url
|
|
361
|
+
else []
|
|
304
362
|
),
|
|
305
363
|
)
|
|
306
364
|
|