def parse_metrics(metrics: tuple) -> dict:
    """
    Parse and convert the metrics captured by get_metrics() into a dictionary.

    The main role of this is to parse the enormous dict returned by docker.container.stats and just
    retrieve the memory usage as a list. NOTE: memory_usage_mb is total usage in megabytes,
    while the `docker stats` command line command reports total - cache.

    Parameters
    ----------
    metrics: tuple
        Tuple of metrics output by get_metrics().

    Returns
    -------
    Dictionary containing the final rows in the covidcast table, rows loaded to the the covidcast table during the
    operation, final database size, change in database size during the operation, runtime, and the maximum memory
    usage queried during the function call.
    """
    output = {"final_table_rows": metrics[3],
              "rows_loaded": metrics[3] - metrics[2],
              "db_size_mb": metrics[1],
              "size_loaded_mb": metrics[1] - metrics[0],
              "runtime": metrics[4],
              "peak_memory_mb": max(i["memory_stats"]["usage"] / 1024 / 1024 for i in metrics[5])}
    return output