Skip to content

Commit 61b88f7

Browse files
committed
Fix ref binding
1 parent 4a9c57d commit 61b88f7

2 files changed

Lines changed: 225 additions & 195 deletions

File tree

hgraph/_impl/_types/_ref.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,29 @@ def __iter__(self):
444444
# Only iterate if items were already created (don't force creation)
445445
return iter(self._items) if self._items else iter([])
446446

447+
def clone_binding(self, other: TimeSeriesReferenceInput):
448+
# Ensure list items exist when cloning from another list reference input
449+
# that already expanded its children.
450+
self.un_bind_output()
451+
if other.output:
452+
self.bind_output(other.output)
453+
elif other._items:
454+
if self._items is None:
455+
if self._value_builder is None:
456+
raise RuntimeError("REF[TSL] value_builder not set by builder")
457+
self._items = [
458+
self._value_builder.make_instance(owning_input=self)
459+
for _ in range(self._size)
460+
]
461+
for o, s in zip(other._items, self._items):
462+
s.clone_binding(o)
463+
elif other.value:
464+
self._value = other.value
465+
if self.owning_node.is_started:
466+
self._sample_time = self.owning_graph.evaluation_clock.evaluation_time
467+
if self.active:
468+
self.notify(self._sample_time)
469+
447470

448471
@dataclass
449472
class PythonTimeSeriesBundleReferenceInput(PythonTimeSeriesReferenceInput, Generic[TIME_SERIES_TYPE]):

0 commit comments

Comments
 (0)