fix(dsh): resolve follow-up UI and shared diagnosis budget review
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
775bc23dc3
commit
5ce3f827f0
11 files changed
+204
-20
No files matched your search
@@ -132,7 +132,9 @@ class DshAutomation(QObject):
|
||||
self._owns_execution_lane = not item.read_only and (item.authorized or item.cleanup_allowed)
|
||||
self._uses_cad_controls = self._owns_execution_lane and item.authorized
|
||||
self.cancel_event = Event()
|
||||
self._analysis_deadline = monotonic() + self._diagnosis_budget_seconds()
|
||||
# Start the shared model budget when the Harness session is ready;
|
||||
# startup/session creation must not consume diagnosis time.
|
||||
self._analysis_deadline = None
|
||||
self._current_identity = (task_id, code, run_id)
|
||||
if run_id == 'observation':
|
||||
run_id = uuid4().hex
|
||||
@@ -200,6 +202,8 @@ class DshAutomation(QObject):
|
||||
self.cancel_event.set()
|
||||
for request_id, (complete, holder) in list(self.waiters.items()):
|
||||
holder.update(status='cancelled', error='diagnosis_cancelled')
|
||||
if holder.get('_ready') is not None:
|
||||
holder['_ready'].set()
|
||||
complete.set()
|
||||
self.cancel_requested.emit(request_id)
|
||||
self._publish_context()
|
||||
@@ -226,17 +230,27 @@ class DshAutomation(QObject):
|
||||
if remaining <= 0:
|
||||
raise TimeoutError('native_diagnosis_total_timeout')
|
||||
request_id = uuid4().hex
|
||||
complete, holder = Event(), {}
|
||||
complete, holder = Event(), {'_ready': Event()}
|
||||
self.waiters[request_id] = (complete, holder)
|
||||
try:
|
||||
self.model_requested.emit({'request_id': request_id, 'incident_id': incident_id,
|
||||
'snapshot': snapshot, 'evidence': evidence[:38000], 'phase': phase})
|
||||
'snapshot': snapshot, 'evidence': evidence[:38000], 'phase': phase,
|
||||
'model_budget_ms': max(1, int(remaining * 1000))})
|
||||
if self._analysis_deadline is None:
|
||||
if not holder['_ready'].wait(300):
|
||||
self._native_unavailable = True
|
||||
self.cancel_requested.emit(request_id)
|
||||
raise TimeoutError('native_diagnosis_startup_timeout')
|
||||
remaining = (self._analysis_deadline or monotonic() + self._diagnosis_budget_seconds()) - monotonic()
|
||||
if remaining <= 0:
|
||||
self.cancel_requested.emit(request_id)
|
||||
raise TimeoutError('native_diagnosis_total_timeout')
|
||||
if not complete.wait(remaining):
|
||||
self.cancel_requested.emit(request_id)
|
||||
raise TimeoutError('native_diagnosis_total_timeout')
|
||||
if holder.get('status') != 'completed':
|
||||
raise RuntimeError(holder.get('error', 'native_diagnosis_failed'))
|
||||
return holder
|
||||
return {key: value for key, value in holder.items() if key != '_ready'}
|
||||
finally:
|
||||
self.waiters.pop(request_id, None)
|
||||
|
||||
@@ -253,19 +267,28 @@ class DshAutomation(QObject):
|
||||
def _runtime_stopped(self):
|
||||
for complete, holder in list(self.waiters.values()):
|
||||
holder.update(status='failed', error='native_harness_stopped')
|
||||
if holder.get('_ready') is not None:
|
||||
holder['_ready'].set()
|
||||
complete.set()
|
||||
|
||||
def _diagnosis_event(self, value):
|
||||
if value.get('request_id') not in self.waiters:
|
||||
return
|
||||
if value.get('status') == 'started':
|
||||
if self._analysis_deadline is None:
|
||||
self._analysis_deadline = monotonic() + self._diagnosis_budget_seconds()
|
||||
self.latest['session_id'] = value['session_id']
|
||||
holder = self.waiters[value['request_id']][1]
|
||||
if holder.get('_ready') is not None:
|
||||
holder['_ready'].set()
|
||||
self._publish_context()
|
||||
else:
|
||||
waiter = self.waiters.get(value.get('request_id'))
|
||||
if waiter:
|
||||
complete, holder = waiter
|
||||
holder.update(value)
|
||||
if holder.get('_ready') is not None:
|
||||
holder['_ready'].set()
|
||||
complete.set()
|
||||
|
||||
def _state_changed(self, row):
|
||||
|
||||
@@ -336,12 +336,13 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
QMessageBox.warning(self, '已保留待恢复任务', self._archive_close_notice)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self._cancel_dsh_diagnosis()
|
||||
if self._close_saving:
|
||||
event.ignore()
|
||||
return
|
||||
if self._workers or self.history_panel._worker or (self._dsh_operations and self._dsh_operations.worker):
|
||||
self._close_pending = True
|
||||
if self._dsh_automation and getattr(self._dsh_automation, '_owns_execution_lane', False):
|
||||
self._cancel_dsh_diagnosis()
|
||||
self.plan_panel.cancel_operation()
|
||||
self._pause_queue()
|
||||
self._set_operator_message('操作尚未结束,请等当前步骤安全收尾后关闭。', 'warning')
|
||||
@@ -374,12 +375,16 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self._run_async(lambda: archive_completed_session(self.service), self._session_archived)
|
||||
return
|
||||
if self._dsh_view is not None and getattr(self._dsh_view, 'is_running', False):
|
||||
# All confirmation/retention branches have passed; the remaining
|
||||
# asynchronous shutdown is part of an accepted close request.
|
||||
self._cancel_dsh_diagnosis()
|
||||
event.ignore()
|
||||
if not self._dsh_stopping:
|
||||
self._dsh_stopping = True
|
||||
self._dsh_view.stopped.connect(lambda: QTimer.singleShot(0, self.close))
|
||||
self._dsh_view.shutdown()
|
||||
return
|
||||
self._cancel_dsh_diagnosis()
|
||||
for name, widget in self._layout_widgets().items():
|
||||
self._layout_settings.setValue(f'single_project/{name}', widget.saveState())
|
||||
self._layout_settings.setValue('tasks/sort', self.task_list.sort.currentData())
|
||||
@@ -479,7 +484,7 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self._task_context_failed(error, auto_intervene=auto_intervene)
|
||||
|
||||
def _update_gates(self):
|
||||
cancellable = bool(self._dsh_automation and self._dsh_automation.can_cancel)
|
||||
cancellable = bool(self._dsh_automation and getattr(self._dsh_automation, 'can_cancel', False))
|
||||
self.cancel_diagnosis_button.setVisible(cancellable)
|
||||
self.cancel_diagnosis_button.setEnabled(cancellable)
|
||||
busy = bool(self._workers) or self._loading or self.history_panel._worker is not None
|
||||
@@ -1324,8 +1329,9 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
QMessageBox.warning(self, '操作未完成', message)
|
||||
|
||||
def _cancel_dsh_diagnosis(self):
|
||||
if self._dsh_automation is not None:
|
||||
self._dsh_automation.cancel()
|
||||
cancel = getattr(self._dsh_automation, 'cancel', None)
|
||||
if cancel is not None:
|
||||
cancel()
|
||||
|
||||
def _set_auto_intervention(self, enabled):
|
||||
self._layout_settings.setValue('dsh/auto_intervention', enabled)
|
||||
|
||||
Reference in new issue
Block a user