Skip to content

Commit 350153b

Browse files
committed
Rename base class from Item to TimelineItem
(so that we can reuse Item to add deprecated backwards compatibility in a next commit)
1 parent 513cb29 commit 350153b

3 files changed

Lines changed: 35 additions & 35 deletions

File tree

docs/timeline/model.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ Model
1111
:undoc-members:
1212
:show-inheritance:
1313

14-
.. autoclass:: yamcs.client.Item
15-
:members:
16-
:undoc-members:
17-
:show-inheritance:
18-
1914
.. autoclass:: yamcs.client.ItemBand
2015
:members:
2116
:undoc-members:
@@ -61,6 +56,11 @@ Model
6156
:undoc-members:
6257
:show-inheritance:
6358

59+
.. autoclass:: yamcs.client.TimelineItem
60+
:members:
61+
:undoc-members:
62+
:show-inheritance:
63+
6464
.. autoclass:: yamcs.client.TimelineActivity
6565
:members:
6666
:undoc-members:

yamcs-client/src/yamcs/client/timeline/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from yamcs.client.core import pagination
55
from yamcs.client.core.context import Context
66
from yamcs.client.core.helpers import to_isostring, to_server_time
7-
from yamcs.client.timeline.model import Band, Item, View
7+
from yamcs.client.timeline.model import Band, TimelineItem, View
88
from yamcs.protobuf.timeline import timeline_pb2
99

1010
__all__ = [
@@ -141,7 +141,7 @@ def list_items(
141141
start: Optional[datetime.datetime] = None,
142142
stop: Optional[datetime.datetime] = None,
143143
page_size: int = 500,
144-
) -> Iterable[Item]:
144+
) -> Iterable[TimelineItem]:
145145
"""
146146
List the items.
147147
@@ -171,10 +171,10 @@ def list_items(
171171
params=params,
172172
response_class=timeline_pb2.ListItemsResponse,
173173
items_key="items",
174-
item_mapper=Item._as_subclass,
174+
item_mapper=TimelineItem._as_subclass,
175175
)
176176

177-
def get_item(self, id: str) -> Item:
177+
def get_item(self, id: str) -> TimelineItem:
178178
"""
179179
Fetch an item by its identifier.
180180
@@ -185,14 +185,14 @@ def get_item(self, id: str) -> Item:
185185
response = self.ctx.get_proto(url)
186186
message = timeline_pb2.TimelineItem()
187187
message.ParseFromString(response.content)
188-
return Item._from_proto(message)
188+
return TimelineItem._from_proto(message)
189189

190-
def save_item(self, item: Item):
190+
def save_item(self, item: TimelineItem):
191191
"""
192192
Save or update an item.
193193
194194
:param item:
195-
Item object
195+
TimelineItem object
196196
"""
197197
url = f"/timeline/{self._instance}/items/{item.id}"
198198
req = timeline_pb2.SaveItemRequest()

