Пример #1
0
def component_metric_all():
    request_data = request.json
    check_request_parameters(request_data)
    tracker = Tracker(job_id=request_data['job_id'],
                      component_name=request_data['component_name'],
                      role=request_data['role'],
                      party_id=request_data['party_id'])
    metrics = tracker.get_metric_list()
    all_metric_data = {}
    if metrics:
        for metric_namespace, metric_names in metrics.items():
            all_metric_data[metric_namespace] = all_metric_data.get(
                metric_namespace, {})
            for metric_name in metric_names:
                all_metric_data[metric_namespace][
                    metric_name] = all_metric_data[metric_namespace].get(
                        metric_name, {})
                metric_data, metric_meta = get_metric_all_data(
                    tracker=tracker,
                    metric_namespace=metric_namespace,
                    metric_name=metric_name)
                all_metric_data[metric_namespace][metric_name][
                    'data'] = metric_data
                all_metric_data[metric_namespace][metric_name][
                    'meta'] = metric_meta
        return get_json_result(retcode=0,
                               retmsg='success',
                               data=all_metric_data)
    else:
        return get_json_result(retcode=0, retmsg='no data', data={})
Пример #2
0
def job_view():
    request_data = request.json
    check_request_parameters(request_data)
    job_tracker = Tracker(job_id=request_data['job_id'],
                          role=request_data['role'],
                          party_id=request_data['party_id'])
    job_view_data = job_tracker.get_job_view()
    if job_view_data:
        job_metric_list = job_tracker.get_metric_list(job_level=True)
        job_view_data['model_summary'] = {}
        for metric_namespace, namespace_metrics in job_metric_list.items():
            job_view_data['model_summary'][metric_namespace] = job_view_data[
                'model_summary'].get(metric_namespace, {})
            for metric_name in namespace_metrics:
                job_view_data['model_summary'][metric_namespace][
                    metric_name] = job_view_data['model_summary'][
                        metric_namespace].get(metric_name, {})
                for metric_data in job_tracker.get_job_metric_data(
                        metric_namespace=metric_namespace,
                        metric_name=metric_name):
                    job_view_data['model_summary'][metric_namespace][
                        metric_name][metric_data.key] = metric_data.value
        return get_json_result(retcode=0, retmsg='success', data=job_view_data)
    else:
        return get_json_result(retcode=101, retmsg='error')
Пример #3
0
def component_metrics():
    request_data = request.json
    check_request_parameters(request_data)
    tracker = Tracker(job_id=request_data['job_id'], component_name=request_data['component_name'],
                      role=request_data['role'], party_id=request_data['party_id'])
    metrics = tracker.get_metric_list()
    if metrics:
        return get_json_result(retcode=0, retmsg='success', data=metrics)
    else:
        return get_json_result(retcode=0, retmsg='no data', data={})