bohr-agent-sdk 0.1.107__py3-none-any.whl → 0.1.109__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bohr-agent-sdk
3
- Version: 0.1.107
3
+ Version: 0.1.109
4
4
  Summary: SDK for scientific agents
5
5
  Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
6
6
  Author: DP Technology
@@ -62,7 +62,7 @@ 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=wyOutOTlQEBIJUQQFUFBGE18rQL5fUnjKu88NxbIlhQ,12703
65
+ dp/agent/server/calculation_mcp_server.py,sha256=hsTxuguyqgq_4HSeJYS7VnW-jTvqf9DI0mpvRj0wK3w,13566
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
@@ -75,8 +75,8 @@ dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mm
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.107.dist-info/METADATA,sha256=YDcLpn0uLCRpNsAOCW46X8v7-HRiwp2g_DTIHD_99_4,11070
79
- bohr_agent_sdk-0.1.107.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
- bohr_agent_sdk-0.1.107.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
- bohr_agent_sdk-0.1.107.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
- bohr_agent_sdk-0.1.107.dist-info/RECORD,,
78
+ bohr_agent_sdk-0.1.109.dist-info/METADATA,sha256=B9SUVukVXm_P3E8ZWP41ApkenlCwobucnf9DSN_F2Ds,11070
79
+ bohr_agent_sdk-0.1.109.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
80
+ bohr_agent_sdk-0.1.109.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
81
+ bohr_agent_sdk-0.1.109.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
82
+ bohr_agent_sdk-0.1.109.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  import inspect
2
+ import json
2
3
  import os
3
4
  from collections.abc import Callable
4
5
  from contextlib import contextmanager
@@ -64,6 +65,20 @@ def set_directory(workdir: str):
64
65
  os.chdir(cwd)
65
66
 
66
67
 
68
+ def load_executor(executor):
69
+ if not executor and os.path.exists("executor.json"):
70
+ with open("executor.json", "r") as f:
71
+ executor = json.load(f)
72
+ return executor
73
+
74
+
75
+ def load_storage(storage):
76
+ if not storage and os.path.exists("storage.json"):
77
+ with open("storage.json", "r") as f:
78
+ storage = json.load(f)
79
+ return storage
80
+
81
+
67
82
  def query_job_status(job_id: str, executor: Optional[dict] = None
68
83
  ) -> Literal["Running", "Succeeded", "Failed"]:
69
84
  """
@@ -75,6 +90,7 @@ def query_job_status(job_id: str, executor: Optional[dict] = None
75
90
  """
76
91
  trace_id, exec_id = job_id.split("/")
77
92
  with set_directory(trace_id):
93
+ executor = load_executor(executor)
78
94
  _, executor = init_executor(executor)
79
95
  status = executor.query_status(exec_id)
80
96
  logger.info("Job %s status is %s" % (job_id, status))
@@ -89,6 +105,7 @@ def terminate_job(job_id: str, executor: Optional[dict] = None):
89
105
  """
90
106
  trace_id, exec_id = job_id.split("/")
91
107
  with set_directory(trace_id):
108
+ executor = load_executor(executor)
92
109
  _, executor = init_executor(executor)
93
110
  executor.terminate(exec_id)
94
111
  logger.info("Job %s is terminated" % job_id)
@@ -151,6 +168,8 @@ def get_job_results(job_id: str, executor: Optional[dict] = None,
151
168
  """
152
169
  trace_id, exec_id = job_id.split("/")
153
170
  with set_directory(trace_id):
171
+ executor = load_executor(executor)
172
+ storage = load_storage(storage)
154
173
  _, executor = init_executor(executor)
155
174
  results = executor.get_results(exec_id)
156
175
  results, output_artifacts = handle_output_artifacts(
@@ -249,6 +268,12 @@ class CalculationMCPServer:
249
268
  if preprocess_func is not None:
250
269
  executor, storage, kwargs = preprocess_func(
251
270
  executor, storage, kwargs)
271
+ if executor:
272
+ with open("executor.json", "w") as f:
273
+ json.dump(executor, f, indent=4)
274
+ if storage:
275
+ with open("storage.json", "w") as f:
276
+ json.dump(storage, f, indent=4)
252
277
  kwargs, input_artifacts = handle_input_artifacts(
253
278
  fn, kwargs, storage)
254
279
  executor_type, executor = init_executor(executor)