Repository: spotify/luigi
File: luigi/execution_summary.py (Python)

Code before:
    FAILED                         2      There were failed tasks
    FAILED_AND_SCHEDULING_FAILED   3      There were failed tasks and tasks whose scheduling failed
    SCHEDULING_FAILED              4      There were tasks whose scheduling failed
    NOT_RUN                        5      There were tasks that were not granted run permission by the scheduler
    MISSING_EXT                    6      There were missing external dependencies
    =============================  =====  ==========================================================
    
    """
    SUCCESS = 0
    SUCCESS_WITH_RETRY = 1
    FAILED = 2
    FAILED_AND_SCHEDULING_FAILED = 3
    SCHEDULING_FAILED = 4
    NOT_RUN = 5
    MISSING_EXT = 6

    # Make sure all the retcodes have a (smiley, reason) in this dictionary
    _DETAILS = {
        SUCCESS: (":)", "there were no failed tasks or missing dependencies"),
        SUCCESS_WITH_RETRY: (":)", "there were failed tasks but they all succeeded in a retry"),
        FAILED: (":(" ,"there were failed tasks"),
        FAILED_AND_SCHEDULING_FAILED: (":(", "there were failed tasks and tasks whose scheduling failed"),
        SCHEDULING_FAILED: (":(", "there were tasks whose scheduling failed"),
        NOT_RUN: (":|", "there were tasks that were not granted run permission by the scheduler"),
        MISSING_EXT: (":|", "there were missing external dependencies")
    }


class LuigiRunResult:
    """
    Result of the execution (build/run) will be of type LuigiRunResult instead of
    the regular Boolean response if the keyword argument ``detailed_summary=True`` is passed to
    build/run. A response of type **LuigiRunResult** has the following attributes:

    Attributes:
        * **summary_text_one_line** - One line summary of the progress.
        * **summary_text** - Detailed summary of the progress.
        * **status** - Integer Return Code. See \
        `LuigiRetCodes <https://luigi.readthedocs.io/en/latest/api/luigi.execution_summary.html#luigi.execution_summary.LuigiRetCodes>`_ \
        for what these codes mean.
        * **worker** - Worker object.
        * **execution_succeeded** - Boolean which is *True* if finally, there were no failed tasks.
        * **scheduling_succeeded** - Boolean which is *True* if all the tasks were scheduled without errors.

    """
    def __init__(self, worker, worker_add_run_status=True):
        self.worker = worker
        self.summary_text = summary(worker)
        self.summary_text_one_line, self.status = self._progress_summary(worker)
        self.scheduling_succeeded = worker_add_run_status
        self.execution_succeeded = (True if self.status is LuigiRetCodes.SUCCESS or 

Review comment (suggestion):
Can you use a real enum and then use this kind of syntax? Would it be better?

https://docs.python.org/3/library/enum.html#planet

Code after:
    SUCCESS                        There were no failed tasks or missing dependencies
    SUCCESS_WITH_RETRY             There were failed tasks but they all succeeded in a retry
    FAILED                         There were failed tasks
    FAILED_AND_SCHEDULING_FAILED   There were failed tasks and tasks whose scheduling failed
    SCHEDULING_FAILED              There were tasks whose scheduling failed
    NOT_RUN                        There were tasks that were not granted run permission by the scheduler
    MISSING_EXT                    There were missing external dependencies
    =============================  ==========================================================

    """
    SUCCESS = (":)", "there were no failed tasks or missing dependencies")
    SUCCESS_WITH_RETRY = (":)", "there were failed tasks but they all succeeded in a retry")
    FAILED = (":(", "there were failed tasks")
    FAILED_AND_SCHEDULING_FAILED = (":(", "there were failed tasks and tasks whose scheduling failed")
    SCHEDULING_FAILED = (":(", "there were tasks whose scheduling failed")
    NOT_RUN = (":|", "there were tasks that were not granted run permission by the scheduler")
    MISSING_EXT = (":|", "there were missing external dependencies")


class LuigiRunResult(object):
    """
    The result of a call to build/run when passing the detailed_summary=True argument.

    Attributes:
        - one_line_summary (str): One line summary of the progress.
        - summary_text (str): Detailed summary of the progress.
        - status (LuigiStatusCode): Luigi Status Code. See :class:`~luigi.execution_summary.LuigiStatusCode` for what these codes mean.
        - worker (luigi.worker.worker): Worker object. See :class:`~luigi.worker.worker`.
        - scheduling_succeeded (bool): Boolean which is *True* if all the tasks were scheduled without errors.

    """
    def __init__(self, worker, worker_add_run_status=True):
        self.worker = worker
        summary_dict = _summary_dict(worker)
        self.summary_text = _summary_wrap(_summary_format(summary_dict, worker))
        self.status = _tasks_status(summary_dict)
        self.one_line_summary = _create_one_line_summary(self.status)
        self.scheduling_succeeded = worker_add_run_status

    def __str__(self):
        return "LuigiRunResult with status {0}".format(self.status)

    def __repr__(self):
        return "LuigiRunResult(status={0!r},worker={1!r},scheduling_succeeded={2!r})".format(self.status, self.worker, self.scheduling_succeeded)


def _partition_tasks(worker):
    """
    Takes a worker and sorts out tasks based on their status.
    Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker
    """