-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
enum.py
68 lines (49 loc) · 1.73 KB
/
enum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import enum
from datetime import datetime, timezone
from typing import Optional
class ComponentContext(enum.Enum):
"""Describes whether the current process is running LightningFlow or LightningWork."""
FLOW = "flow"
WORK = "work"
FRONTEND = "frontend"
class AppStage(enum.Enum):
BLOCKING = "blocking"
RUNNING = "running"
RESTARTING = "restarting"
STOPPING = "stopping"
FAILED = "failed"
class WorkFailureReasons:
TIMEOUT = "timeout" # triggered when pending and wait timeout has been passed
SPOT_RETRIVAL = "spot_retrival" # triggered when a SIGTERM signal is sent the spot instance work.
USER_EXCEPTION = "user_exception" # triggered when an exception is raised by user code.
INVALID_RETURN_VALUE = "invalid_return_value" # triggered when the return value isn't valid.
class WorkStopReasons:
SIGTERM_SIGNAL_HANDLER = "sigterm_signal_handler"
PENDING = "pending"
class WorkPendingReason(enum.Enum):
IMAGE_BUILDING = "image_building"
REQUESTING_RESOURCE = "requesting_ressource"
class WorkStageStatus:
NOT_STARTED = "not_started"
STARTED = "started"
STOPPED = "stopped"
PENDING = "pending"
RUNNING = "running"
SUCCEEDED = "succeeded"
FAILED = "failed"
def make_status(stage: str, message: Optional[str] = None, reason: Optional[str] = None):
status = {
"stage": stage,
"timestamp": datetime.now(tz=timezone.utc).timestamp(),
}
if message:
status["message"] = message
if reason:
status["reason"] = reason
return status
class CacheCallsKeys:
LATEST_CALL_HASH = "latest_call_hash"
class OpenAPITags:
APP_CLIENT_COMMAND = "app_client_command"
APP_COMMAND = "app_command"
APP_API = "app_api"