Skip to content

Commit a70fec3

Browse files
committed
Rename client-side create request fields is_{active,dry_run}
Makes it easier to handle & compare the request object with a dispatch object, also adds more consistency overall. Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 5a2cadf commit a70fec3

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/frequenz/client/dispatch/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ async def create(
153153
start_time=start_time,
154154
duration=duration,
155155
selector=selector,
156-
is_active=active,
157-
is_dry_run=dry_run,
156+
active=active,
157+
dry_run=dry_run,
158158
payload=payload or {},
159159
recurrence=recurrence or RecurrenceRule(),
160160
).to_protobuf()

src/frequenz/client/dispatch/_internal_types.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class DispatchCreateRequest:
4848
selector: ComponentSelector
4949
"""The component selector specifying which components the dispatch targets."""
5050

51-
is_active: bool
51+
active: bool
5252
"""Indicates whether the dispatch is active and eligible for processing."""
5353

54-
is_dry_run: bool
54+
dry_run: bool
5555
"""Indicates if the dispatch is a dry run.
5656
5757
Executed for logging and monitoring without affecting actual component states."""
@@ -84,8 +84,8 @@ def from_protobuf(
8484
start_time=to_datetime(pb_object.start_time),
8585
duration=timedelta(seconds=pb_object.duration),
8686
selector=component_selector_from_protobuf(pb_object.selector),
87-
is_active=pb_object.is_active,
88-
is_dry_run=pb_object.is_dry_run,
87+
active=pb_object.is_active,
88+
dry_run=pb_object.is_dry_run,
8989
payload=MessageToDict(pb_object.payload),
9090
recurrence=RecurrenceRule.from_protobuf(pb_object.recurrence),
9191
)
@@ -103,8 +103,8 @@ def to_protobuf(self) -> PBDispatchCreateRequest:
103103
pb_request.start_time.CopyFrom(to_timestamp(self.start_time))
104104
pb_request.duration = int(self.duration.total_seconds())
105105
pb_request.selector.CopyFrom(component_selector_to_protobuf(self.selector))
106-
pb_request.is_active = self.is_active
107-
pb_request.is_dry_run = self.is_dry_run
106+
pb_request.is_active = self.active
107+
pb_request.is_dry_run = self.dry_run
108108
pb_request.payload.update(self.payload)
109109
pb_request.recurrence.CopyFrom(self.recurrence.to_protobuf())
110110

src/frequenz/client/dispatch/test/_service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ def _dispatch_from_request(
240240
The initialized dispatch.
241241
"""
242242
params = _request.__dict__
243-
params["active"] = params.pop("is_active")
244-
params["dry_run"] = params.pop("is_dry_run")
245243

246244
return Dispatch(
247245
id=_id,

0 commit comments

Comments
 (0)