from libs.constants import UNKNOWN
from libs.statuses import BaseStatuses


class JobLifeCycle(BaseStatuses):
    """Experiment lifecycle

    Props:
        * CREATED: created.
        * BUILDING: This includes time before being bound to a node,
                    as well as time spent pulling images onto the host.
        * RUNNING: The pod has been bound to a node and all of the containers have been started.
        * SUCCEEDED: All containers in the pod have voluntarily terminated with a
                     container exit code of 0, and the system is
                     not going to restart any of these containers.
        * FAILED: All containers in the pod have terminated,
                  and at least one container has terminated in a failure.
        * STOPPED: was stopped/deleted/killed
        * UNKNOWN: For some reason the state of the pod could not be obtained,
                   typically due to an error in communicating with the host of the pod.
    """
    CREATED = 'Created'
    BUILDING = 'Building'
    RUNNING = 'Running'
    SUCCEEDED = 'Succeeded'
    FAILED = 'Failed'
    STOPPED = 'Stopped'
    UNKNOWN = UNKNOWN

    CHOICES = (
        (CREATED, CREATED),
        (BUILDING, BUILDING),
        (RUNNING, RUNNING),
        (SUCCEEDED, SUCCEEDED),
        (FAILED, FAILED),
        (STOPPED, STOPPED),
        (UNKNOWN, UNKNOWN),
    )

    STARTING_STATUS = [CREATED, BUILDING]
    RUNNING_STATUS = [BUILDING, RUNNING]
    DONE_STATUS = [FAILED, STOPPED, SUCCEEDED]
    FAILED_STATUS = [FAILED]

@@ -1395,17 +1395,17 @@
 TATUS = 
-%5B
+%7B
 CREATED,
@@ -1413,17 +1413,17 @@
 BUILDING
-%5D
+%7D
 %0A    RUN
@@ -1436,17 +1436,17 @@
 TATUS = 
-%5B
+%7B
 BUILDING
@@ -1454,17 +1454,17 @@
  RUNNING
-%5D
+%7D
 %0A    DON
@@ -1470,25 +1470,25 @@
 NE_STATUS = 
-%5B
+%7B
 FAILED, STOP
@@ -1501,17 +1501,17 @@
 UCCEEDED
-%5D
+%7D
 %0A    FAI
@@ -1527,13 +1527,15 @@
 S = 
-%5B
+%7B
 FAILED
-%5D
+, %7D
 %0A

Update job statuses