Skip to content

Commit 73e9065

Browse files
authored
Force push_mode to be passed as a keyword argument for input adapters (#657)
* Fix nasty bug where Kafka adapter in Burst mode gave wrong Edge type Signed-off-by: Adam Glustein <adam.glustein@point72.com> * Force push_mode to be passed as a keyword argument, error if it is passed positionally Signed-off-by: Adam Glustein <adam.glustein@point72.com> --------- Signed-off-by: Adam Glustein <adam.glustein@point72.com>
1 parent bb04478 commit 73e9065

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

csp/adapters/kafka.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def subscribe(
187187
)
188188
properties["tick_timestamp_from_field"] = tick_timestamp_from_field
189189

190-
return _kafka_input_adapter_def(self, ts_type, properties, push_mode)
190+
return _kafka_input_adapter_def(self, ts_type, properties, push_mode=push_mode)
191191

192192
def publish(
193193
self,
@@ -225,7 +225,7 @@ def publish(
225225

226226
def status(self, push_mode=csp.PushMode.NON_COLLAPSING):
227227
ts_type = Status
228-
return status_adapter_def(self, ts_type, push_mode)
228+
return status_adapter_def(self, ts_type, push_mode=push_mode)
229229

230230
def __hash__(self):
231231
return hash((self._group_id_prefix, hash_mutable(self._properties)))

csp/adapters/parquet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def subscribe_dict_basket_struct_column(
268268

269269
def status(self, push_mode=PushMode.NON_COLLAPSING):
270270
ts_type = Status
271-
return status_adapter_def(self, ts_type, push_mode)
271+
return status_adapter_def(self, ts_type, push_mode=push_mode)
272272

273273
def _create(self, engine, memo):
274274
"""method needs to return the wrapped c++ adapter manager"""

csp/impl/wiring/adapters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def _instantiate_impl(cls, __forced_tvars, name, args, kwargs):
4343
def _instantiate(self, __forced_tvars, name, *args, **kwargs):
4444
return self._instantiate_func(__forced_tvars, name, args=args, kwargs=kwargs)
4545

46-
def __call__(cls, *args, **kwargs):
46+
def __call__(cls, *args, push_mode=PushMode.NON_COLLAPSING, **kwargs):
47+
if cls.is_input:
48+
kwargs["push_mode"] = push_mode
4749
return cls._instantiate(None, None, *args, **kwargs)
4850

4951
def using(cls, name=None, **__forced_tvars):
@@ -183,6 +185,7 @@ def _adapterdef(BaseDef, name, create_method, out_type, manager_type, memoize=Tr
183185
"memoize": memoize,
184186
"force_memoize": force_memoize,
185187
"_impl": create_method,
188+
"is_input": is_input,
186189
},
187190
)
188191
return adaptertype

csp/tests/adapters/test_kafka.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import typing
23
from datetime import date, datetime, timedelta
34

45
import pytest
@@ -514,6 +515,11 @@ def sub_graph():
514515
key="foo",
515516
push_mode=push_mode,
516517
)
518+
# ensure graph-time ts type is correct
519+
if push_mode == csp.PushMode.BURST:
520+
assert data.tstype.typ is typing.List[BasicData]
521+
else:
522+
assert data.tstype.typ is BasicData
517523
csp.add_graph_output(key, data)
518524
stop_flags.append(csp.count(data) == 1)
519525

0 commit comments

Comments
 (0)