AllenNeuralDynamics / AllenNeuralDynamics/prototome-web-ui

Add error handling channel

Abierto
#41 0 comentarios 0 reacciones 2 asignados Reclamado por @Poofjunior Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
0
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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} }));
};
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.