AllenNeuralDynamics / AllenNeuralDynamics/prototome-web-ui

Add error handling channel

Đang mở
#41 0 bình luận 0 reaction 2 người được giao Được @Poofjunior nhận Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
0
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

To catch backend errors, we need to send the error through one-liner and dedicate a channel to unpacking and alerting users of errors. Implemented in brainslosher like so

slosher class
```
class BrainSlosher(Instrument):
def __init__():
...
# attribute to track events that occur in job_worker
self.job_status_lock = Lock()
self.job_status: BrainSlosherJobStatus = BrainSlosherJobStatus(status="idle")

def _run_job_worker(self, job: BrainSlosherJob, job_path: Path):

try:
super()._run_job_worker(job, job_path)
except Exception as e:
self.log.error(f"Error running job: {str(e)}.")
message = BrainSlosherJobStatus(status="failed", message=str(e))

```

Server class
```
class ZMQServer(RouterServer):

def __init__(self, rpc_port: str = "5555", broadcast_port: str = "5556",
config: dict[str, str] = None, instances: dict = None):
.....
self.add_stream("error_check", 1, self.check_job_status)

def check_job_status(self) -> dict:

message = self.brainslosher.get_job_status()
return message.model_dump()

```

and then the front end treats everything coming from the error_check as an error
```
const handleErrorMessage = (evt: MessageEvent) => {
const error = JSON.parse(evt.data);
window.dispatchEvent(new CustomEvent("Error During Run", { detail: {message: error} }));
};
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.