How to use report_error_message method in Slash

Best Python code snippet using slash

convert_phase 2.py

Source:convert_phase 2.py Github

copy

Full Screen

...147 if not error_data.subcomponent:148 error_data.subcomponent = subcomponent.name149 tflite_metrics = metrics.TFLiteConverterMetrics()150 tflite_metrics.set_converter_error(error_data)151 def report_error_message(error_message: Text):152 error_data = converter_error_data_pb2.ConverterErrorData()153 error_data.error_message = error_message154 report_error(error_data)155 def actual_decorator(func):156 @functools.wraps(func)157 def wrapper(*args, **kwargs):158 try:159 return func(*args, **kwargs)160 except ConverterError as converter_error:161 if converter_error.errors:162 for error_data in converter_error.errors:163 report_error(error_data)164 else:165 report_error_message(str(converter_error))166 raise converter_error from None # Re-throws the exception.167 except Exception as error:168 report_error_message(str(error))169 raise error from None # Re-throws the exception.170 return wrapper...

Full Screen

Full Screen

evaluate.py

Source:evaluate.py Github

copy

Full Screen

...46 47 if not os.path.exists(os.path.join(submit_dir,'results.zip')):48 error_message['status'] = -149 error_message['message'] = 'Cannot find results.zip file!'50 report_error_message(error_message,out_path,union_key)51 logging.info('Cannot find results.zip file!')52 return None53 unzip_file(submit_path, submit_dir)54 if not os.path.exists(os.path.join(submit_dir,'results')):55 error_message['status'] = -156 error_message['message'] = 'Cannot find the results folder after unzipping the results.zip file!'57 report_error_message(error_message,out_path,union_key)58 logging.info('Cannot find the results folder after unzipping the results.zip file!')59 return None60 try:61 gtfiles = glob.glob(os.path.join(standard_path, '*.txt'))62 tsfiles = []63 for gt_txt in gtfiles: 64 if not os.path.exists(os.path.join(submit_dir,'results',os.path.basename(gt_txt))):65 error_message['status'] = -166 error_message['message'] = 'Cannot find '+os.path.basename(gt_txt)+' in results/ folder!'67 report_error_message(error_message,out_path,union_key)68 logging.info('Cannot find '+os.path.basename(gt_txt)+' in results/ folder!')69 return None 70 tsfiles.append(os.path.join(submit_dir,'results',os.path.basename(gt_txt)))71 72 logging.info('Found %d groundtruths and %d test files.', len(gtfiles), len(tsfiles))73 logging.info('Available LAP solvers %s', str(mm.lap.available_solvers))74 logging.info('Default LAP solver \'%s\'', mm.lap.default_solver)75 logging.info('Loading files.')76 77 gt = OrderedDict(78 [(os.path.splitext(Path(f).parts[-1])[0], mm.io.loadtxt(f, fmt=fmt, min_confidence=1)) for f in gtfiles]79 )80 ts = OrderedDict([(os.path.splitext(Path(f).parts[-1])[0], mm.io.loadtxt(f, fmt=fmt)) for f in tsfiles])81 mh = mm.metrics.create()82 accs, names, flag = compare_dataframes(gt, ts)83 metrics = list(mm.metrics.motchallenge_metrics)84 if exclude_id:85 metrics = [x for x in metrics if not x.startswith('id')]86 logging.info('Running metrics')87 summary = mh.compute_many(accs, names=names, metrics=metrics, generate_overall=True)88 print(mm.io.render_summary(summary, formatters=mh.formatters, namemap=mm.io.motchallenge_metric_names))89 logging.info('Completed')90 MOTA = summary['mota']['OVERALL']91 MOTP = 1 - summary['motp']['OVERALL']92 IDF1 = summary['idf1']['OVERALL']93 MT = summary['mostly_tracked']['OVERALL']94 ML = summary['mostly_lost']['OVERALL']95 FP = summary['num_false_positives']['OVERALL']96 FN = summary['num_misses']['OVERALL']97 IDs = summary['num_switches']['OVERALL']98 Frag = summary['num_fragmentations']['OVERALL']99 if (MOTA + MOTP) <= 0:100 check_code = 1101 print("MOTA + MOTP <= 0, wrong.")102 return None103 else:104 score = (2 * MOTA * MOTP) / (MOTA + MOTP)105 score_detail = (MOTA, MOTP, IDF1, MT, ML, FP, FN, IDs, Frag)106 score = (2 * MOTA * MOTP) / (MOTA + MOTP)107 except BaseException as e:108 print(e)109 if os.path.exists(os.path.join(submit_dir+'results')):110 shutil.rmtree(os.path.join(submit_dir+'results'))111 return None112 else:113 report_score(score, score_detail, out_path, union_key, status)114 if os.path.exists(os.path.join(submit_dir+'results')):115 shutil.rmtree(os.path.join(submit_dir+'results'))116 return (MOTA, MOTP, IDF1, MT, ML, FP, FN, IDs, Frag)117def compare_dataframes(gts, ts):118 """Builds accumulator for each sequence."""119 accs = []120 names = []121 for k in gts:122 if k in ts.keys():123 logging.info('Comparing %s...', k)124 accs.append(mm.utils.compare_to_groundtruth(gts[k], ts[k], 'iou', distth=0.5))125 names.append(k)126 else:127 logging.warning('No ground truth for %s, skipping.', k)128 return accs, names, False129 return accs, names, True130def dump_2_json(info, path):131 with open(path, 'w') as output_json_file:132 json.dump(info, output_json_file, indent=4)133def report_error_message(error_dict,out_p,union_key):134 error_dict['unionKey'] = union_key135 print(error_dict)136 error_dict = bytes(json.dumps(error_dict), 'utf-8')137 url = out_p138 headers={'Content-Type': 'application/json'}139 x = requests.post(url, data=error_dict,headers=headers)140def report_score(score, score_detail, out_p, union_key, status):141 if status == 0:142 msg = "Success"143 else:144 msg = "Wrong user results directory."145 url=out_p146 data={147 'unionKey': union_key,...

Full Screen

Full Screen

convert_phase.py.transformed.py

Source:convert_phase.py.transformed.py Github

copy

Full Screen

...86 if not error_data.subcomponent:87 error_data.subcomponent = subcomponent.name88 tflite_metrics = metrics.TFLiteConverterMetrics()89 tflite_metrics.set_converter_error(error_data)90 def report_error_message(error_message: Text):91 error_data = converter_error_data_pb2.ConverterErrorData()92 error_data.error_message = error_message93 report_error(error_data)94 def actual_decorator(func):95 @functools.wraps(func)96 def wrapper(*args, **kwargs):97 try:98 return func(*args, **kwargs)99 except ConverterError as converter_error:100 if converter_error.errors:101 for error_data in converter_error.errors:102 report_error(error_data)103 else:104 report_error_message(str(converter_error))105 except Exception as error:106 report_error_message(str(error))107 return wrapper...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful