from typing import Tuple
from typing import List


def get_mpcs(model, mpc_id: int, consider_mpcadd: bool=True,
             stop_on_failure: bool=True) -> Tuple[List[int], List[str]]:
    """
    Gets the MPCs in a semi-usable form.

    Parameters
    ----------
    mpc_id : int
        the desired MPC ID
    stop_on_failure : bool; default=True
        errors if parsing something new

    Returns
    -------
    nids : List[int]
        the constrained nodes
    comps : List[str]
        the components that are constrained on each node

    Considers:
      - MPC
      - MPCADD

    """
    mpcs = model.get_reduced_mpcs(
        mpc_id, consider_mpcadd=consider_mpcadd,
        stop_on_failure=stop_on_failure)
    nids = []
    comps = []
    for mpc in mpcs:
        if mpc.type == 'MPC':
            for nid, comp, unused_coefficient in zip(mpc.nodes, mpc.components, mpc.coefficients):
                nids.append(nid)
                comps.append(comp)
        else:
            if stop_on_failure:
                model.log.error('not considering:\n%s' % str(mpc))
                raise NotImplementedError(mpc)
            model.log.warning('not considering:\n%s' % str(mpc))
    return nids, comps