Commit 00acb567 authored by Matteo Spanio's avatar Matteo Spanio
Browse files

update request error handling

parent 0aa52313
from rich.console import Console
import os
from argparse import ArgumentParser
from time import sleep
import grpc
from mpai_cae_arp.network import arp_pb2
from mpai_cae_arp.network import arp_pb2_grpc
channels = {
"AudioAnalyser": grpc.insecure_channel("[::]:50051"),
"VideoAnalyser": grpc.insecure_channel("[::]:50052"),
"TapeIrregularityClassifier": grpc.insecure_channel("[::]:50053"),
"TapeAudioRestoration": grpc.insecure_channel("[::]:50054"),
"Packager": grpc.insecure_channel("[::]:50055"),
"AudioAnalyser": grpc.insecure_channel("localhost:50051"),
"VideoAnalyser": grpc.insecure_channel("localhost:50052"),
"TapeIrregularityClassifier": grpc.insecure_channel("localhost:50053"),
"TapeAudioRestoration": grpc.insecure_channel("localhost:50054"),
"Packager": grpc.insecure_channel("localhost:50055"),
}
def get_args() -> tuple[str, str]:
......@@ -43,9 +44,15 @@ def run():
packager = arp_pb2_grpc.AIMStub(channels["Packager"])
request = arp_pb2.InfoRequest()
for aim in [audio_analyser, video_analyser, tape_irreg_classifier, tape_audio_restoration, packager]:
response = aim.getInfo(request)
console.print("[bold]{}[/], v{}".format(response.title, response.version))
try:
for aim in [audio_analyser, video_analyser, tape_irreg_classifier, tape_audio_restoration, packager]:
response = aim.getInfo(request)
console.print("[bold]{}[/], v{}".format(response.title, response.version))
sleep(0.3)
except grpc.RpcError as e:
console.print("[bold red]Error![/] :boom:")
console.print(f"[italic red]{e.details()}[/]")
exit(69)
request = arp_pb2.JobRequest(
working_dir="/data",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment