bohr-agent-sdk 0.1.109__py3-none-any.whl → 0.1.110__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.
- {bohr_agent_sdk-0.1.109.dist-info → bohr_agent_sdk-0.1.110.dist-info}/METADATA +1 -1
- {bohr_agent_sdk-0.1.109.dist-info → bohr_agent_sdk-0.1.110.dist-info}/RECORD +8 -8
- dp/agent/server/executor/base_executor.py +22 -0
- dp/agent/server/executor/dispatcher_executor.py +1 -0
- dp/agent/server/executor/local_executor.py +12 -2
- {bohr_agent_sdk-0.1.109.dist-info → bohr_agent_sdk-0.1.110.dist-info}/WHEEL +0 -0
- {bohr_agent_sdk-0.1.109.dist-info → bohr_agent_sdk-0.1.110.dist-info}/entry_points.txt +0 -0
- {bohr_agent_sdk-0.1.109.dist-info → bohr_agent_sdk-0.1.110.dist-info}/top_level.txt +0 -0
|
@@ -66,17 +66,17 @@ dp/agent/server/calculation_mcp_server.py,sha256=hsTxuguyqgq_4HSeJYS7VnW-jTvqf9D
|
|
|
66
66
|
dp/agent/server/preprocessor.py,sha256=XUWu7QOwo_sIDMYS2b1OTrM33EXEVH_73vk-ju1Ok8A,1264
|
|
67
67
|
dp/agent/server/utils.py,sha256=ui3lca9EagcGqmYf8BKLsPARIzXxJ3jgN98yuEO3OSQ,1668
|
|
68
68
|
dp/agent/server/executor/__init__.py,sha256=s95M5qKQk39Yi9qaVJZhk_nfj54quSf7EDghR3OCFUA,248
|
|
69
|
-
dp/agent/server/executor/base_executor.py,sha256=
|
|
70
|
-
dp/agent/server/executor/dispatcher_executor.py,sha256
|
|
71
|
-
dp/agent/server/executor/local_executor.py,sha256=
|
|
69
|
+
dp/agent/server/executor/base_executor.py,sha256=nR2jI-wFvKoOk8QaK11pnSAkHj2MsE6uyzPWDx-vgJA,3018
|
|
70
|
+
dp/agent/server/executor/dispatcher_executor.py,sha256=-P1HAuHDbfLi-3mkT29I84x2aMvmXiM2h-qfZGEobjI,10872
|
|
71
|
+
dp/agent/server/executor/local_executor.py,sha256=pGXlDOrfjfP40hSMzbF-Wls3OnOTsH8PdkQjcDjP6_w,6580
|
|
72
72
|
dp/agent/server/storage/__init__.py,sha256=Sgsyp5hb0_hhIGugAPfQFzBHt_854rS_MuMuE3sn8Gs,389
|
|
73
73
|
dp/agent/server/storage/base_storage.py,sha256=728-oNG6N8isV95gZVnyi4vTznJPJhSjxw9Gl5Y_y5o,2356
|
|
74
74
|
dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mmPFecrln-Ytk40,10488
|
|
75
75
|
dp/agent/server/storage/http_storage.py,sha256=KiySq7g9-iJr12XQCKKyJLn8wJoDnSRpQAR5_qPJ1ZU,1471
|
|
76
76
|
dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
|
|
77
77
|
dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
|
|
78
|
-
bohr_agent_sdk-0.1.
|
|
79
|
-
bohr_agent_sdk-0.1.
|
|
80
|
-
bohr_agent_sdk-0.1.
|
|
81
|
-
bohr_agent_sdk-0.1.
|
|
82
|
-
bohr_agent_sdk-0.1.
|
|
78
|
+
bohr_agent_sdk-0.1.110.dist-info/METADATA,sha256=zqodSHxsxgJ5AYkjncOWOL4qA5hWhiY8Sx1AvPOfMO0,11070
|
|
79
|
+
bohr_agent_sdk-0.1.110.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
80
|
+
bohr_agent_sdk-0.1.110.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
|
|
81
|
+
bohr_agent_sdk-0.1.110.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
|
|
82
|
+
bohr_agent_sdk-0.1.110.dist-info/RECORD,,
|
|
@@ -5,6 +5,8 @@ from collections.abc import Callable
|
|
|
5
5
|
from typing import Any, Literal, TypedDict
|
|
6
6
|
|
|
7
7
|
from mcp.server.fastmcp.server import Context
|
|
8
|
+
from mcp.shared.context import RequestContext
|
|
9
|
+
from starlette.requests import Request
|
|
8
10
|
logger = logging.getLogger(__name__)
|
|
9
11
|
|
|
10
12
|
|
|
@@ -27,6 +29,26 @@ class BaseExecutor(ABC):
|
|
|
27
29
|
def get_results(self, job_id: str) -> dict:
|
|
28
30
|
pass
|
|
29
31
|
|
|
32
|
+
def prune_context(self, kwargs: dict):
|
|
33
|
+
for key, value in kwargs.items():
|
|
34
|
+
if isinstance(value, Context):
|
|
35
|
+
context = Context(request_context=RequestContext(
|
|
36
|
+
request_id=value.request_context.request_id,
|
|
37
|
+
meta=value.request_context.meta,
|
|
38
|
+
session=None,
|
|
39
|
+
lifespan_context=value.request_context.lifespan_context,
|
|
40
|
+
request=Request(
|
|
41
|
+
scope={
|
|
42
|
+
k: v for k, v in
|
|
43
|
+
value.request_context.request.scope.items()
|
|
44
|
+
if k not in ["app", "router", "endpoint",
|
|
45
|
+
"starlette.exception_handlers"]
|
|
46
|
+
},
|
|
47
|
+
)
|
|
48
|
+
))
|
|
49
|
+
kwargs[key] = context
|
|
50
|
+
return kwargs
|
|
51
|
+
|
|
30
52
|
async def async_run(
|
|
31
53
|
self, fn: Callable, kwargs: dict, context: Context,
|
|
32
54
|
trace_id: str) -> TypedDict(
|
|
@@ -129,6 +129,7 @@ class DispatcherExecutor(BaseExecutor):
|
|
|
129
129
|
self.resources["envs"]["DP_AGENT_RUNNING_MODE"] = "1"
|
|
130
130
|
|
|
131
131
|
def submit(self, fn, kwargs):
|
|
132
|
+
kwargs = self.prune_context(kwargs)
|
|
132
133
|
script = ""
|
|
133
134
|
fn_name = fn.__name__
|
|
134
135
|
func_def_script, packages = get_func_def_script(fn)
|
|
@@ -88,6 +88,7 @@ class LocalExecutor(BaseExecutor):
|
|
|
88
88
|
"""
|
|
89
89
|
self.env = env or {}
|
|
90
90
|
self.dflow = dflow
|
|
91
|
+
self.workflow_id = None
|
|
91
92
|
|
|
92
93
|
def set_env(self):
|
|
93
94
|
old_env = {}
|
|
@@ -105,6 +106,7 @@ class LocalExecutor(BaseExecutor):
|
|
|
105
106
|
del os.environ[k]
|
|
106
107
|
|
|
107
108
|
def submit(self, fn, kwargs):
|
|
109
|
+
kwargs = self.prune_context(kwargs)
|
|
108
110
|
os.environ["DP_AGENT_RUNNING_MODE"] = "1"
|
|
109
111
|
old_env = self.set_env()
|
|
110
112
|
params = {"fn": fn, "kwargs": kwargs}
|
|
@@ -123,6 +125,7 @@ class LocalExecutor(BaseExecutor):
|
|
|
123
125
|
match_link = re.search(DFLOW_LINK_PATTERN, log)
|
|
124
126
|
if match_id and match_link:
|
|
125
127
|
wf_id = match_id.group(1)
|
|
128
|
+
self.workflow_id = wf_id
|
|
126
129
|
wf_uid = match_id.group(2)
|
|
127
130
|
wf_link = match_link.group(1)
|
|
128
131
|
extra_info["workflow_id"] = wf_id
|
|
@@ -155,11 +158,18 @@ class LocalExecutor(BaseExecutor):
|
|
|
155
158
|
return "Failed"
|
|
156
159
|
|
|
157
160
|
def terminate(self, job_id):
|
|
161
|
+
if self.workflow_id is not None:
|
|
162
|
+
try:
|
|
163
|
+
from dflow import Workflow
|
|
164
|
+
wf = Workflow(id=self.workflow_id)
|
|
165
|
+
wf.terminate()
|
|
166
|
+
except Exception as e:
|
|
167
|
+
logger.error(f"Failed to terminate workflow: {e}")
|
|
158
168
|
try:
|
|
159
169
|
p = psutil.Process(int(job_id))
|
|
160
170
|
p.terminate()
|
|
161
|
-
except Exception:
|
|
162
|
-
|
|
171
|
+
except Exception as e:
|
|
172
|
+
logger.error(f"Failed to terminate process: {e}")
|
|
163
173
|
|
|
164
174
|
def get_results(self, job_id):
|
|
165
175
|
if os.path.isfile("%s.txt" % job_id):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|