osis-python 0.8.5__tar.gz → 0.8.7__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.
- {osis_python-0.8.5/src/osis_python.egg-info → osis_python-0.8.7}/PKG-INFO +1 -1
- {osis_python-0.8.5 → osis_python-0.8.7/src/osis_python.egg-info}/PKG-INFO +1 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/__init__.py +1 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/control/io.py +7 -3
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/control/manager.py +4 -2
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/__init__.py +1 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/batch.py +12 -3
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/client.py +0 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/command.py +65 -14
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/engine.py +11 -7
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/general/interface.py +7 -9
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/post/combine.py +5 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/post/design_check.py +5 -1
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/post/manager.py +12 -4
- {osis_python-0.8.5 → osis_python-0.8.7}/LICENSE +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/README.md +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/pyproject.toml +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/setup.cfg +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/osis_python.egg-info/SOURCES.txt +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/osis_python.egg-info/dependency_links.txt +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/osis_python.egg-info/requires.txt +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/osis_python.egg-info/top_level.txt +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/boundary/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/boundary/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/boundary/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/control/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/control/control.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/control/nonlinear.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/all_func.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/apdl_sync.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/basic_manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/enums.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/exceptions.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/normalize.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/references.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/sdk.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/solver.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/core/sync_apdl_cli.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/display/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/display/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/display/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/dynamic/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/dynamic/load_to_mass.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/dynamic/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/dynamic/modal.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/dynamic/seismic.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/element/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/element/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/element/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/general/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/geometry/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/geometry/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/geometry/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/live/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/live/analysis.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/live/grade.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/live/lane.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/live/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/load/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/load/loadcase.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/load/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/load/static.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/load/tendon.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/material/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/material/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/material/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/node/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/node/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/node/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/post/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/post/display.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/project/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/project/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/project/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/component_thickness.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/coordinate.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/creep_shrink.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/damping.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/property/pu_curve.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/quick_building/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/quick_building/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/result/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/result/check.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/result/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/result/routes.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/common.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/composite.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/numeric.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/param.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/rebar.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/rib.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/section/steel.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/settlement/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/settlement/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/settlement/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stability/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stability/buckling.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stability/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stage/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stage/define.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stage/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/stage/overall.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/thickness/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/thickness/interface.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/thickness/manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/__init__.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/generator.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/introspect.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/matrix.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/out_to_python.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/parser.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/routes.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/src/pyosis/transfer/split.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/tests/test_batch.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/tests/test_delete_occupied.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/tests/test_project_manager.py +0 -0
- {osis_python-0.8.5 → osis_python-0.8.7}/tests/test_transfer_fixups.py +0 -0
|
@@ -7,7 +7,7 @@ A library for extending OSIS functionality.
|
|
|
7
7
|
A library that allows users to use CAE with great flexibility.
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
__version__ = "0.8.
|
|
10
|
+
__version__ = "0.8.7"
|
|
11
11
|
|
|
12
12
|
from .core.engine import OSISEngine
|
|
13
13
|
from .core.batch import batch, flush, batch_state, BatchError
|
|
@@ -6,14 +6,18 @@ from ..core import REGISTRY
|
|
|
6
6
|
|
|
7
7
|
from typing import Literal, List, Tuple, Optional
|
|
8
8
|
|
|
9
|
-
@REGISTRY.register("APDL")
|
|
10
|
-
def osis_apdl(path):
|
|
9
|
+
@REGISTRY.register("APDL", timeout=3600)
|
|
10
|
+
def osis_apdl(path=None):
|
|
11
11
|
'''
|
|
12
12
|
输出前处理的当前状态,文件格式为.out
|
|
13
13
|
|
|
14
14
|
Args:
|
|
15
15
|
path: 路径,可缺省。格式:C:\\Temp\\OSIS.out
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
Note:
|
|
18
|
+
大模型导出耗时较长,HTTP 超时缺省给到 3600(60 分钟);
|
|
19
|
+
可用 set_timeout() 全局调整,或调用时传 timeout= 单独指定
|
|
20
|
+
|
|
17
21
|
Returns:
|
|
18
22
|
tuple (bool, str): 返回一个元组,包含:
|
|
19
23
|
- bool: 操作是否成功
|
|
@@ -85,11 +85,13 @@ class ControlManager:
|
|
|
85
85
|
if not ok:
|
|
86
86
|
raise RuntimeError(f"设置重力加速度失败: {err}")
|
|
87
87
|
|
|
88
|
-
def export_apdl(self, path: str | None = None) -> None:
|
|
88
|
+
def export_apdl(self, path: str | None = None, *, timeout: float | None = None) -> None:
|
|
89
89
|
'''导出当前前处理状态到 APDL .out 文件
|
|
90
90
|
|
|
91
91
|
Args:
|
|
92
92
|
path (str | None): 输出文件完整路径,可缺省;不传则使用程序当前路径
|
|
93
|
+
timeout (float): HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
94
|
+
未设置时用 APDL 命令的缺省值 3600
|
|
93
95
|
|
|
94
96
|
Returns:
|
|
95
97
|
None
|
|
@@ -97,7 +99,7 @@ class ControlManager:
|
|
|
97
99
|
Raises:
|
|
98
100
|
RuntimeError: 导出失败时抛出异常
|
|
99
101
|
'''
|
|
100
|
-
ok, err = osis_apdl(path)
|
|
102
|
+
ok, err = osis_apdl(path, timeout=timeout)
|
|
101
103
|
if not ok:
|
|
102
104
|
raise RuntimeError(f"导出 APDL 文件失败: {err}")
|
|
103
105
|
|
|
@@ -8,7 +8,7 @@ OSISEngine中的函数,将会分发到各个模块,被再次封装,意图
|
|
|
8
8
|
- 将函数命名格式转换成python的常用格式,便于人与AI的理解
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
from .command import REGISTRY, osis_run, set_run_mode
|
|
11
|
+
from .command import REGISTRY, osis_run, set_run_mode, set_timeout
|
|
12
12
|
from .client import set_osis_port, set_osis_url
|
|
13
13
|
from .batch import batch, flush, batch_state, BatchError
|
|
14
14
|
from .basic_manager import BasicManager, LazyRef
|
|
@@ -53,6 +53,7 @@ class _BatchState:
|
|
|
53
53
|
self.buffer: list[str] = [] # 已入队的命令流(每条自带分号终止符)
|
|
54
54
|
self.depth: int = 0 # batch 嵌套深度,>0 表示激活
|
|
55
55
|
self.flushing: bool = False # 冲刷进行中(防止拦截器递归冲刷)
|
|
56
|
+
self.timeout: float | None = None # set_timeout 的全局超时,冲刷时的兜底
|
|
56
57
|
|
|
57
58
|
@property
|
|
58
59
|
def active(self) -> bool:
|
|
@@ -79,7 +80,8 @@ def flush(
|
|
|
79
80
|
Args:
|
|
80
81
|
isolate (bool): 冲刷失败时是否二分定位失败命令(仅供调试,
|
|
81
82
|
无重试无退避;二分重放假设失败命令本身无副作用残留)
|
|
82
|
-
timeout (float): HTTP
|
|
83
|
+
timeout (float): HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
84
|
+
未设置时用 600(大批量 Execution 耗时较长)
|
|
83
85
|
max_size (int): 单次请求最大命令条数,默认不限(一次全发)。
|
|
84
86
|
超大模型可设 5000 之类的安全阀,将分多次请求发送
|
|
85
87
|
|
|
@@ -91,6 +93,8 @@ def flush(
|
|
|
91
93
|
'''
|
|
92
94
|
if batch_state.flushing or not batch_state.buffer:
|
|
93
95
|
return 0
|
|
96
|
+
if timeout is None:
|
|
97
|
+
timeout = batch_state.timeout if batch_state.timeout is not None else 600
|
|
94
98
|
cmds = batch_state.buffer[:]
|
|
95
99
|
batch_state.buffer.clear()
|
|
96
100
|
batch_state.flushing = True
|
|
@@ -142,7 +146,7 @@ def _send(cmds: list[str], isolate: bool = False, timeout: float | None = None)
|
|
|
142
146
|
# ──────────────────────────────────────────────
|
|
143
147
|
|
|
144
148
|
@contextmanager
|
|
145
|
-
def batch() -> Iterator[None]:
|
|
149
|
+
def batch(timeout: float | None = None) -> Iterator[None]:
|
|
146
150
|
'''batch 模式上下文:内部所有命令只进缓冲,退出时一次性发送
|
|
147
151
|
|
|
148
152
|
>>> with pyosis.batch():
|
|
@@ -151,6 +155,11 @@ def batch() -> Iterator[None]:
|
|
|
151
155
|
... element_manager.create_beam3d(None, 1, 2, 1, 1, 1)
|
|
152
156
|
... # 退出时 3 条命令拼成一条流,一次 HTTP 请求
|
|
153
157
|
|
|
158
|
+
Args:
|
|
159
|
+
timeout (float): 退出时冲刷的 HTTP 超时秒数;不传则用 set_timeout() 的
|
|
160
|
+
全局设置,未设置时用 600。缓冲内的命令在退出前不会执行,命令自带
|
|
161
|
+
的 timeout 无从生效,耗时命令请在此处指定
|
|
162
|
+
|
|
154
163
|
规则:
|
|
155
164
|
* 正常退出:自动 flush(),缓冲内全部命令一次执行
|
|
156
165
|
* 异常退出:丢弃本次进入后新增的缓冲命令并抛出原异常
|
|
@@ -170,4 +179,4 @@ def batch() -> Iterator[None]:
|
|
|
170
179
|
else:
|
|
171
180
|
batch_state.depth -= 1
|
|
172
181
|
if batch_state.depth == 0:
|
|
173
|
-
flush()
|
|
182
|
+
flush(timeout=timeout)
|
|
@@ -32,11 +32,14 @@ def osis_run(
|
|
|
32
32
|
mode: 运行模式,此参数为了同时执行多条命令提高效率
|
|
33
33
|
* 使用 stash 仅会将命令流存到OSIS中,不会执行
|
|
34
34
|
* 收到 exec 信号才会执行暂存包括当前的所有命令流。
|
|
35
|
-
timeout: HTTP
|
|
35
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
36
|
+
未设置时用 osis_client 的 DEFAULT_TIMEOUT
|
|
36
37
|
|
|
37
38
|
Returns:
|
|
38
39
|
tuple (bool, str): 是否成功,失败原因
|
|
39
40
|
"""
|
|
41
|
+
if timeout is None:
|
|
42
|
+
timeout = REGISTRY.timeout
|
|
40
43
|
response = osis_client(
|
|
41
44
|
"OSIS_Run",
|
|
42
45
|
{"strCmd": strCmd, "mode": mode},
|
|
@@ -123,50 +126,72 @@ class OSISFunctionRegistry:
|
|
|
123
126
|
... pass
|
|
124
127
|
>>> test_func("name", True, 1.0, None) # 组装成 test,name,1,1.0; # 参数值为None会被忽略
|
|
125
128
|
>>> test_func("name", True, "", 1) # 组装成 test,name,1,,1; # 需要空参数忽略参数类型填一个空字符串: ""
|
|
126
|
-
>>>
|
|
129
|
+
>>>
|
|
130
|
+
>>> # timeout 是命令流的保留参数,不写进命令流。任何命令都可以在调用时传,
|
|
131
|
+
>>> # 覆盖本次 HTTP 超时:
|
|
132
|
+
>>> osis_combine_solve(timeout=7200) # 只发 CombineSolve;
|
|
133
|
+
>>> # 耗时命令在注册时给出自己的缺省值(普通命令用 osis_client 的 300):
|
|
134
|
+
>>> @REGISTRY.register("CombineSolve", timeout=3600)
|
|
135
|
+
... def osis_combine_solve():
|
|
136
|
+
... '''计算组合和包络'''
|
|
137
|
+
... pass
|
|
138
|
+
|
|
127
139
|
|
|
128
|
-
|
|
129
140
|
"""
|
|
130
|
-
|
|
141
|
+
|
|
131
142
|
def __init__(self):
|
|
132
143
|
self.commands = {} # func_name -> info
|
|
133
144
|
self.run_mode = "exec" # 命令处理模式,默认执行
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
self.timeout = None # set_timeout 设的全局超时,None 时用各命令注册的缺省值
|
|
146
|
+
|
|
147
|
+
def register(self, cmd_name=None, timeout: float | None = None):
|
|
136
148
|
"""
|
|
137
149
|
注册函数装饰器
|
|
138
|
-
|
|
150
|
+
|
|
139
151
|
Args:
|
|
140
152
|
cmd_name: 命令名,不提供则使用函数名
|
|
153
|
+
timeout: 该命令的 HTTP 超时秒数缺省值,None 时用 osis_client 的
|
|
154
|
+
DEFAULT_TIMEOUT。耗时命令(求解、导出等)应显式给出
|
|
141
155
|
"""
|
|
142
156
|
def decorator(func):
|
|
143
157
|
name = cmd_name or func.__name__
|
|
144
|
-
|
|
158
|
+
register_timeout = timeout
|
|
159
|
+
|
|
145
160
|
# 保存函数信息
|
|
146
161
|
self.commands[func.__name__] = {
|
|
147
162
|
'func': func,
|
|
148
163
|
'name': func.__name__,
|
|
149
164
|
'cmd_name': name,
|
|
150
165
|
'doc': func.__doc__ or '',
|
|
151
|
-
'module': func.__module__
|
|
166
|
+
'module': func.__module__,
|
|
167
|
+
'timeout': timeout
|
|
152
168
|
}
|
|
153
|
-
|
|
169
|
+
|
|
154
170
|
# 创建包装函数
|
|
155
171
|
@functools.wraps(func)
|
|
156
172
|
def wrapper(*args, **kwargs): # 函数执行时,都会走这个路径
|
|
173
|
+
# timeout 是命令流的保留参数,不进命令流
|
|
174
|
+
call_timeout = kwargs.pop("timeout", None)
|
|
157
175
|
# 包装参数
|
|
158
176
|
cmd, _bound_args = self._process_arguments(func, cmd_name, *args, **kwargs)
|
|
177
|
+
timeout = self._resolve_timeout(call_timeout, register_timeout)
|
|
159
178
|
# batch 模式:进缓冲,退出上下文时统一发送
|
|
160
179
|
if batch_state.active:
|
|
161
180
|
batch_state.buffer.append(cmd)
|
|
162
181
|
return (True, "queued")
|
|
163
182
|
# 发送到软件
|
|
164
|
-
return self._execute_command(cmd)
|
|
183
|
+
return self._execute_command(cmd, timeout=timeout)
|
|
165
184
|
|
|
166
185
|
return wrapper
|
|
167
186
|
|
|
168
187
|
return decorator
|
|
169
188
|
|
|
189
|
+
def _resolve_timeout(self, call_timeout: float | None, register_timeout: float | None):
|
|
190
|
+
"""确定本次 HTTP 超时:调用时传入 > set_timeout 全局设置 > 注册时声明的缺省值"""
|
|
191
|
+
if call_timeout is not None:
|
|
192
|
+
return call_timeout
|
|
193
|
+
return self.timeout if self.timeout is not None else register_timeout
|
|
194
|
+
|
|
170
195
|
def _process_arguments(self, func, cmd_name, *args, **kwargs):
|
|
171
196
|
"""处理参数并生成命令字符串,同时返回绑定参数(供 batch 影子登记)"""
|
|
172
197
|
|
|
@@ -209,10 +234,10 @@ class OSISFunctionRegistry:
|
|
|
209
234
|
cmd = f"{cmd_name},{','.join(param_values)};" if len(param_values) != 0 else f"{cmd_name};"
|
|
210
235
|
return cmd, dict(bound.arguments)
|
|
211
236
|
|
|
212
|
-
def _execute_command(self, cmd) -> Tuple[bool, str, Any]:
|
|
237
|
+
def _execute_command(self, cmd, timeout: float | None = None) -> Tuple[bool, str, Any]:
|
|
213
238
|
"""执行命令(发送到软件)"""
|
|
214
239
|
# _log(cmd)
|
|
215
|
-
result = osis_run(cmd, "exec")
|
|
240
|
+
result = osis_run(cmd, "exec", timeout=timeout)
|
|
216
241
|
isok, error, *rest = result
|
|
217
242
|
return result
|
|
218
243
|
|
|
@@ -233,16 +258,42 @@ class OSISFunctionRegistry:
|
|
|
233
258
|
'''设置命令运行模式,默认是暂存,可以提高性能'''
|
|
234
259
|
self.run_mode = mode
|
|
235
260
|
|
|
261
|
+
def set_timeout(self, timeout: float | None = None):
|
|
262
|
+
'''设置所有命令流的默认 HTTP 超时秒数
|
|
263
|
+
|
|
264
|
+
Args:
|
|
265
|
+
timeout: 超时秒数;None 恢复为各命令注册时声明的缺省值
|
|
266
|
+
|
|
267
|
+
Note:
|
|
268
|
+
优先级:调用时传入的 timeout > 本设置 > 注册时声明的缺省值。
|
|
269
|
+
batch 冲刷同样受本设置影响(未设置时用 600)
|
|
270
|
+
'''
|
|
271
|
+
self.timeout = timeout
|
|
272
|
+
batch_state.timeout = timeout
|
|
273
|
+
|
|
236
274
|
# 全局函数注册表实例
|
|
237
275
|
REGISTRY = OSISFunctionRegistry() # 作用为提供python函数和命令流的映射关系,保证参数个数与顺序正常,python函数一定要注册一下
|
|
238
276
|
|
|
239
277
|
def set_run_mode(mode: Literal["stash", "exec"]="exec"):
|
|
240
278
|
'''
|
|
241
279
|
设置全局命令运行模式,默认是暂存,可以提高性能
|
|
242
|
-
|
|
280
|
+
|
|
243
281
|
Args:
|
|
244
282
|
mode: 运行模式,此参数为了同时执行多条命令提高效率
|
|
245
283
|
* 使用 stash 仅会将命令流存到OSIS中,不会执行
|
|
246
284
|
* 收到 exec 信号才会执行暂存包括当前的所有命令流。
|
|
247
285
|
'''
|
|
248
286
|
REGISTRY.set_run_mode(mode)
|
|
287
|
+
|
|
288
|
+
def set_timeout(timeout: float | None = None):
|
|
289
|
+
'''
|
|
290
|
+
设置所有命令流的默认 HTTP 超时秒数
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
timeout: 超时秒数;None 恢复为各命令注册时声明的缺省值
|
|
294
|
+
|
|
295
|
+
Note:
|
|
296
|
+
优先级:调用时传入的 timeout > 本设置 > 注册时声明的缺省值。
|
|
297
|
+
batch 冲刷同样受本设置影响(未设置时用 600)
|
|
298
|
+
'''
|
|
299
|
+
REGISTRY.set_timeout(timeout)
|
|
@@ -269,17 +269,18 @@ class OSISEngine:
|
|
|
269
269
|
# 通用操作(直接暴露 general 和 core 的函数)
|
|
270
270
|
# ──────────────────────────────────────────
|
|
271
271
|
|
|
272
|
-
def run(self, cmd: str = "") -> None:
|
|
272
|
+
def run(self, cmd: str = "", *, timeout: float | None = None) -> None:
|
|
273
273
|
"""执行 OSIS 命令流
|
|
274
274
|
|
|
275
275
|
Args:
|
|
276
276
|
cmd: 命令流字符串
|
|
277
|
-
|
|
277
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
278
|
+
未设置时用客户端缺省
|
|
278
279
|
|
|
279
280
|
Returns:
|
|
280
281
|
(success, error) 元组
|
|
281
282
|
"""
|
|
282
|
-
ok, err = osis_run(cmd)
|
|
283
|
+
ok, err = osis_run(cmd, timeout=timeout)
|
|
283
284
|
if not ok:
|
|
284
285
|
raise RuntimeError(f"执行失败: {err}")
|
|
285
286
|
|
|
@@ -287,7 +288,8 @@ class OSISEngine:
|
|
|
287
288
|
"""求解工程
|
|
288
289
|
|
|
289
290
|
Args:
|
|
290
|
-
timeout: HTTP
|
|
291
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
292
|
+
未设置时用 Solve 命令的缺省值 3600
|
|
291
293
|
"""
|
|
292
294
|
ok, err = osis_solve(timeout=timeout)
|
|
293
295
|
if not ok:
|
|
@@ -387,13 +389,15 @@ class OSISEngine:
|
|
|
387
389
|
# ──────────────────────────────────────────
|
|
388
390
|
# 便捷方法(委托给 control manager)
|
|
389
391
|
# ──────────────────────────────────────────
|
|
390
|
-
def export_apdl(self, path: str | None = None) -> None:
|
|
392
|
+
def export_apdl(self, path: str | None = None, *, timeout: float | None = None) -> None:
|
|
391
393
|
"""导出前处理状态为 .out 文件
|
|
392
|
-
|
|
394
|
+
|
|
393
395
|
Args:
|
|
394
396
|
path: 路径,可缺省。格式:C:\\Temp\\OSIS.out
|
|
397
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
398
|
+
未设置时用 APDL 命令的缺省值 3600
|
|
395
399
|
"""
|
|
396
|
-
self.control.export_apdl(path)
|
|
400
|
+
self.control.export_apdl(path, timeout=timeout)
|
|
397
401
|
|
|
398
402
|
def import_apdl(self, path: str) -> None:
|
|
399
403
|
"""读取 .out / .sml 文件
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Any, Dict, Literal, List, Union, Sequence
|
|
2
2
|
from ..core import REGISTRY, osis_run
|
|
3
|
-
from ..core.client import
|
|
3
|
+
from ..core.client import osis_client
|
|
4
4
|
|
|
5
5
|
def osis_matrix(matrix_name: str, matrix_data: Union[List, int, float, str]):
|
|
6
6
|
"""
|
|
@@ -144,18 +144,16 @@ def osis_clc():
|
|
|
144
144
|
"""
|
|
145
145
|
pass
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
@REGISTRY.register("Solve", timeout=3600)
|
|
148
|
+
def osis_solve():
|
|
148
149
|
"""
|
|
149
150
|
求解工程
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
Note:
|
|
153
|
+
模型大时耗时较长,HTTP 超时缺省给到 3600(60 分钟);
|
|
154
|
+
可用 set_timeout() 全局调整,或调用时传 timeout= 单独指定
|
|
153
155
|
|
|
154
156
|
Returns:
|
|
155
157
|
tuple (bool, str): 是否成功,失败原因
|
|
156
158
|
"""
|
|
157
|
-
|
|
158
|
-
"Solve;",
|
|
159
|
-
"exec",
|
|
160
|
-
timeout=timeout if timeout is not None else DEFAULT_SOLVE_TIMEOUT,
|
|
161
|
-
)
|
|
159
|
+
pass
|
|
@@ -74,10 +74,14 @@ def osis_combine_post(combine: Literal["Combine"], strCombineName: str, strAddCo
|
|
|
74
74
|
pass
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
@REGISTRY.register('CombineSolve')
|
|
77
|
+
@REGISTRY.register('CombineSolve', timeout=3600)
|
|
78
78
|
def osis_combine_solve():
|
|
79
79
|
"""计算组合和包络。
|
|
80
80
|
|
|
81
|
+
Note:
|
|
82
|
+
组合与包络数量多、模型大时耗时较长,HTTP 超时缺省给到 3600(60 分钟);
|
|
83
|
+
可用 set_timeout() 全局调整,或调用时传 timeout= 单独指定
|
|
84
|
+
|
|
81
85
|
Returns:
|
|
82
86
|
tuple (bool, str):
|
|
83
87
|
- bool: 操作是否成功
|
|
@@ -317,10 +317,14 @@ def osis_check_add(
|
|
|
317
317
|
pass
|
|
318
318
|
|
|
319
319
|
|
|
320
|
-
@REGISTRY.register('CheckSolve')
|
|
320
|
+
@REGISTRY.register('CheckSolve', timeout=3600)
|
|
321
321
|
def osis_check_solve():
|
|
322
322
|
"""计算验算作用。
|
|
323
323
|
|
|
324
|
+
Note:
|
|
325
|
+
验算项多、模型大时耗时较长,HTTP 超时缺省给到 3600(60 分钟);
|
|
326
|
+
可用 set_timeout() 全局调整,或调用时传 timeout= 单独指定
|
|
327
|
+
|
|
324
328
|
Returns:
|
|
325
329
|
tuple (bool, str):
|
|
326
330
|
- bool: 操作是否成功
|
|
@@ -130,13 +130,17 @@ class PostManager:
|
|
|
130
130
|
if not ok:
|
|
131
131
|
raise RuntimeError(f"往组合 {combine_name} 添加 {add_name} 失败: {err}")
|
|
132
132
|
|
|
133
|
-
def solve_combines(self) -> None:
|
|
133
|
+
def solve_combines(self, *, timeout: float | None = None) -> None:
|
|
134
134
|
"""计算组合和包络
|
|
135
135
|
|
|
136
|
+
Args:
|
|
137
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
138
|
+
未设置时用 CombineSolve 命令的缺省值 3600
|
|
139
|
+
|
|
136
140
|
Raises:
|
|
137
141
|
RuntimeError: 计算失败时抛出异常
|
|
138
142
|
"""
|
|
139
|
-
ok, err = osis_combine_solve()
|
|
143
|
+
ok, err = osis_combine_solve(timeout=timeout)
|
|
140
144
|
if not ok:
|
|
141
145
|
raise RuntimeError(f"计算荷载组合失败: {err}")
|
|
142
146
|
|
|
@@ -461,13 +465,17 @@ class PostManager:
|
|
|
461
465
|
if not ok:
|
|
462
466
|
raise RuntimeError(f"添加验算作用 {item} ({combine_name}) 失败: {err}")
|
|
463
467
|
|
|
464
|
-
def solve_checks(self) -> None:
|
|
468
|
+
def solve_checks(self, *, timeout: float | None = None) -> None:
|
|
465
469
|
"""计算验算作用
|
|
466
470
|
|
|
471
|
+
Args:
|
|
472
|
+
timeout: HTTP 超时秒数;不传则用 set_timeout() 的全局设置,
|
|
473
|
+
未设置时用 CheckSolve 命令的缺省值 3600
|
|
474
|
+
|
|
467
475
|
Raises:
|
|
468
476
|
RuntimeError: 计算失败时抛出异常
|
|
469
477
|
"""
|
|
470
|
-
ok, err = osis_check_solve()
|
|
478
|
+
ok, err = osis_check_solve(timeout=timeout)
|
|
471
479
|
if not ok:
|
|
472
480
|
raise RuntimeError(f"计算验算失败: {err}")
|
|
473
481
|
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|