|
2 | 2 | Models Node as a central element in a project's pipeline |
3 | 3 | """ |
4 | 4 |
|
| 5 | +from enum import auto |
5 | 6 | from typing import Annotated, Any, TypeAlias, Union |
6 | 7 |
|
7 | 8 | from common_library.basic_types import DEFAULT_FACTORY |
|
20 | 21 | from pydantic.config import JsonDict |
21 | 22 |
|
22 | 23 | from .basic_types import EnvVarKey, KeyIDStr |
| 24 | +from .groups import GroupID |
23 | 25 | from .projects_access import AccessEnum |
24 | 26 | from .projects_nodes_io import ( |
25 | 27 | DatCoreFileLink, |
|
31 | 33 | from .projects_nodes_layout import Position |
32 | 34 | from .projects_state import RunningState |
33 | 35 | from .services import ServiceKey, ServiceVersion |
| 36 | +from .utils.enums import StrAutoEnum |
34 | 37 |
|
35 | 38 | InputTypes = Union[ |
36 | 39 | # NOTE: WARNING the order in Union[*] below matters! |
|
71 | 74 | UnitStr: TypeAlias = Annotated[str, StringConstraints(strip_whitespace=True)] |
72 | 75 |
|
73 | 76 |
|
| 77 | +class NodeLockStatus(StrAutoEnum): |
| 78 | + OPENING = auto() |
| 79 | + OPENED = auto() |
| 80 | + CLOSING = auto() |
| 81 | + |
| 82 | + |
| 83 | +class NodeLockState(BaseModel): |
| 84 | + is_locked: Annotated[ |
| 85 | + bool, |
| 86 | + Field( |
| 87 | + description="True if the node is locked, False otherwise", |
| 88 | + ), |
| 89 | + ] |
| 90 | + |
| 91 | + locked_by: Annotated[ |
| 92 | + GroupID | None, |
| 93 | + Field(description="Group that owns locked the node, None if not locked"), |
| 94 | + ] |
| 95 | + |
| 96 | + locked_reason: Annotated[ |
| 97 | + NodeLockStatus | None, |
| 98 | + Field( |
| 99 | + description="Reason why the node is locked, None if not locked", |
| 100 | + ), |
| 101 | + ] |
| 102 | + |
| 103 | + model_config = ConfigDict(extra="forbid") |
| 104 | + |
| 105 | + |
74 | 106 | class NodeState(BaseModel): |
75 | 107 | modified: Annotated[ |
76 | 108 | bool, |
|
0 commit comments