oocana-python-executor 0.15.1__tar.gz → 0.15.3__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 (18) hide show
  1. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/PKG-INFO +1 -1
  2. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/pyproject.toml +1 -1
  3. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/executor.py +10 -10
  4. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/__init__.py +0 -0
  5. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/block.py +0 -0
  6. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/context.py +0 -0
  7. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/data.py +0 -0
  8. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/hook.py +0 -0
  9. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/logger.py +0 -0
  10. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/matplot/matplotlib_oomol/__init__.py +0 -0
  11. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/matplot/matplotlib_oomol/oomol.py +0 -0
  12. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/matplot/oomol_matplot_helper.py +0 -0
  13. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/secret.py +0 -0
  14. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/service.py +0 -0
  15. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/topic.py +0 -0
  16. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/python_executor/utils.py +0 -0
  17. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/tests/test_cli.py +0 -0
  18. {oocana_python_executor-0.15.1 → oocana_python_executor-0.15.3}/tests/test_secret.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oocana-python-executor
3
- Version: 0.15.1
3
+ Version: 0.15.3
4
4
  Summary: a client subscribe mqtt topic to execute oocana's block
5
5
  Author-Email: l1shen <lishen1635@gmail.com>, yleaf <11785335+leavesster@users.noreply.github.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "oocana-python-executor"
3
- version = "0.15.1"
3
+ version = "0.15.3"
4
4
  authors = [
5
5
  { name = "l1shen", email = "lishen1635@gmail.com" },
6
6
  { name = "yleaf", email = "11785335+leavesster@users.noreply.github.com" },
@@ -5,7 +5,6 @@ import os
5
5
  import queue
6
6
  import sys
7
7
  import logging
8
- import re
9
8
  from . import hook
10
9
  from oocana import Mainframe, ServiceExecutePayload
11
10
  from .utils import run_in_new_thread, run_async_code, oocana_dir
@@ -50,7 +49,7 @@ def config_logger(session_id: str, suffix: str | None, output: Literal["console"
50
49
  logger.propagate = False
51
50
 
52
51
 
53
- async def run_executor(address: str, session_id: str, package: str | None, session_dir: str, suffix: str | None = None):
52
+ async def run_executor(address: str, session_id: str, package: str | None, session_dir: str, suffix: str | None = None, identifier: str | None = None):
54
53
 
55
54
  if suffix is not None:
56
55
  mainframe = Mainframe(address, f"python-executor-{suffix}", logger)
@@ -69,8 +68,7 @@ async def run_executor(address: str, session_id: str, package: str | None, sessi
69
68
 
70
69
  # add package to sys.path
71
70
  if package is not None:
72
- # TODO: compatibility for package with prefix. e.g. package-/app/workspace. remove it after new version of oocana
73
- sys.path.append(re.sub(r"^.*?/", "/", package))
71
+ sys.path.append(package)
74
72
  elif os.path.exists("/app/workspace"):
75
73
  sys.path.append("/app/workspace")
76
74
 
@@ -78,8 +76,8 @@ async def run_executor(address: str, session_id: str, package: str | None, sessi
78
76
  def not_current_session(message):
79
77
  return message.get("session_id") != session_id
80
78
 
81
- def not_current_package(message):
82
- return message.get("package") != package
79
+ def not_current_job(message):
80
+ return message.get("identifier") != identifier
83
81
 
84
82
  # 目前的 mqtt 库,在 subscribe 回调里 publish 消息会导致死锁无法工作,参考 https://github.com/eclipse/paho.mqtt.python/issues/527 或者 https://stackoverflow.com/a/36964192/4770006
85
83
  # 通过这种方式来绕过,所有需要 callback 后 publish message 的情况,都需要使用 future 类似方式来绕过。
@@ -90,7 +88,7 @@ async def run_executor(address: str, session_id: str, package: str | None, sessi
90
88
  if not_current_session(message):
91
89
  return
92
90
 
93
- if not_current_package(message):
91
+ if not_current_job(message):
94
92
  return
95
93
 
96
94
  # https://github.com/oomol/oocana-rust/issues/310 临时解决方案
@@ -109,7 +107,7 @@ async def run_executor(address: str, session_id: str, package: str | None, sessi
109
107
  if not_current_session(message):
110
108
  return
111
109
 
112
- if not_current_package(message):
110
+ if not_current_job(message):
113
111
  return
114
112
 
115
113
  nonlocal fs
@@ -146,7 +144,7 @@ async def run_executor(address: str, session_id: str, package: str | None, sessi
146
144
  mainframe.subscribe(exit_report_topic(), service_exit)
147
145
  mainframe.subscribe(status_report_topic(), service_status)
148
146
 
149
- mainframe.notify_executor_ready(session_id, EXECUTOR_NAME, package)
147
+ mainframe.notify_executor_ready(session_id, EXECUTOR_NAME, package, identifier)
150
148
 
151
149
  async def spawn_service(message: ServiceExecutePayload, service_hash: str):
152
150
  logger.info(f"create new service {message.get('dir')}")
@@ -230,6 +228,7 @@ def main():
230
228
  parser.add_argument("--session-dir", help="a tmp dir for whole session", required=True)
231
229
  parser.add_argument("--output", help="output log to console or file", default="file", choices=["console", "file"])
232
230
  parser.add_argument("--package", help="package path, if set, executor will only run same package block", default=None)
231
+ parser.add_argument("--identifier", help="identifier for executor, oocana will think same identifier as one executor", default=None)
233
232
  parser.add_argument("--suffix", help="suffix for log file", default=None)
234
233
 
235
234
  args = parser.parse_args()
@@ -240,10 +239,11 @@ def main():
240
239
  package: str | None = args.package
241
240
  suffix: str | None = args.suffix
242
241
  session_dir: str = args.session_dir
242
+ identifier: str | None = args.identifier
243
243
 
244
244
  config_logger(session_id, suffix, output)
245
245
 
246
- run_async_code(run_executor(address=address, session_id=session_id, package=package, session_dir=session_dir, suffix=suffix))
246
+ run_async_code(run_executor(address=address, session_id=session_id, package=package, session_dir=session_dir, suffix=suffix, identifier=identifier))
247
247
 
248
248
  if __name__ == '__main__':
249
249
  main()