yamcs-client/src/yamcs/client/timeline/model.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
__all__ = [
1313
"Band",
1414
"CommandBand",
15-
"Item",
1615
"ItemBand",
1716
"OnCompletion",
1817
"OnFailure",
@@ -26,6 +25,7 @@
2625
"StartCondition",
2726
"TimelineActivity",
2827
"TimelineEvent",
28+
"TimelineItem",
2929
"TimelineTask",
3030
"TimeRuler",
3131
"Trace",
@@ -84,13 +84,13 @@ class OnCompletion:
8484
success or failure).
8585
"""
8686

87-
item: Union["Item", str]
87+
item: Union["TimelineItem", str]
8888
"""Predecessor item (or its identifier)"""
8989

9090
@property
9191
def item_id(self) -> str:
9292
"""Item identifier of the predecessor"""
93-
if isinstance(self.item, Item):
93+
if isinstance(self.item, TimelineItem):
9494
return self.item.id
9595
else:
9696
return self.item
@@ -103,13 +103,13 @@ def _to_predecessor(self) -> "Predecessor":
103103
class OnSuccess:
104104
"""The item starts only if the predecessor has completed successfully."""
105105

106-
item: Union["Item", str]
106+
item: Union["TimelineItem", str]
107107
"""Predecessor item (or its identifier)"""
108108

109109
@property
110110
def item_id(self) -> str:
111111
"""Item identifier of the predecessor"""
112-
if isinstance(self.item, Item):
112+
if isinstance(self.item, TimelineItem):
113113
return self.item.id
114114
else:
115115
return self.item
@@ -122,13 +122,13 @@ def _to_predecessor(self) -> "Predecessor":
122122
class OnFailure:
123123
"""The item starts only if the predecessor has failed."""
124124

125-
item: Union["Item", str]
125+
item: Union["TimelineItem", str]
126126
"""Predecessor item (or its identifier)"""
127127

128128
@property
129129
def item_id(self) -> str:
130130
"""Item identifier of the predecessor"""
131-
if isinstance(self.item, Item):
131+
if isinstance(self.item, TimelineItem):
132132
return self.item.id
133133
else:
134134
return self.item
@@ -141,13 +141,13 @@ def _to_predecessor(self) -> "Predecessor":
141141
class OnStart:
142142
"""The item starts as soon as the predecessor has started."""
143143

144-
item: Union["Item", str]
144+
item: Union["TimelineItem", str]
145145
"""Predecessor item (or its identifier)"""
146146

147147
@property
148148
def item_id(self) -> str:
149149
"""Item identifier of the predecessor"""
150-
if isinstance(self.item, Item):
150+
if isinstance(self.item, TimelineItem):
151151
return self.item.id
152152
else:
153153
return self.item
@@ -165,7 +165,7 @@ def _to_predecessor(self) -> "Predecessor":
165165
@dataclass
166166
class Predecessor:
167167

168-
item: Union[str, "Item"]
168+
item: Union[str, "TimelineItem"]
169169
"""Predecessor item (or its identifier)"""
170170

171171
start_condition: StartCondition = StartCondition.ON_SUCCESS
@@ -174,7 +174,7 @@ class Predecessor:
174174
@property
175175
def item_id(self) -> str:
176176
"""Item identifier of the predecessor"""
177-
if isinstance(self.item, Item):
177+
if isinstance(self.item, TimelineItem):
178178
return self.item.id
179179
else:
180180
return self.item
@@ -193,7 +193,7 @@ def _to_proto(self) -> timeline_pb2.PredecessorInfo:
193193
return proto
194194

195195

196-
class Item(abc.ABC):
196+
class TimelineItem(abc.ABC):
197197

198198
def __init__(
199199
self,
@@ -305,7 +305,7 @@ def _to_start_trigger(predecessor: Predecessor) -> StartTrigger:
305305

306306
@staticmethod
307307
@abc.abstractmethod
308-
def _from_proto(proto: timeline_pb2.TimelineItem) -> "Item":
308+
def _from_proto(proto: timeline_pb2.TimelineItem) -> "TimelineItem":
309309
pass
310310

311311
@staticmethod
@@ -338,7 +338,7 @@ def _to_proto(self) -> timeline_pb2.TimelineItem:
338338
return proto
339339

340340

341-
class TimelineEvent(Item):
341+
class TimelineEvent(TimelineItem):
342342
"""
343343
An event on the timeline. This has a fixed start time, and an
344344
optional duration.
@@ -393,7 +393,7 @@ def __init__(
393393
:param extra:
394394
Project-specific properties (ignored by Yamcs)
395395
"""
396-
Item.__init__(
396+
TimelineItem.__init__(
397397
self,
398398
name=name,
399399
start=start,
@@ -471,7 +471,7 @@ def _from_proto(proto: timeline_pb2.TimelineItem) -> "TimelineEvent":
471471

472472

473473
@dataclass
474-
class TimelineActivity(Item):
474+
class TimelineActivity(TimelineItem):
475475
"""
476476
An activity on the timeline. Activities can be scheduled at a fixed
477477
time, or they can be scheduled relative to predecessor items.
@@ -515,7 +515,7 @@ def __init__(
515515
:param extra:
516516
Project-specific properties (ignored by Yamcs)
517517
"""
518-
Item.__init__(
518+
TimelineItem.__init__(
519519
self,
520520
name=name,
521521
start=start,
@@ -538,9 +538,9 @@ def _from_proto(proto: timeline_pb2.TimelineItem) -> "TimelineActivity":
538538
if not predecessors:
539539
start = parse_server_time(proto.start)
540540
elif len(predecessors) == 1:
541-
start = Item._to_start_trigger(predecessors[0])
541+
start = TimelineItem._to_start_trigger(predecessors[0])
542542
else:
543-
start = [Item._to_start_trigger(x) for x in predecessors]
543+
start = [TimelineItem._to_start_trigger(x) for x in predecessors]
544544

545545
item = TimelineActivity(
546546
id=proto.id,
@@ -571,7 +571,7 @@ def _to_proto(self) -> timeline_pb2.TimelineItem:
571571

572572

573573
@dataclass
574-
class TimelineTask(Item):
574+
class TimelineTask(TimelineItem):
575575
"""
576576
A task on the timeline. Tasks are actions to be performed by the
577577
user. Tasks can be scheduled at a fixed time, or they can be
@@ -614,7 +614,7 @@ def __init__(
614614
:param extra:
615615
Project-specific properties (ignored by Yamcs)
616616
"""
617-
Item.__init__(
617+
TimelineItem.__init__(
618618
self,
619619
name=name,
620620
start=start,
@@ -634,9 +634,9 @@ def _from_proto(proto: timeline_pb2.TimelineItem) -> "TimelineTask":
634634
if not predecessors:
635635
start = parse_server_time(proto.start)
636636
elif len(predecessors) == 1:
637-
start = Item._to_start_trigger(predecessors[0])
637+
start = TimelineItem._to_start_trigger(predecessors[0])
638638
else:
639-
start = [Item._to_start_trigger(x) for x in predecessors]
639+
start = [TimelineItem._to_start_trigger(x) for x in predecessors]
640640

641641
item = TimelineTask(
642642
id=proto.id,

0 commit comments

Comments
 (0)