Skip to content

Commit fadbd4b

Browse files
committed
Rename timeout_ms to inactivity_gap_ms
1 parent c0a7c7b commit fadbd4b

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

quixstreams/dataframe/dataframe.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ def sliding_count_window(
14871487

14881488
def session_window(
14891489
self,
1490-
timeout_ms: Union[int, timedelta],
1490+
inactivity_gap_ms: Union[int, timedelta],
14911491
grace_ms: Union[int, timedelta] = 0,
14921492
name: Optional[str] = None,
14931493
on_late: Optional[WindowOnLateCallback] = None,
@@ -1526,7 +1526,7 @@ def session_window(
15261526
sdf = (
15271527
# Define a session window with 30-second timeout and 10-second grace period
15281528
sdf.session_window(
1529-
timeout_ms=timedelta(seconds=30),
1529+
inactivity_gap_ms=timedelta(seconds=30),
15301530
grace_ms=timedelta(seconds=10)
15311531
)
15321532
@@ -1542,7 +1542,7 @@ def session_window(
15421542
)
15431543
```
15441544
1545-
:param timeout_ms: The session timeout period.
1545+
:param inactivity_gap_ms: The session timeout period.
15461546
If no new events arrive within this period, the session will be closed.
15471547
Can be specified as either an `int` representing milliseconds
15481548
or a `timedelta` object.
@@ -1571,11 +1571,11 @@ def session_window(
15711571
This object can be further configured with aggregation functions
15721572
like `sum`, `count`, etc. applied to the StreamingDataFrame.
15731573
"""
1574-
timeout_ms = ensure_milliseconds(timeout_ms)
1574+
inactivity_gap_ms = ensure_milliseconds(inactivity_gap_ms)
15751575
grace_ms = ensure_milliseconds(grace_ms)
15761576

15771577
return SessionWindowDefinition(
1578-
timeout_ms=timeout_ms,
1578+
inactivity_gap_ms=inactivity_gap_ms,
15791579
grace_ms=grace_ms,
15801580
dataframe=self,
15811581
name=name,

quixstreams/dataframe/windows/definitions.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -546,38 +546,34 @@ class SessionWindowDefinition(WindowDefinition):
546546

547547
def __init__(
548548
self,
549-
timeout_ms: int,
549+
inactivity_gap_ms: int,
550550
grace_ms: int,
551551
dataframe: "StreamingDataFrame",
552552
name: Optional[str] = None,
553553
on_late: Optional[WindowOnLateCallback] = None,
554554
):
555-
if not isinstance(timeout_ms, int):
555+
if not isinstance(inactivity_gap_ms, int):
556556
raise TypeError("Session timeout must be an integer")
557-
if timeout_ms < 1:
557+
if inactivity_gap_ms < 1:
558558
raise ValueError("Session timeout cannot be smaller than 1ms")
559559
if grace_ms < 0:
560560
raise ValueError("Session grace cannot be smaller than 0ms")
561561

562562
super().__init__(name, dataframe, on_late)
563563

564-
self._timeout_ms = timeout_ms
564+
self._inactivity_gap_ms = inactivity_gap_ms
565565
self._grace_ms = grace_ms
566566

567-
@property
568-
def timeout_ms(self) -> int:
569-
return self._timeout_ms
570-
571567
@property
572568
def grace_ms(self) -> int:
573569
return self._grace_ms
574570

575571
def _get_name(self, func_name: Optional[str]) -> str:
576572
prefix = f"{self._name}_session_window" if self._name else "session_window"
577573
if func_name:
578-
return f"{prefix}_{self._timeout_ms}_{func_name}"
574+
return f"{prefix}_{self._inactivity_gap_ms}_{func_name}"
579575
else:
580-
return f"{prefix}_{self._timeout_ms}"
576+
return f"{prefix}_{self._inactivity_gap_ms}"
581577

582578
def _create_window(
583579
self,
@@ -594,7 +590,7 @@ def _create_window(
594590
window_type = SessionWindowMultiAggregation
595591

596592
return window_type(
597-
timeout_ms=self._timeout_ms,
593+
timeout_ms=self._inactivity_gap_ms,
598594
grace_ms=self._grace_ms,
599595
name=self._get_name(func_name=func_name),
600596
dataframe=self._dataframe,

0 commit comments

Comments
 (0)