Skip to content

Commit abb8c67

Browse files
committed
ruff
1 parent e7ea1b1 commit abb8c67

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/models-library/src/models_library/projects_nodes.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Models Node as a central element in a project's pipeline
33
"""
44

5+
from enum import auto
56
from typing import Annotated, Any, TypeAlias, Union
67

78
from common_library.basic_types import DEFAULT_FACTORY
@@ -20,6 +21,7 @@
2021
from pydantic.config import JsonDict
2122

2223
from .basic_types import EnvVarKey, KeyIDStr
24+
from .groups import GroupID
2325
from .projects_access import AccessEnum
2426
from .projects_nodes_io import (
2527
DatCoreFileLink,
@@ -31,6 +33,7 @@
3133
from .projects_nodes_layout import Position
3234
from .projects_state import RunningState
3335
from .services import ServiceKey, ServiceVersion
36+
from .utils.enums import StrAutoEnum
3437

3538
InputTypes = Union[
3639
# NOTE: WARNING the order in Union[*] below matters!
@@ -71,6 +74,35 @@
7174
UnitStr: TypeAlias = Annotated[str, StringConstraints(strip_whitespace=True)]
7275

7376

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+
74106
class NodeState(BaseModel):
75107
modified: Annotated[
76108
bool,

packages/models-library/src/models_library/utils/enums.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
@unique
77
class StrAutoEnum(StrEnum):
88
@staticmethod
9-
def _generate_next_value_(name, start, count, last_values):
9+
def _generate_next_value_(
10+
name: str, start: int, count: int, last_values: list[str] # noqa: ARG004
11+
) -> str:
1012
return name.upper()
1113

1214

0 commit comments

Comments
 (0)