def penaltymodel_factory(priority):
    """Decorator to assign a `priority` attribute to the decorated function.

    Args:
        priority (int): The priority of the factory. Factories are queried
            in order of decreasing priority.

    Examples:
        Decorate penalty model factories like:

        >>> @pm.penaltymodel_factory(105)
        ... def factory_function(spec):
        ...     pass
        >>> factory_function.priority
        105

    """
    def _entry_point(f):
        f.priority = priority
        return f
    return _entry_point