AllenNeuralDynamics / AllenNeuralDynamics/prototome-web-ui
Add error handling channel
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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} }));
};
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.