新增系统仿真参数优化 Skill
This commit is contained in:
1 parent
a87d462e94
commit
42ffdfff7d
6 files changed
+5935
-14
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -27,7 +27,7 @@ import uuid
|
||||
import xml.etree.ElementTree as ET
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterable, Mapping, Sequence
|
||||
from typing import Any, Callable, Iterable, Mapping, Sequence
|
||||
|
||||
|
||||
MAX_INPUT_BYTES = 5 * 1024 * 1024
|
||||
@@ -1294,12 +1294,16 @@ def _read_simulation_stream(
|
||||
simulation_id: str,
|
||||
timeout: float,
|
||||
progress_path: Path,
|
||||
*,
|
||||
event_sink: Callable[[object], None] | None = None,
|
||||
full_result: str | None = "result.json",
|
||||
) -> tuple[dict[str, object] | None, dict[str, object] | None]:
|
||||
final_result: dict[str, object] | None = None
|
||||
final_error: dict[str, object] | None = None
|
||||
public_phase: str | None = None
|
||||
public_progress: float | None = None
|
||||
public_emit_time = 0.0
|
||||
sink = event_sink or emit_json
|
||||
try:
|
||||
progress = progress_path.open("x", encoding="utf-8", newline="\n")
|
||||
except OSError as exc:
|
||||
@@ -1333,7 +1337,11 @@ def _read_simulation_stream(
|
||||
)
|
||||
event_kind = event.get("event")
|
||||
logged_event = (
|
||||
_public_result_event(event, simulation_id)
|
||||
_public_result_event(
|
||||
event,
|
||||
simulation_id,
|
||||
full_result=full_result,
|
||||
)
|
||||
if event_kind == "result"
|
||||
else event
|
||||
)
|
||||
@@ -1348,16 +1356,16 @@ def _read_simulation_stream(
|
||||
previous_progress=public_progress,
|
||||
seconds_since_emit=now - public_emit_time,
|
||||
):
|
||||
emit_json(event)
|
||||
sink(event)
|
||||
public_phase = str(event.get("phase") or "")
|
||||
raw_progress = event.get("progress")
|
||||
if isinstance(raw_progress, (int, float)) and not isinstance(raw_progress, bool):
|
||||
public_progress = float(raw_progress)
|
||||
public_emit_time = now
|
||||
elif event_kind == "result":
|
||||
emit_json(logged_event)
|
||||
sink(logged_event)
|
||||
else:
|
||||
emit_json(event)
|
||||
sink(event)
|
||||
if event_kind == "result":
|
||||
result = event.get("result")
|
||||
if isinstance(result, dict):
|
||||
|
||||
Reference in new issue
Block a user