Skip to content

Commit 70c3662

Browse files
committed
Rename timeout_ms to inactivity_gap_ms
1 parent 0ab8812 commit 70c3662

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
@@ -1529,7 +1529,7 @@ def sliding_count_window(
15291529

15301530
def session_window(
15311531
self,
1532-
timeout_ms: Union[int, timedelta],
1532+
inactivity_gap_ms: Union[int, timedelta],
15331533
grace_ms: Union[int, timedelta] = 0,
15341534
name: Optional[str] = None,
15351535
on_late: Optional[WindowOnLateCallback] = None,
@@ -1568,7 +1568,7 @@ def session_window(
15681568
sdf = (
15691569
# Define a session window with 30-second timeout and 10-second grace period
15701570
sdf.session_window(
1571-
timeout_ms=timedelta(seconds=30),
1571+
inactivity_gap_ms=timedelta(seconds=30),
15721572
grace_ms=timedelta(seconds=10)
15731573
)
15741574
@@ -1584,7 +1584,7 @@ def session_window(
15841584
)
15851585
```
15861586
1587-
:param timeout_ms: The session timeout period.
1587+
:param inactivity_gap_ms: The session timeout period.
15881588
If no new events arrive within this period, the session will be closed.
15891589
Can be specified as either an `int` representing milliseconds
15901590
or a `timedelta` object.
@@ -1613,11 +1613,11 @@ def session_window(
16131613
This object can be further configured with aggregation functions
16141614
like `sum`, `count`, etc. applied to the StreamingDataFrame.
16151615
"""
1616-
timeout_ms = ensure_milliseconds(timeout_ms)
1616+
inactivity_gap_ms = ensure_milliseconds(inactivity_gap_ms)
16171617
grace_ms = ensure_milliseconds(grace_ms)
16181618

16191619
return SessionWindowDefinition(
1620-
timeout_ms=timeout_ms,
1620+
inactivity_gap_ms=inactivity_gap_ms,
16211621
grace_ms=grace_ms,
16221622
dataframe=self,
16231623
name=name,

quixstreams/dataframe/windows/definitions.py

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

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

564564
super().__init__(name, dataframe, on_late)
565565

566-
self._timeout_ms = timeout_ms
566+
self._inactivity_gap_ms = inactivity_gap_ms
567567
self._grace_ms = grace_ms
568568

569-
@property
570-
def timeout_ms(self) -> int:
571-
return self._timeout_ms
572-
573569
@property
574570
def grace_ms(self) -> int:
575571
return self._grace_ms
576572

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

584580
def _create_window(
585581
self,
@@ -596,7 +592,7 @@ def _create_window(
596592
window_type = SessionWindowMultiAggregation
597593

598594
return window_type(
599-
timeout_ms=self._timeout_ms,
595+
timeout_ms=self._inactivity_gap_ms,
600596
grace_ms=self._grace_ms,
601597
name=self._get_name(func_name=func_name),
602598
dataframe=self._dataframe,

0 commit comments

Comments
 (0)