oocana-python-executor 0.16.2__tar.gz → 0.16.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.16.2 → oocana_python_executor-0.16.3}/PKG-INFO +1 -1
  2. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/pyproject.toml +1 -1
  3. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/executor.py +9 -3
  4. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/matplot/oomol_matplot_helper.py +18 -7
  5. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/__init__.py +0 -0
  6. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/block.py +0 -0
  7. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/context.py +0 -0
  8. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/data.py +0 -0
  9. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/hook.py +0 -0
  10. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/logger.py +0 -0
  11. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/matplot/matplotlib_oomol/__init__.py +0 -0
  12. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/matplot/matplotlib_oomol/oomol.py +0 -0
  13. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/secret.py +0 -0
  14. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/service.py +0 -0
  15. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/topic.py +0 -0
  16. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/python_executor/utils.py +0 -0
  17. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.3}/tests/test_cli.py +0 -0
  18. {oocana_python_executor-0.16.2 → oocana_python_executor-0.16.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.16.2
3
+ Version: 0.16.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.16.2"
3
+ version = "0.16.3"
4
4
  authors = [
5
5
  { name = "l1shen", email = "lishen1635@gmail.com" },
6
6
  { name = "yleaf", email = "11785335+leavesster@users.noreply.github.com" },
@@ -49,7 +49,7 @@ def config_logger(session_id: str, identifier: str | None, output: Literal["cons
49
49
  logger.propagate = False
50
50
 
51
51
 
52
- async def run_executor(address: str, session_id: str, tmp_dir: str, package: str | None, session_dir: str, identifier: str | None = None):
52
+ async def run_executor(address: str, session_id: str, tmp_dir: str, package: str | None, session_dir: str, identifier: str | None = None, debug_port: int | None = None):
53
53
 
54
54
  if identifier is not None:
55
55
  mainframe = Mainframe(address, f"python-executor-id-{identifier}", logger)
@@ -146,7 +146,7 @@ async def run_executor(address: str, session_id: str, tmp_dir: str, package: str
146
146
  mainframe.subscribe(exit_report_topic(), service_exit)
147
147
  mainframe.subscribe(status_report_topic(), service_status)
148
148
 
149
- mainframe.notify_executor_ready(session_id, EXECUTOR_NAME, package, identifier)
149
+ mainframe.notify_executor_ready(session_id, package, identifier, debug_port)
150
150
 
151
151
  async def spawn_service(message: ServiceExecutePayload, service_hash: str):
152
152
  logger.info(f"create new service {message.get('dir')}")
@@ -256,6 +256,7 @@ def main():
256
256
  if len(unknown_args) > 0:
257
257
  logger.warning(f"receive unknown args: {unknown_args}")
258
258
 
259
+ debug_port = None
259
260
  if namespace.debug_port is not None and namespace.debug_port.isdigit():
260
261
  try:
261
262
  import debugpy
@@ -265,12 +266,17 @@ def main():
265
266
  logger.info("wait for client to connect")
266
267
  debugpy.wait_for_client()
267
268
  logger.info("client connected")
269
+ debug_port = int(namespace.debug_port)
268
270
  except ImportError:
269
271
  logger.warning("Warning: debugpy not installed, debugging functionality will not be available")
272
+ debug_port = None
270
273
  except Exception as e:
271
274
  logger.warning(f"Warning: debugpy listen failed: {e}")
275
+ debug_port = None
276
+ else:
277
+ debug_port = None
272
278
 
273
- run_async_code(run_executor(address=address, tmp_dir=tmp_dir, session_id=session_id, package=package, session_dir=session_dir, identifier=identifier))
279
+ run_async_code(run_executor(address=address, tmp_dir=tmp_dir, session_id=session_id, package=package, session_dir=session_dir, identifier=identifier, debug_port=debug_port))
274
280
 
275
281
  if __name__ == '__main__':
276
282
  main()
@@ -1,4 +1,7 @@
1
1
  from python_executor.data import block_var
2
+ from logging import Logger
3
+
4
+ __all__ = ["add_matplot_module", "import_helper"]
2
5
 
3
6
  def add_matplot_module():
4
7
  import sys
@@ -6,13 +9,14 @@ def add_matplot_module():
6
9
  dir = os.path.dirname(os.path.abspath(__file__))
7
10
  sys.path.insert(0, dir)
8
11
 
9
- def import_helper(logger):
12
+
13
+ def setup_matplot(logger: Logger):
10
14
  # matplotlib 的 use() 替换
11
15
  try:
12
16
  import matplotlib # type: ignore
13
17
  matplotlib.use('module://matplotlib_oomol') # matplotlib_oomol.py 文件所在目录加入 PYTHONPATH
14
- except:
15
- logger.error("import matplotlib failed")
18
+ except Exception as e:
19
+ logger.warning("import matplotlib failed", e)
16
20
  return
17
21
 
18
22
  # matplotlib 主题替换
@@ -21,9 +25,11 @@ def import_helper(logger):
21
25
  import matplotlib.pyplot as plt # type: ignore
22
26
  plt.style.use("classic" if os.getenv("OOMOL_COLOR_SCHEME", "dark") == "light" else "dark_background")
23
27
  plt.rcParams['font.sans-serif'] = ['Source Han Sans SC']
24
- except:
25
- pass
28
+ except Exception as e:
29
+ logger.warning("matplotlib theme setup failed", e)
30
+
26
31
 
32
+ def setup_plotly(logger: Logger):
27
33
  # plotly 的 show() 替换
28
34
  try:
29
35
  import os
@@ -65,5 +71,10 @@ def import_helper(logger):
65
71
 
66
72
  renderers['oomol'] = OomolRenderer()
67
73
  renderers.default = 'oomol'
68
- except:
69
- logger.warning("import plotly failed")
74
+ except Exception as e:
75
+ logger.warning("import plotly failed", e)
76
+
77
+
78
+ def import_helper(logger: Logger):
79
+ setup_matplot(logger)
80
+ setup_plotly(logger)