Skip to content

Commit 56d65be

Browse files
committed
Rename CommandMode to ExecutionMode and update references throughout the codebase
1 parent ed1eb8f commit 56d65be

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async def main() -> None:
6868
)
6969
],
7070
label="Execution via Python",
71-
# mode=CommandMode.HIGH_PRIORITY
71+
# mode=ExecutionMode.HIGH_PRIORITY
7272
)
7373

7474
while True:

pyoverkiz/action_queue.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pyoverkiz.models import Action
1212

1313
if TYPE_CHECKING:
14-
from pyoverkiz.enums import CommandMode
14+
from pyoverkiz.enums import ExecutionMode
1515

1616

1717
@dataclass(frozen=True, slots=True)
@@ -78,15 +78,15 @@ class ActionQueue:
7878
The batch is flushed when:
7979
- The delay timer expires
8080
- The max actions limit is reached
81-
- The command mode changes
81+
- The execution mode changes
8282
- The label changes
8383
- Manual flush is requested
8484
"""
8585

8686
def __init__(
8787
self,
8888
executor: Callable[
89-
[list[Action], CommandMode | None, str | None], Coroutine[None, None, str]
89+
[list[Action], ExecutionMode | None, str | None], Coroutine[None, None, str]
9090
],
9191
delay: float = 0.5,
9292
max_actions: int = 20,
@@ -102,7 +102,7 @@ def __init__(
102102
self._max_actions = max_actions
103103

104104
self._pending_actions: list[Action] = []
105-
self._pending_mode: CommandMode | None = None
105+
self._pending_mode: ExecutionMode | None = None
106106
self._pending_label: str | None = None
107107
self._pending_waiters: list[QueuedExecution] = []
108108

@@ -121,7 +121,7 @@ def _copy_action(action: Action) -> Action:
121121
async def add(
122122
self,
123123
actions: list[Action],
124-
mode: CommandMode | None = None,
124+
mode: ExecutionMode | None = None,
125125
label: str | None = None,
126126
) -> QueuedExecution:
127127
"""Add actions to the queue.
@@ -132,7 +132,7 @@ async def add(
132132
133133
Args:
134134
actions: Actions to queue.
135-
mode: Command mode, which triggers a flush if it differs from the
135+
mode: Execution mode, which triggers a flush if it differs from the
136136
pending mode.
137137
label: Label for the action group.
138138
@@ -141,7 +141,7 @@ async def add(
141141
executes.
142142
"""
143143
batches_to_execute: list[
144-
tuple[list[Action], CommandMode | None, str | None, list[QueuedExecution]]
144+
tuple[list[Action], ExecutionMode | None, str | None, list[QueuedExecution]]
145145
] = []
146146

147147
if not actions:
@@ -235,7 +235,7 @@ async def _delayed_flush(self) -> None:
235235

236236
def _prepare_flush(
237237
self,
238-
) -> tuple[list[Action], CommandMode | None, str | None, list[QueuedExecution]]:
238+
) -> tuple[list[Action], ExecutionMode | None, str | None, list[QueuedExecution]]:
239239
"""Prepare a flush by taking snapshot and clearing state (must be called with lock held).
240240
241241
Returns a tuple of (actions, mode, label, waiters) that should be executed
@@ -266,7 +266,7 @@ def _prepare_flush(
266266
async def _execute_batch(
267267
self,
268268
actions: list[Action],
269-
mode: CommandMode | None,
269+
mode: ExecutionMode | None,
270270
label: str | None,
271271
waiters: list[QueuedExecution],
272272
) -> None:

pyoverkiz/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pyoverkiz.action_queue import ActionQueue, ActionQueueSettings
2323
from pyoverkiz.auth import AuthStrategy, Credentials, build_auth_strategy
2424
from pyoverkiz.const import SUPPORTED_SERVERS
25-
from pyoverkiz.enums import APIType, CommandMode, Server
25+
from pyoverkiz.enums import APIType, ExecutionMode, Server
2626
from pyoverkiz.exceptions import (
2727
ExecutionQueueFullError,
2828
InvalidEventListenerIdError,
@@ -471,7 +471,7 @@ async def get_api_version(self) -> str:
471471
async def _execute_action_group_direct(
472472
self,
473473
actions: list[Action],
474-
mode: CommandMode | None = None,
474+
mode: ExecutionMode | None = None,
475475
label: str | None = "python-overkiz-api",
476476
) -> str:
477477
"""Execute a non-persistent action group directly (internal method).
@@ -489,7 +489,7 @@ async def _execute_action_group_direct(
489489
async def execute_action_group(
490490
self,
491491
actions: list[Action],
492-
mode: CommandMode | None = None,
492+
mode: ExecutionMode | None = None,
493493
label: str | None = "python-overkiz-api",
494494
) -> str:
495495
"""Execute a non-persistent action group.
@@ -509,7 +509,7 @@ async def execute_action_group(
509509
510510
Args:
511511
actions: List of actions to execute.
512-
mode: Command mode (`GEOLOCATED`, `INTERNAL`, `HIGH_PRIORITY`,
512+
mode: Execution mode (`GEOLOCATED`, `INTERNAL`, `HIGH_PRIORITY`,
513513
or `None`).
514514
label: Label for the action group.
515515
@@ -547,13 +547,13 @@ def get_pending_actions_count(self) -> int:
547547
return 0
548548

549549
@retry_on_auth_error
550-
async def cancel_command(self, exec_id: str) -> None:
550+
async def cancel_execution(self, exec_id: str) -> None:
551551
"""Cancel a running setup-level execution."""
552552
await self._delete(f"exec/current/setup/{exec_id}")
553553

554554
@retry_on_auth_error
555555
async def get_action_groups(self) -> list[ActionGroup]:
556-
"""List the action groups (scenarios)."""
556+
"""List the persisted action groups (scenarios)."""
557557
response = await self._get("actionGroups")
558558
return [ActionGroup(**action_group) for action_group in decamelize(response)]
559559

pyoverkiz/enums/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Convenience re-exports for the enums package."""
22

33
# Explicitly re-export all Enum subclasses to avoid wildcard import issues
4-
from pyoverkiz.enums.command import CommandMode, OverkizCommand, OverkizCommandParam
4+
from pyoverkiz.enums.command import ExecutionMode, OverkizCommand, OverkizCommandParam
55
from pyoverkiz.enums.execution import (
66
ExecutionState,
77
ExecutionSubType,
@@ -18,9 +18,9 @@
1818

1919
__all__ = [
2020
"APIType",
21-
"CommandMode",
2221
"DataType",
2322
"EventName",
23+
"ExecutionMode",
2424
"ExecutionState",
2525
"ExecutionSubType",
2626
"ExecutionType",

pyoverkiz/enums/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ class OverkizCommandParam(StrEnum):
766766

767767

768768
@unique
769-
class CommandMode(StrEnum):
770-
"""Execution mode flags for commands (e.g., high priority or geolocated)."""
769+
class ExecutionMode(StrEnum):
770+
"""Execution mode flags (e.g., high priority or geolocated)."""
771771

772772
HIGH_PRIORITY = "highPriority"
773773
GEOLOCATED = "geolocated"

tests/test_action_queue.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88
from pyoverkiz.action_queue import ActionQueue, QueuedExecution
9-
from pyoverkiz.enums import CommandMode, OverkizCommand
9+
from pyoverkiz.enums import ExecutionMode, OverkizCommand
1010
from pyoverkiz.models import Action, Command
1111

1212

@@ -112,7 +112,7 @@ async def test_action_queue_max_actions_flush(mock_executor):
112112

113113
@pytest.mark.asyncio
114114
async def test_action_queue_mode_change_flush(mock_executor):
115-
"""Test that queue flushes when command mode changes."""
115+
"""Test that queue flushes when execution mode changes."""
116116
queue = ActionQueue(executor=mock_executor, delay=0.5)
117117

118118
action = Action(
@@ -124,7 +124,7 @@ async def test_action_queue_mode_change_flush(mock_executor):
124124
queued1 = await queue.add([action], mode=None)
125125

126126
# Add action with high priority - should flush previous batch
127-
queued2 = await queue.add([action], mode=CommandMode.HIGH_PRIORITY)
127+
queued2 = await queue.add([action], mode=ExecutionMode.HIGH_PRIORITY)
128128

129129
# Wait for both batches
130130
exec_id1 = await queued1

utils/generate_enums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ async def generate_command_enums() -> None:
569569
command_file = Path(__file__).parent.parent / "pyoverkiz" / "enums" / "command.py"
570570
content = command_file.read_text()
571571

572-
find_class_start(content, "CommandMode")
572+
find_class_start(content, "ExecutionMode")
573573

574574
existing_commands = extract_enum_members(content, "OverkizCommand")
575575
existing_params = extract_enum_members(content, "OverkizCommandParam")
@@ -656,8 +656,8 @@ async def generate_command_enums() -> None:
656656
lines.append("")
657657
lines.append("")
658658

659-
# Append CommandMode class
660-
command_mode_start = content.find("@unique\nclass CommandMode")
659+
# Append ExecutionMode class
660+
command_mode_start = content.find("@unique\nclass ExecutionMode")
661661
if command_mode_start != -1:
662662
lines.append(content[command_mode_start:].rstrip())
663663
lines.append("")

0 commit comments

Comments
 (0)