Skip to content

feat: add support for optional pulsetime param to flood in query2#135

Open
ErikBjare wants to merge 1 commit intomasterfrom
dev/custom-flood-pulsetime
Open

feat: add support for optional pulsetime param to flood in query2#135
ErikBjare wants to merge 1 commit intomasterfrom
dev/custom-flood-pulsetime

Conversation

@ErikBjare
Copy link
Copy Markdown
Member

I had this in a dirty working tree, can't remember why I added it. But kinda makes sense?

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR adds an optional pulsetime: float = 5 parameter to q2_flood in the query2 interface, forwarding it to aw_transform.flood(). The default matches flood()'s own default so existing queries are unaffected. A new test validates the underlying flood() function with a custom pulsetime value.

  • q2_flood now accepts pulsetime: float = 5 and passes it through to flood(), enabling callers to override the gap-fill threshold.
  • A new test verifies that a 30s gap is not flooded at the default pulsetime=5 but is flooded when pulsetime=31.

Confidence Score: 4/5

Safe to merge; the wrapper change is minimal and backwards-compatible, with the only gap being that the query2 decorator chain is untested with the new parameter.

The wrapper change is a one-liner with a default that preserves existing behaviour, and the underlying flood() already supported pulsetime. The new test validates the right outcome but exercises only the raw flood() function — the q2_function/q2_typecheck decorator chain that manipulates positional args is not covered, leaving a small blind spot.

tests/test_flood.py — consider adding a test that calls q2_flood through the query2 layer to confirm pulsetime survives the decorator chain.

Important Files Changed

Filename Overview
aw_query/functions.py Adds optional pulsetime: float = 5 param to q2_flood, forwarding it to the underlying flood() call; default matches flood()'s own default, so existing behaviour is unchanged.
tests/test_flood.py Adds test_flood_with_custom_pulsetime covering the underlying flood() function; the query2 wrapper (q2_flood) is not exercised with the new parameter.

Sequence Diagram

sequenceDiagram
    participant Query as query2 engine
    participant q2_flood
    participant flood as aw_transform.flood()

    Query->>q2_flood: "flood(events, pulsetime=31)"
    Note over q2_flood: q2_function strips datastore/namespace args
    Note over q2_flood: q2_typecheck validates required args only
    q2_flood->>flood: "flood(events, pulsetime=31)"
    flood-->>q2_flood: "List[Event] (gaps <= 31s filled)"
    q2_flood-->>Query: List[Event]
Loading

Reviews (1): Last reviewed commit: "feat: add support for optional pulsetime..." | Re-trigger Greptile

Comment thread tests/test_flood.py
Comment on lines +83 to +101
def test_flood_with_custom_pulsetime():
"""Test that flood respects custom pulsetime parameter"""
# Create events with 30s gap (simulating 30s poll_time)
events = [
Event(timestamp=now, duration=5, data={"a": 0}),
Event(timestamp=now + 35 * td1s, duration=5, data={"b": 1}),
]

# With default pulsetime=5, gap should NOT be flooded
flooded_default = flood(events)
assert len(flooded_default) == 2
total_duration_default = sum((e.duration for e in flooded_default), timedelta(0))
assert total_duration_default == timedelta(seconds=10)

# With pulsetime=31 (matching 30s poll_time + 1), gap should be flooded
flooded_custom = flood(events, pulsetime=31)
assert len(flooded_custom) == 2
total_duration_custom = sum((e.duration for e in flooded_custom), timedelta(0))
assert total_duration_custom == timedelta(seconds=40) # Full duration with gap filled
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Test covers flood() directly, not q2_flood through the query2 layer

The new test validates the underlying flood() function with pulsetime, but it doesn't verify that the parameter is correctly forwarded through the q2_flood wrapper and its decorator chain (q2_function + q2_typecheck). Since q2_function manipulates *args by stripping datastore/namespace arguments positionally, a positional-index shift bug in the decorator could cause pulsetime to be silently ignored without this test catching it. There are no existing q2_flood tests in test_query2.py to compensate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant