# Path: user_metrics/etl/aggregator.py
# def build_numpy_op_agg(agg_meta_list, metric_header, method_handle):
#     """
#         Builder method for ``numpy_op`` aggregator.
#     """
#     agg_method = numpy_op
#     agg_method = decorator_builder(metric_header)(agg_method)
#     agg_meta_header = [o.field_name for o in agg_meta_list]
# 
#     setattr(agg_method, METRIC_AGG_METHOD_FLAG, True)
#     setattr(agg_method, METRIC_AGG_METHOD_NAME, method_handle)
#     setattr(agg_method, METRIC_AGG_METHOD_HEAD, agg_meta_header)
#     setattr(agg_method, METRIC_AGG_METHOD_KWARGS,
#             {
#                 'agg_meta': agg_meta_list
#             }
#             )
#     return agg_method
# 
# def build_agg_meta(op_list, field_prefix_names):
#     """
#         Builder helper method for building module aggregators via
#         ``build_numpy_op_agg``.
#     """
#     return [AggregatorMeta(name + op.__name__, index, op)
#             for name, index in field_prefix_names.iteritems()
#             for op in op_list]
# 
# Path: user_metrics/etl/aggregator.py
# METRIC_AGG_METHOD_KWARGS = 'metric_agg_kwargs'


from user_metrics.config import logging
from numpy import mean, std, median
from user_metrics.metrics import query_mod
from user_metrics.metrics.users import UMP_MAP
from user_metrics.etl.aggregator import build_numpy_op_agg, build_agg_meta
from user_metrics.etl.aggregator import METRIC_AGG_METHOD_KWARGS
import os
import user_metrics.utils.multiprocessing_wrapper as mpw
import user_metric as um
        except TypeError:
            dropped_users += 1

    if metric_params.log_:
        logging.info(__name__ + '::Processed PID = %s.  '
                                'Dropped users = %s.' % (
                                    os.getpid(), str(dropped_users)))

    return results


# ==========================
# DEFINE METRIC AGGREGATORS
# ==========================


metric_header = PagesCreated.header()

field_prefixes =\
    {
    'count_': 1,
    }

# Build "dist" decorator
op_list = [sum, mean, std, median, min, max]
pages_created_stats_agg = build_numpy_op_agg(
    build_agg_meta(op_list, field_prefixes), metric_header,
    'pages_created_stats_agg')

agg_kwargs = getattr(pages_created_stats_agg, METRIC_AGG_METHOD_KWARGS)

# Path: user_metrics/etl/aggregator.py
# def build_numpy_op_agg(agg_meta_list, metric_header, method_handle):
#     """
#         Builder method for ``numpy_op`` aggregator.
#     """
#     agg_method = numpy_op
#     agg_method = decorator_builder(metric_header)(agg_method)
#     agg_meta_header = [o.field_name for o in agg_meta_list]
# 
#     setattr(agg_method, METRIC_AGG_METHOD_FLAG, True)
#     setattr(agg_method, METRIC_AGG_METHOD_NAME, method_handle)
#     setattr(agg_method, METRIC_AGG_METHOD_HEAD, agg_meta_header)
#     setattr(agg_method, METRIC_AGG_METHOD_KWARGS,
#             {
#                 'agg_meta': agg_meta_list
#             }
#             )
#     return agg_method
# 
# def build_agg_meta(op_list, field_prefix_names):
#     """
#         Builder helper method for building module aggregators via
#         ``build_numpy_op_agg``.
#     """
#     return [AggregatorMeta(name + op.__name__, index, op)
#             for name, index in field_prefix_names.iteritems()
#             for op in op_list]
# 
# Path: user_metrics/etl/aggregator.py
# METRIC_AGG_METHOD_KWARGS = 'metric_agg_kwargs'


# Path: user_metrics/metrics/pages_created.py
from user_metrics.config import logging
from numpy import mean, std, median
from user_metrics.metrics import query_mod
from user_metrics.metrics.users import UMP_MAP
from user_metrics.etl.aggregator import build_numpy_op_agg, build_agg_meta
from user_metrics.etl.aggregator import METRIC_AGG_METHOD_KWARGS
import os
import user_metrics.utils.multiprocessing_wrapper as mpw
import user_metric as um

        except TypeError:
            dropped_users += 1

    if metric_params.log_:
        logging.info(__name__ + '::Processed PID = %s.  '
                                'Dropped users = %s.' % (
                                    os.getpid(), str(dropped_users)))

    return results


# ==========================
# DEFINE METRIC AGGREGATORS
# ==========================


metric_header = PagesCreated.header()

field_prefixes =\
    {
    'count_': 1,
    }

# Build "dist" decorator
op_list = [sum, mean, std, median, min, max]
pages_created_stats_agg = build_numpy_op_agg(
    build_agg_meta(op_list, field_prefixes), metric_header,
    'pages_created_stats_agg')

agg_kwargs = getattr(pages_created_stats_agg, METRIC_AGG_METHOD_KWARGS)

setattr(pages_created_stats_agg, METRIC_AGG_METHOD_KWARGS, agg_kwargs)