Skip to content

Commit ccbf676

Browse files
committed
Update to latest dispatch-api
Renames a few fields, but stays compatible otherwise. Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 1e05672 commit ccbf676

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ classifiers = [
3737
requires-python = ">= 3.11, < 4"
3838
dependencies = [
3939
"typing-extensions >= 4.6.1, < 5",
40-
"frequenz-api-dispatch == 1.0.0-rc1",
40+
"frequenz-api-dispatch == 1.0.0-rc2",
4141
"frequenz-client-base >= 0.8.0, < 0.12.0",
4242
"frequenz-client-common >= 0.1.0, < 0.4.0",
4343
"grpcio >= 1.70.0, < 2",
@@ -93,7 +93,7 @@ dev-pylint = [
9393
"pylint == 3.3.7",
9494
# For checking the noxfile, docs/ script, and tests
9595
"frequenz-client-dispatch[cli,dev-mkdocs,dev-noxfile,dev-pytest]",
96-
"frequenz-api-dispatch == 1.0.0-rc1",
96+
"frequenz-api-dispatch == 1.0.0-rc2",
9797
]
9898
dev-pytest = [
9999
"pytest == 8.3.5",

src/frequenz/client/dispatch/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def to_interval(
166166
) -> PBTimeIntervalFilter | None:
167167
return (
168168
PBTimeIntervalFilter(
169-
**{"from": to_timestamp(from_)}, to=to_timestamp(to)
169+
from_time=to_timestamp(from_), to_time=to_timestamp(to)
170170
)
171171
if from_ or to
172172
else None

src/frequenz/client/dispatch/recurrence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def from_protobuf(cls, pb_criteria: PBRecurrenceRule.EndCriteria) -> "EndCriteri
8888
match pb_criteria.WhichOneof("count_or_until"):
8989
case "count":
9090
instance.count = pb_criteria.count
91-
case "until":
92-
instance.until = to_datetime(pb_criteria.until)
91+
case "until_time":
92+
instance.until = to_datetime(pb_criteria.until_time)
9393
return instance
9494

9595
def to_protobuf(self) -> PBRecurrenceRule.EndCriteria:
@@ -103,7 +103,7 @@ def to_protobuf(self) -> PBRecurrenceRule.EndCriteria:
103103
if self.count is not None:
104104
pb_criteria.count = self.count
105105
elif self.until is not None:
106-
pb_criteria.until.CopyFrom(to_timestamp(self.until))
106+
pb_criteria.until_time.CopyFrom(to_timestamp(self.until))
107107

108108
return pb_criteria
109109

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,20 @@ def _filter_dispatch(
188188
if target != dispatch.target:
189189
return False
190190
if _filter.HasField("start_time_interval"):
191-
if start_from := _filter.start_time_interval.__dict__["from"]:
191+
if start_from := _filter.start_time_interval.from_time:
192192
if dispatch.start_time < _to_dt(start_from):
193193
return False
194-
if start_to := _filter.start_time_interval.to:
194+
if start_to := _filter.start_time_interval.to_time:
195195
if dispatch.start_time >= _to_dt(start_to):
196196
return False
197197
if _filter.HasField("end_time_interval"):
198-
if end_from := _filter.end_time_interval.__dict__["from"]:
198+
if end_from := _filter.end_time_interval.from_time:
199199
if (
200200
dispatch.duration
201201
and dispatch.start_time + dispatch.duration < _to_dt(end_from)
202202
):
203203
return False
204-
if end_to := _filter.end_time_interval.to:
204+
if end_to := _filter.end_time_interval.to_time:
205205
if (
206206
dispatch.duration
207207
and dispatch.start_time + dispatch.duration >= _to_dt(end_to)

src/frequenz/client/dispatch/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def from_protobuf(cls, pb_object: PBDispatch) -> "Dispatch":
295295
id=pb_object.metadata.dispatch_id,
296296
type=pb_object.data.type,
297297
create_time=to_datetime(pb_object.metadata.create_time),
298-
update_time=to_datetime(pb_object.metadata.modification_time),
298+
update_time=to_datetime(pb_object.metadata.update_time),
299299
end_time=(
300300
to_datetime(pb_object.metadata.end_time)
301301
if pb_object.metadata.HasField("end_time")
@@ -327,7 +327,7 @@ def to_protobuf(self) -> PBDispatch:
327327
metadata=DispatchMetadata(
328328
dispatch_id=self.id,
329329
create_time=to_timestamp(self.create_time),
330-
modification_time=to_timestamp(self.update_time),
330+
update_time=to_timestamp(self.update_time),
331331
end_time=(
332332
to_timestamp(self.end_time) if self.end_time is not None else None
333333
),

0 commit comments

Comments
 (0)