-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: class based refactor for SDK #129
Merged
Merged
Changes from 66 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
e4df766
refactor init
kohlisid 382bdf2
init
kohlisid 87420ca
move infor
kohlisid 136da24
move infor
kohlisid 58b6496
await change
kohlisid 83d366a
await change
kohlisid ceee882
change to create task
kohlisid b828204
change to create task
kohlisid 837de07
ev loop
kohlisid c4f0376
cleanup
kohlisid b385e25
cleanup
kohlisid a22673b
cleanup
kohlisid fe52e9f
server on same thread
kohlisid e2c315d
server on same thread
kohlisid 28b5c70
server on same thread
kohlisid da9d1db
Export class
kohlisid 27967bf
Class refactor
kohlisid a0ac382
multiproc info fix
kohlisid 05a2cfe
modular
kohlisid 3f6049f
modular
kohlisid b642b17
modular
kohlisid 40bb295
modular
kohlisid e3b7090
mapstream
kohlisid 88bb474
mapstream
kohlisid e187f90
mapstream
kohlisid d7ff4a1
reduce
kohlisid 32d2975
reduce
kohlisid 3e3238a
sink
kohlisid e35b156
sink
kohlisid 1ba673d
sink
kohlisid 069d681
sink
kohlisid 285a1ae
sink
kohlisid e86fbe1
proto
kohlisid 98dd013
transform
kohlisid 9e268f8
source
kohlisid b517b6c
source
kohlisid 9c814c6
source
kohlisid 111684a
source
kohlisid 39788cd
source
kohlisid d7fe470
tests
kohlisid 7b96725
source
kohlisid 0a3c004
tests
kohlisid 50fd5c3
tests
kohlisid c76de42
examples
kohlisid 2aa9b30
examples
kohlisid 49c8b8d
cleanup
kohlisid bfde535
lint
kohlisid ebecebf
lint
kohlisid b11d086
README
kohlisid b2e7be3
SideInput
kohlisid 617f63a
tests
kohlisid 9bb16a7
tests
kohlisid e4656d5
tests
kohlisid 7c1b276
add uvloop
kohlisid 74efb87
seperate mappers
kohlisid fe6ec20
seperate mappers
kohlisid 0575d2d
seperate mapstream
kohlisid c1256f6
seperate reducer
kohlisid c7b8a84
seperate servers
kohlisid c0a025c
examples
kohlisid 678ec60
examples
kohlisid cdb97c1
examples
kohlisid a25387f
examples
kohlisid dffdc5f
examples
kohlisid 2742b56
examples
kohlisid 6bf2c4a
examples
kohlisid 6e44a6c
README
kohlisid cbf47bf
REDUCER INSTANCE
kohlisid d88ed5c
REDUCER INSTANCE
kohlisid 3961f95
deep copy
kohlisid 4065717
deep copy
kohlisid d2c844d
deep copy
kohlisid d3b59ff
lint
kohlisid 6b56383
add reducer test
kohlisid 02afc01
change reduce signature
kohlisid d8bcefe
comments
kohlisid d8ce1ce
comments
kohlisid 59d6550
comments
kohlisid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
import aiorun | ||
from collections.abc import Iterator | ||
from collections.abc import AsyncIterable | ||
|
||
|
||
from pynumaflow.reducer import ( | ||
Messages, | ||
Message, | ||
Datum, | ||
Metadata, | ||
AsyncReducer, | ||
ReduceAsyncServer, | ||
) | ||
|
||
|
||
async def my_handler(keys: list[str], datums: Iterator[Datum], md: Metadata) -> Messages: | ||
# count the number of events | ||
async def reduce_handler(keys: list[str], datums: AsyncIterable[Datum], md: Metadata) -> Messages: | ||
interval_window = md.interval_window | ||
counter = 0 | ||
async for _ in datums: | ||
counter += 1 | ||
|
||
msg = ( | ||
f"counter:{counter} interval_window_start:{interval_window.start} " | ||
f"interval_window_end:{interval_window.end}" | ||
) | ||
return Messages(Message(keys=keys, value=str.encode(msg))) | ||
return Messages(Message(str.encode(msg), keys=keys)) | ||
|
||
|
||
if __name__ == "__main__": | ||
grpc_server = AsyncReducer(handler=my_handler) | ||
aiorun.run(grpc_server.start()) | ||
grpc_server = ReduceAsyncServer(reduce_handler) | ||
grpc_server.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
from pynumaflow.mapper import Messages, Message, Datum, Mapper | ||
from pynumaflow.mapper import Messages, Message, Datum, MapServer, Mapper | ||
|
||
|
||
def my_handler(keys: list[str], datum: Datum) -> Messages: | ||
val = datum.value | ||
_ = datum.event_time | ||
_ = datum.watermark | ||
strs = val.decode("utf-8").split(",") | ||
messages = Messages() | ||
if len(strs) == 0: | ||
messages.append(Message.to_drop()) | ||
class Flatmap(Mapper): | ||
def handler(self, keys: list[str], datum: Datum) -> Messages: | ||
val = datum.value | ||
_ = datum.event_time | ||
_ = datum.watermark | ||
strs = val.decode("utf-8").split(",") | ||
messages = Messages() | ||
if len(strs) == 0: | ||
messages.append(Message.to_drop()) | ||
return messages | ||
for s in strs: | ||
messages.append(Message(str.encode(s))) | ||
return messages | ||
for s in strs: | ||
messages.append(Message(str.encode(s))) | ||
return messages | ||
|
||
|
||
if __name__ == "__main__": | ||
grpc_server = Mapper(handler=my_handler) | ||
grpc_server = MapServer(Flatmap()) | ||
grpc_server.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify readme. give an overral gist and point them to examples. take a look how go's is written.