bohr-agent-sdk 0.1.114__tar.gz → 0.1.116__tar.gz

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.
Files changed (89) hide show
  1. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/PKG-INFO +1 -1
  2. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/setup.py +1 -1
  3. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/PKG-INFO +1 -1
  4. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/adk/client/calculation_mcp_tool.py +7 -4
  5. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/client/mcp_client.py +7 -0
  6. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/calculation_mcp_server.py +8 -6
  7. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/executor/local_executor.py +12 -12
  8. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/README.md +0 -0
  9. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/pyproject.toml +0 -0
  10. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/setup.cfg +0 -0
  11. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/SOURCES.txt +0 -0
  12. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/dependency_links.txt +0 -0
  13. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/entry_points.txt +0 -0
  14. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/requires.txt +0 -0
  15. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/bohr_agent_sdk.egg-info/top_level.txt +0 -0
  16. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/__init__.py +0 -0
  17. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/__init__.py +0 -0
  18. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/adk/__init__.py +0 -0
  19. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/adk/client/__init__.py +0 -0
  20. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/adk/storage_artifact_service.py +0 -0
  21. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/adk/utils.py +0 -0
  22. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/camel/__init__.py +0 -0
  23. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/camel/client/__init__.py +0 -0
  24. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/adapter/camel/client/calculation_mcp_client.py +0 -0
  25. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/__init__.py +0 -0
  26. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/cli.py +0 -0
  27. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/__init__.py +0 -0
  28. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/calculation/simple.py.template +0 -0
  29. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/device/tescan_device.py.template +0 -0
  30. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/main.py.template +0 -0
  31. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/__init__.py +0 -0
  32. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/__init__.py +0 -0
  33. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/config.py +0 -0
  34. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/constants.py +0 -0
  35. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/debug.py +0 -0
  36. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/files.py +0 -0
  37. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/files_upload.py +0 -0
  38. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/files_user.py +0 -0
  39. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/messages.py +0 -0
  40. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/projects.py +0 -0
  41. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/sessions.py +0 -0
  42. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/utils.py +0 -0
  43. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/api/websocket.py +0 -0
  44. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/config/__init__.py +0 -0
  45. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/config/agent_config.py +0 -0
  46. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/index.html +0 -0
  47. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/package.json +0 -0
  48. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/tsconfig.json +0 -0
  49. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/tsconfig.node.json +0 -0
  50. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DdAmKhul.js +0 -0
  51. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DfN2raU9.css +0 -0
  52. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/ui-static/index.html +0 -0
  53. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/frontend/vite.config.ts +0 -0
  54. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/scripts/build_ui.py +0 -0
  55. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/__init__.py +0 -0
  56. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/app.py +0 -0
  57. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/connection.py +0 -0
  58. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/file_watcher.py +0 -0
  59. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/middleware.py +0 -0
  60. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/models.py +0 -0
  61. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/session_manager.py +0 -0
  62. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/user_files.py +0 -0
  63. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/server/utils.py +0 -0
  64. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/test_download.py +0 -0
  65. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/ui_utils.py +0 -0
  66. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cli/templates/ui/websocket-server.py +0 -0
  67. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/client/__init__.py +0 -0
  68. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cloud/__init__.py +0 -0
  69. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cloud/main.py +0 -0
  70. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cloud/mcp.py +0 -0
  71. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/cloud/mqtt.py +0 -0
  72. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/device/__init__.py +0 -0
  73. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/device/device/__init__.py +0 -0
  74. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/device/device/device.py +0 -0
  75. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/device/device/types.py +0 -0
  76. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/device/mqtt_device_twin.py +0 -0
  77. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/__init__.py +0 -0
  78. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/executor/__init__.py +0 -0
  79. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/executor/base_executor.py +0 -0
  80. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/executor/dispatcher_executor.py +0 -0
  81. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/preprocessor.py +0 -0
  82. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/__init__.py +0 -0
  83. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/base_storage.py +0 -0
  84. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/bohrium_storage.py +0 -0
  85. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/http_storage.py +0 -0
  86. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/local_storage.py +0 -0
  87. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/storage/oss_storage.py +0 -0
  88. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/src/dp/agent/server/utils.py +0 -0
  89. {bohr_agent_sdk-0.1.114 → bohr_agent_sdk-0.1.116}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.114
3
+ Version: 0.1.116
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
9
9
 
10
10
  setup(
11
11
  name="bohr-agent-sdk",
12
- version="0.1.114",
12
+ version="0.1.116",
13
13
  description="SDK for science agent and mcp tools",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.114
3
+ Version: 0.1.116
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -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 or "executor" not in args:
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["executor"]
105
- storage = args["storage"]
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):
@@ -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
- with set_directory(trace_id):
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" % (trace_id, exec_id)
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
- with set_directory(trace_id):
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, trace_id)
429
+ fn, kwargs, context, workdir)
428
430
  exec_id = res["job_id"]
429
- job_id = "%s/%s" % (trace_id, exec_id)
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, redirect_file=None):
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 redirect_file:
39
+ if redirect_log:
40
40
  stdout = sys.stdout
41
- flog = open(redirect_file, "w")
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 redirect_file:
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["redirect_file"] = "log.txt"
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.txt"):
122
- with open("log.txt", "r") as f:
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 {}