bohr-agent-sdk 0.1.114__py3-none-any.whl → 0.1.116__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.114.dist-info → bohr_agent_sdk-0.1.116.dist-info}/METADATA +1 -1
- {bohr_agent_sdk-0.1.114.dist-info → bohr_agent_sdk-0.1.116.dist-info}/RECORD +9 -9
- dp/agent/adapter/adk/client/calculation_mcp_tool.py +7 -4
- dp/agent/client/mcp_client.py +7 -0
- dp/agent/server/calculation_mcp_server.py +8 -6
- dp/agent/server/executor/local_executor.py +12 -12
- {bohr_agent_sdk-0.1.114.dist-info → bohr_agent_sdk-0.1.116.dist-info}/WHEEL +0 -0
- {bohr_agent_sdk-0.1.114.dist-info → bohr_agent_sdk-0.1.116.dist-info}/entry_points.txt +0 -0
- {bohr_agent_sdk-0.1.114.dist-info → bohr_agent_sdk-0.1.116.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ dp/agent/adapter/adk/__init__.py,sha256=mxX2SxGgDjwQ7WjfKMw9mQkq4ddl8XlCA6gnUinC
|
|
|
4
4
|
dp/agent/adapter/adk/storage_artifact_service.py,sha256=Hd1CmEB8HgEz3x_riHVSSmYdw6W2bDYYa3c5ySCqmCE,5414
|
|
5
5
|
dp/agent/adapter/adk/utils.py,sha256=UPCTpvAUCV2V1o0V8dmmFWbiLuUf6fJLIvVX68M3L-M,7698
|
|
6
6
|
dp/agent/adapter/adk/client/__init__.py,sha256=F1xfFNa4ZG8jV9adeGI2D3YBiSX-5RkvqEdTqNdJce4,209
|
|
7
|
-
dp/agent/adapter/adk/client/calculation_mcp_tool.py,sha256=
|
|
7
|
+
dp/agent/adapter/adk/client/calculation_mcp_tool.py,sha256=VDiDSEDsOYduGuCE1mp2cmOoDkdyfHhaTFhNRv0GnMY,12873
|
|
8
8
|
dp/agent/adapter/camel/__init__.py,sha256=RN1NhdmsJyN43fTxTXFld4UKZksjpSV0b2QvFn5gK7o,77
|
|
9
9
|
dp/agent/adapter/camel/client/__init__.py,sha256=ld-r0_WsZLFv6yyrmxjWmR8JgnrQzOw4fX0hwVHzciY,93
|
|
10
10
|
dp/agent/adapter/camel/client/calculation_mcp_client.py,sha256=JZZUYYfMgXvHzK4f6IJp-ia33wn3aYZqDSDVa5yKtdc,1860
|
|
@@ -51,7 +51,7 @@ dp/agent/cli/templates/ui/server/session_manager.py,sha256=ZbNHGCFvswa-LKWn6c6RM
|
|
|
51
51
|
dp/agent/cli/templates/ui/server/user_files.py,sha256=khkiyY2UOOysHqO6JgCPUDqtrInp83G1M62i3Lj-0aY,2995
|
|
52
52
|
dp/agent/cli/templates/ui/server/utils.py,sha256=f4NfwFBq_RdZyFn_KCW6ZThYW8TvQyVruK7PJZ-DA80,1530
|
|
53
53
|
dp/agent/client/__init__.py,sha256=yu7HYZwAkD7g5dL9JttLkGmspBcyOf-6OoCjci4oPDA,59
|
|
54
|
-
dp/agent/client/mcp_client.py,sha256=
|
|
54
|
+
dp/agent/client/mcp_client.py,sha256=ZWsegHF_ar8IdRHfG_w6smdSNgmIc9I25rz8Eh4cdZA,6469
|
|
55
55
|
dp/agent/cloud/__init__.py,sha256=e16ymCZX2f-S8DyGB5jSK8gnQqVObRIsvtLXLALIKxQ,441
|
|
56
56
|
dp/agent/cloud/main.py,sha256=5QIEjpZ1RxWnR8wyLf-vlgz1bn9oOnxCYn158LBaLN4,727
|
|
57
57
|
dp/agent/cloud/mcp.py,sha256=tsAwC3doVMLYr6Oh8PxVqF-qCygYkDZJTIhoF_h8eGQ,4537
|
|
@@ -62,21 +62,21 @@ dp/agent/device/device/__init__.py,sha256=w7_1S16S1vWUq0RGl0GFgjq2vFkc5oNvy8cQTn
|
|
|
62
62
|
dp/agent/device/device/device.py,sha256=9ZRIJth-4qMO-i-u_b_cO3d6a4eTbTQjPaxFsV_zEkc,9643
|
|
63
63
|
dp/agent/device/device/types.py,sha256=JuxB-hjf1CjjvfBxCLwRAXVFlYS-nPEdiJpBWLFVCzo,1924
|
|
64
64
|
dp/agent/server/__init__.py,sha256=rckaYd8pbYyB4ENEhgjXKeGMXjdnrgcJpdM1gu5u1Wc,508
|
|
65
|
-
dp/agent/server/calculation_mcp_server.py,sha256=
|
|
65
|
+
dp/agent/server/calculation_mcp_server.py,sha256=L07b0JNMkEjF6UvdKWTkRB14yehXo8QoU4or7lCwiNw,18618
|
|
66
66
|
dp/agent/server/preprocessor.py,sha256=XUWu7QOwo_sIDMYS2b1OTrM33EXEVH_73vk-ju1Ok8A,1264
|
|
67
67
|
dp/agent/server/utils.py,sha256=cIKaAg8UaP5yMwvIVTgUVBjy-B3S16bEdnucUf4UDIM,2055
|
|
68
68
|
dp/agent/server/executor/__init__.py,sha256=s95M5qKQk39Yi9qaVJZhk_nfj54quSf7EDghR3OCFUA,248
|
|
69
69
|
dp/agent/server/executor/base_executor.py,sha256=nR2jI-wFvKoOk8QaK11pnSAkHj2MsE6uyzPWDx-vgJA,3018
|
|
70
70
|
dp/agent/server/executor/dispatcher_executor.py,sha256=CZRxbVkLaDvStXhNaMKrKcx2Z0tPPVzIxkU1ufqWgYc,12081
|
|
71
|
-
dp/agent/server/executor/local_executor.py,sha256=
|
|
71
|
+
dp/agent/server/executor/local_executor.py,sha256=qRVnfqhvaCGBXr-NO4uxcUteFja2BE_6NXauVJ8vnoo,6642
|
|
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.116.dist-info/METADATA,sha256=KycMnrdj1v0eud8EOYzXhMSPX6ISX0rE8aPNou4oJlk,11070
|
|
79
|
+
bohr_agent_sdk-0.1.116.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
80
|
+
bohr_agent_sdk-0.1.116.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
|
|
81
|
+
bohr_agent_sdk-0.1.116.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
|
|
82
|
+
bohr_agent_sdk-0.1.116.dist-info/RECORD,,
|
|
@@ -93,16 +93,19 @@ class CalculationMCPTool(MCPTool):
|
|
|
93
93
|
async def run_async(self, args, tool_context: ToolContext, **kwargs):
|
|
94
94
|
# TODO: add progress callback when run_async
|
|
95
95
|
args = deepcopy(args)
|
|
96
|
-
if self.override
|
|
96
|
+
if self.override:
|
|
97
97
|
args["executor"] = self.executor
|
|
98
|
-
if self.override or "storage" not in args:
|
|
99
98
|
args["storage"] = self.storage
|
|
99
|
+
if not args.get("executor"):
|
|
100
|
+
args.pop("executor", None)
|
|
101
|
+
if not args.get("storage"):
|
|
102
|
+
args.pop("storage", None)
|
|
100
103
|
if not self.async_mode and self.wait:
|
|
101
104
|
return await super().run_async(
|
|
102
105
|
args=args, tool_context=tool_context, **kwargs)
|
|
103
106
|
|
|
104
|
-
executor = args
|
|
105
|
-
storage = args
|
|
107
|
+
executor = args.get("executor")
|
|
108
|
+
storage = args.get("storage")
|
|
106
109
|
res = await self.submit_tool.run_async(
|
|
107
110
|
args=args, tool_context=tool_context, **kwargs)
|
|
108
111
|
if isinstance(res, dict):
|
dp/agent/client/mcp_client.py
CHANGED
|
@@ -160,3 +160,10 @@ class MCPClient:
|
|
|
160
160
|
|
|
161
161
|
async def cleanup(self):
|
|
162
162
|
await self.exit_stack.aclose()
|
|
163
|
+
|
|
164
|
+
async def __aenter__(self):
|
|
165
|
+
await self.connect_to_server()
|
|
166
|
+
return self
|
|
167
|
+
|
|
168
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
169
|
+
await self.cleanup()
|
|
@@ -371,7 +371,7 @@ class CalculationMCPServer:
|
|
|
371
371
|
self.mcp._tool_manager._tools[tool.name] = tool
|
|
372
372
|
return tool
|
|
373
373
|
|
|
374
|
-
def tool(self, preprocess_func=None):
|
|
374
|
+
def tool(self, preprocess_func=None, create_workdir=True):
|
|
375
375
|
if preprocess_func is None:
|
|
376
376
|
preprocess_func = self.preprocess_func
|
|
377
377
|
|
|
@@ -381,7 +381,8 @@ class CalculationMCPServer:
|
|
|
381
381
|
**kwargs) -> SubmitResult:
|
|
382
382
|
trace_id = datetime.today().strftime('%Y-%m-%d-%H:%M:%S.%f')
|
|
383
383
|
logger.info("Job processing (Trace ID: %s)" % trace_id)
|
|
384
|
-
|
|
384
|
+
workdir = trace_id if create_workdir else "."
|
|
385
|
+
with set_directory(workdir):
|
|
385
386
|
if preprocess_func is not None:
|
|
386
387
|
executor, storage, kwargs = preprocess_func(
|
|
387
388
|
executor, storage, kwargs)
|
|
@@ -397,7 +398,7 @@ class CalculationMCPServer:
|
|
|
397
398
|
executor_type, executor = init_executor(executor)
|
|
398
399
|
res = executor.submit(fn, kwargs)
|
|
399
400
|
exec_id = res["job_id"]
|
|
400
|
-
job_id = "%s/%s" % (
|
|
401
|
+
job_id = "%s/%s" % (workdir, exec_id)
|
|
401
402
|
logger.info("Job submitted (ID: %s)" % job_id)
|
|
402
403
|
result = SubmitResult(
|
|
403
404
|
job_id=job_id,
|
|
@@ -416,7 +417,8 @@ class CalculationMCPServer:
|
|
|
416
417
|
context = self.mcp.get_context()
|
|
417
418
|
trace_id = datetime.today().strftime('%Y-%m-%d-%H:%M:%S.%f')
|
|
418
419
|
logger.info("Job processing (Trace ID: %s)" % trace_id)
|
|
419
|
-
|
|
420
|
+
workdir = trace_id if create_workdir else "."
|
|
421
|
+
with set_directory(workdir):
|
|
420
422
|
if preprocess_func is not None:
|
|
421
423
|
executor, storage, kwargs = preprocess_func(
|
|
422
424
|
executor, storage, kwargs)
|
|
@@ -424,9 +426,9 @@ class CalculationMCPServer:
|
|
|
424
426
|
fn, kwargs, storage)
|
|
425
427
|
executor_type, executor = init_executor(executor)
|
|
426
428
|
res = await executor.async_run(
|
|
427
|
-
fn, kwargs, context,
|
|
429
|
+
fn, kwargs, context, workdir)
|
|
428
430
|
exec_id = res["job_id"]
|
|
429
|
-
job_id = "%s/%s" % (
|
|
431
|
+
job_id = "%s/%s" % (workdir, exec_id)
|
|
430
432
|
results = res["result"]
|
|
431
433
|
results, output_artifacts = handle_output_artifacts(
|
|
432
434
|
results, exec_id, storage)
|
|
@@ -32,13 +32,13 @@ class Tee(io.TextIOBase):
|
|
|
32
32
|
return len(text)
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def wrapped_fn(fn, kwargs,
|
|
35
|
+
def wrapped_fn(fn, kwargs, redirect_log=False):
|
|
36
36
|
pid = os.getpid()
|
|
37
37
|
# explicitly reload dflow config
|
|
38
38
|
reload_dflow_config()
|
|
39
|
-
if
|
|
39
|
+
if redirect_log:
|
|
40
40
|
stdout = sys.stdout
|
|
41
|
-
flog = open(
|
|
41
|
+
flog = open("%s.log" % pid, "w")
|
|
42
42
|
sys.stdout = Tee(flog, stdout)
|
|
43
43
|
try:
|
|
44
44
|
if inspect.iscoroutinefunction(fn):
|
|
@@ -46,11 +46,11 @@ def wrapped_fn(fn, kwargs, redirect_file=None):
|
|
|
46
46
|
else:
|
|
47
47
|
result = fn(**kwargs)
|
|
48
48
|
except Exception as e:
|
|
49
|
-
with open("err", "w") as f:
|
|
49
|
+
with open("%s.err" % pid, "w") as f:
|
|
50
50
|
f.write(str(e))
|
|
51
51
|
raise e
|
|
52
52
|
finally:
|
|
53
|
-
if
|
|
53
|
+
if redirect_log:
|
|
54
54
|
sys.stdout = stdout
|
|
55
55
|
flog.close()
|
|
56
56
|
with open("%s.txt" % pid, "w") as f:
|
|
@@ -111,15 +111,15 @@ class LocalExecutor(BaseExecutor):
|
|
|
111
111
|
old_env = self.set_env()
|
|
112
112
|
params = {"fn": fn, "kwargs": kwargs}
|
|
113
113
|
if self.dflow:
|
|
114
|
-
params["
|
|
114
|
+
params["redirect_log"] = True
|
|
115
115
|
p = Process(target=wrapped_fn, kwargs=params)
|
|
116
116
|
p.start()
|
|
117
117
|
extra_info = {}
|
|
118
118
|
if self.dflow:
|
|
119
119
|
while True:
|
|
120
120
|
alive = p.is_alive()
|
|
121
|
-
if os.path.isfile("log.
|
|
122
|
-
with open("log.
|
|
121
|
+
if os.path.isfile("%s.log" % p.pid):
|
|
122
|
+
with open("%s.log" % p.pid, "r") as f:
|
|
123
123
|
log = f.read()
|
|
124
124
|
match_id = re.search(DFLOW_ID_PATTERN, log)
|
|
125
125
|
match_link = re.search(DFLOW_LINK_PATTERN, log)
|
|
@@ -133,8 +133,8 @@ class LocalExecutor(BaseExecutor):
|
|
|
133
133
|
extra_info["workflow_link"] = wf_link
|
|
134
134
|
break
|
|
135
135
|
if not alive:
|
|
136
|
-
if os.path.isfile("err"):
|
|
137
|
-
with open("err", "r") as f:
|
|
136
|
+
if os.path.isfile("%s.err" % p.pid):
|
|
137
|
+
with open("%s.err" % p.pid, "r") as f:
|
|
138
138
|
err_msg = f.read()
|
|
139
139
|
else:
|
|
140
140
|
err_msg = "No workflow submitted"
|
|
@@ -175,8 +175,8 @@ class LocalExecutor(BaseExecutor):
|
|
|
175
175
|
if os.path.isfile("%s.txt" % job_id):
|
|
176
176
|
with open("%s.txt" % job_id, "r") as f:
|
|
177
177
|
return jsonpickle.loads(f.read())
|
|
178
|
-
elif os.path.isfile("err"):
|
|
179
|
-
with open("err", "r") as f:
|
|
178
|
+
elif os.path.isfile("%s.err" % job_id):
|
|
179
|
+
with open("%s.err" % job_id, "r") as f:
|
|
180
180
|
err_msg = f.read()
|
|
181
181
|
raise RuntimeError(err_msg)
|
|
182
182
|
return {}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|