oocana-python-executor 0.15.3__tar.gz → 0.15.4__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.
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/PKG-INFO +1 -1
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/pyproject.toml +1 -1
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/executor.py +17 -13
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/__init__.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/block.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/context.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/data.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/hook.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/logger.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/matplot/matplotlib_oomol/__init__.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/matplot/matplotlib_oomol/oomol.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/matplot/oomol_matplot_helper.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/secret.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/service.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/topic.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/python_executor/utils.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/tests/test_cli.py +0 -0
- {oocana_python_executor-0.15.3 → oocana_python_executor-0.15.4}/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.
|
|
3
|
+
Version: 0.15.4
|
|
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
|
|
@@ -19,9 +19,9 @@ service_store: dict[str, Literal["launching", "running"]] = {}
|
|
|
19
19
|
job_set = set()
|
|
20
20
|
|
|
21
21
|
# 日志目录 ~/.oocana/sessions/{session_id}
|
|
22
|
-
# executor 的日志都会记录在 [python-executor-{
|
|
23
|
-
# 全局 logger 会记录在 python-{
|
|
24
|
-
def config_logger(session_id: str,
|
|
22
|
+
# executor 的日志都会记录在 [python-executor-{identifier}.log | python-executor.log]
|
|
23
|
+
# 全局 logger 会记录在 python-{identifier}.log | python.log
|
|
24
|
+
def config_logger(session_id: str, identifier: str | None, output: Literal["console", "file"]):
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
format = '%(asctime)s - %(levelname)s - {%(pathname)s:%(lineno)d} - %(message)s'
|
|
@@ -29,7 +29,7 @@ def config_logger(session_id: str, suffix: str | None, output: Literal["console"
|
|
|
29
29
|
logger.setLevel(logging.DEBUG)
|
|
30
30
|
if output == "file":
|
|
31
31
|
executor_dir = os.path.join(oocana_dir(), "sessions", session_id)
|
|
32
|
-
logger_file = os.path.join(executor_dir, f"python-executor-{
|
|
32
|
+
logger_file = os.path.join(executor_dir, f"python-executor-{identifier}.log") if identifier is not None else os.path.join(executor_dir, "python-executor.log")
|
|
33
33
|
|
|
34
34
|
if not os.path.exists(logger_file):
|
|
35
35
|
os.makedirs(os.path.dirname(logger_file), exist_ok=True)
|
|
@@ -37,7 +37,7 @@ def config_logger(session_id: str, suffix: str | None, output: Literal["console"
|
|
|
37
37
|
print(f"setup logging in file {logger_file}")
|
|
38
38
|
h = logging.FileHandler(logger_file)
|
|
39
39
|
|
|
40
|
-
global_logger_file = os.path.join(executor_dir, f"python-{
|
|
40
|
+
global_logger_file = os.path.join(executor_dir, f"python-{identifier}.log") if identifier is not None else os.path.join(executor_dir, "python.log")
|
|
41
41
|
logging.basicConfig(filename=global_logger_file, level=logging.DEBUG, format=format)
|
|
42
42
|
else:
|
|
43
43
|
logging.basicConfig(level=logging.DEBUG, format=format)
|
|
@@ -49,10 +49,10 @@ def config_logger(session_id: str, suffix: str | None, output: Literal["console"
|
|
|
49
49
|
logger.propagate = False
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
async def run_executor(address: str, session_id: str, package: str | None, session_dir: str,
|
|
52
|
+
async def run_executor(address: str, session_id: str, package: str | None, session_dir: str, identifier: str | None = None):
|
|
53
53
|
|
|
54
|
-
if
|
|
55
|
-
mainframe = Mainframe(address, f"python-executor-{
|
|
54
|
+
if identifier is not None:
|
|
55
|
+
mainframe = Mainframe(address, f"python-executor-id-{identifier}", logger)
|
|
56
56
|
else:
|
|
57
57
|
mainframe = Mainframe(address, f"python-executor-{session_id}", logger)
|
|
58
58
|
|
|
@@ -229,21 +229,25 @@ def main():
|
|
|
229
229
|
parser.add_argument("--output", help="output log to console or file", default="file", choices=["console", "file"])
|
|
230
230
|
parser.add_argument("--package", help="package path, if set, executor will only run same package block", default=None)
|
|
231
231
|
parser.add_argument("--identifier", help="identifier for executor, oocana will think same identifier as one executor", default=None)
|
|
232
|
-
parser.add_argument("--suffix", help="suffix for log file", default=None)
|
|
233
232
|
|
|
234
|
-
|
|
233
|
+
try:
|
|
234
|
+
args = parser.parse_args()
|
|
235
|
+
except Exception as e:
|
|
236
|
+
print(f"parse args error: {e}")
|
|
237
|
+
# because we hook sys.exit in hook.py and raise a exception, the exit will be reset to 1.
|
|
238
|
+
# parser origin exit code is 2. so we use 2 here.
|
|
239
|
+
sys.exit(2)
|
|
235
240
|
|
|
236
241
|
address: str = args.address
|
|
237
242
|
session_id: str = str(args.session_id)
|
|
238
243
|
output: Literal["console", "file"] = args.output
|
|
239
244
|
package: str | None = args.package
|
|
240
|
-
suffix: str | None = args.suffix
|
|
241
245
|
session_dir: str = args.session_dir
|
|
242
246
|
identifier: str | None = args.identifier
|
|
243
247
|
|
|
244
|
-
config_logger(session_id,
|
|
248
|
+
config_logger(session_id, identifier, output)
|
|
245
249
|
|
|
246
|
-
run_async_code(run_executor(address=address, session_id=session_id, package=package, session_dir=session_dir,
|
|
250
|
+
run_async_code(run_executor(address=address, session_id=session_id, package=package, session_dir=session_dir, identifier=identifier))
|
|
247
251
|
|
|
248
252
|
if __name__ == '__main__':
|
|
249
253
|
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|