Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
922a0f7
init commit
Sep 6, 2022
837cc57
generate proto code
Sep 6, 2022
7beeca8
implement isReady
Sep 7, 2022
b919ebb
update pyi file
Sep 7, 2022
8715ea7
implement initial map fn
Sep 7, 2022
fa7acc5
add graceful shutdown
Sep 8, 2022
03b291e
set up development env
Sep 8, 2022
a19a14e
refactor
Sep 8, 2022
5f980cf
incomplete refactor, wip
Sep 8, 2022
fb42383
update import
Sep 8, 2022
2baee4b
add new data types, update mapfn, update tests
Sep 10, 2022
c667696
update test and run format
Sep 12, 2022
5f0b29c
clean up test datatypes
Sep 12, 2022
339de57
add tests
Sep 12, 2022
4482dab
fix time datatype and update tests
Sep 12, 2022
2d3fb45
re fmt
Sep 12, 2022
6dda94b
update test, update readme
Sep 12, 2022
b8c9e2a
add back sink example
Sep 12, 2022
ab01f51
update readme
Sep 12, 2022
a4f4ab1
remove .DS_Store
Sep 12, 2022
943a2f7
remove try expect in mapfn
Sep 13, 2022
6503541
ignore udfunction files
Sep 13, 2022
9b3de03
revert makefile
Sep 13, 2022
72ce074
try to improve codecov..add test_start
Sep 13, 2022
3df354e
make format
Sep 13, 2022
4b33012
delete one line in encoder
Sep 13, 2022
daded92
add reduce fn placeholder
Sep 13, 2022
105051c
add test case..
Sep 13, 2022
b6f4126
improve codecov & reformat
Sep 13, 2022
4ccb4c1
add test
Sep 13, 2022
886316f
add todo in makefile
Sep 13, 2022
a9727b1
update readme with TODO
Sep 13, 2022
fedb564
ignore proto file
Sep 13, 2022
bbb181e
update datum type event time and watermark type check condition
Sep 13, 2022
d6b4d06
update messages dump method
Sep 13, 2022
2ebaaa5
refactor generated code
Sep 13, 2022
15d2b8b
rename pyi file
Sep 13, 2022
9e53331
update example
Sep 13, 2022
3638df4
add docs for _dtypes.py
Sep 13, 2022
8c13803
update server.py and test and docs
Sep 13, 2022
e135aeb
update server __serve to use only one UDS
Sep 13, 2022
386c553
update messages test and refmt
Sep 13, 2022
d98c2e1
update type error msg
Sep 13, 2022
bf5c98b
update data types and methods based on comments
Sep 13, 2022
41a7a5b
update codecov ignore
Sep 13, 2022
2ed3f67
add grpcio-testing to dev dependencies
Sep 13, 2022
f238d20
Revert "add grpcio-testing to dev dependencies"
Sep 13, 2022
7cb0068
fix tests
Sep 13, 2022
6cb2eca
udpate example
Sep 13, 2022
b5e0aaa
remove protobuf
Sep 14, 2022
9d6dd15
update version
Sep 14, 2022
7448e4a
add data types for UserDefinedFunctionServicer: todo context datatype
Sep 14, 2022
ab672ce
add a types.py
Sep 14, 2022
5991ceb
update poetry and grpcio-tools
Sep 14, 2022
7583526
add NumaflowServicerContext type
Sep 14, 2022
0d77a7a
add tests
Sep 14, 2022
c324ea5
refactor datum type to align with the numaflow-go design
Sep 14, 2022
b5c18f9
add TODO
Sep 14, 2022
e82de65
update example
Sep 14, 2022
764ee62
update function __init__.py
Sep 14, 2022
41ece46
update str for time type
Sep 15, 2022
50a6441
add comments for camel case functions
Sep 15, 2022
8587ca3
refactor the Datum type to align with the numaflow-go design
Sep 15, 2022
40a2d79
update Datum docstring
Sep 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ coverage:

ignore:
- "examples/"
- "pynumaflow/function/generated/udfunction_pb2.py"
- "pynumaflow/function/_udfunction_pb2.pyi"
- "pynumaflow/function/generated/udfunction_pb2_grpc.py"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.

.idea/

# Proto files are coming from numaflow-go https://github.com/numaproj/numaflow-go
protos/
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ format:

test:
poetry run pytest pynumaflow/tests/

# TODO: proto file generate
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,26 @@ and [UDSinks](https://numaproj.github.io/numaflow/sinks/user-defined-sinks/) in
## Implement a User Defined Function (UDF)

```python
from pynumaflow.function import Message, Messages, HTTPHandler
import random

from pynumaflow.function import Messages, Message, Datum
from pynumaflow.function.server import UserDefinedFunctionServicer

def my_handler(key: bytes, value: bytes, _) -> Messages:

def map_handler(key: str, datum: Datum) -> Messages:
val = datum.value
_ = datum.event_time
_ = datum.watermark
messages = Messages()
if random.randint(0, 10) % 2 == 0:
messages.append(Message.to_all(value))
else:
messages.append(Message.to_drop())
messages.append(Message.to_vtx(key, val))
return messages


if __name__ == "__main__":
handler = HTTPHandler(my_handler)
handler.start()
grpc_server = UserDefinedFunctionServicer(map_handler)
grpc_server.start()
```

### Sample Image

A sample UDF [Dockerfile](examples/function/udfproj/Dockerfile) is provided
under [examples](examples/function/udfproj).

### Sample Image (TODO)

## Implement a User Defined Sink (UDSink)

Expand Down
16 changes: 16 additions & 0 deletions examples/function/forward_message/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pynumaflow.function import Messages, Message, Datum
from pynumaflow.function.server import UserDefinedFunctionServicer


def map_handler(key: str, datum: Datum) -> Messages:
val = datum.value
_ = datum.event_time
_ = datum.watermark
messages = Messages()
messages.append(Message.to_vtx(key, val))
return messages


if __name__ == "__main__":
grpc_server = UserDefinedFunctionServicer(map_handler)
grpc_server.start()
1 change: 0 additions & 1 deletion examples/function/udfproj/.python-version

This file was deleted.

43 changes: 0 additions & 43 deletions examples/function/udfproj/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions examples/function/udfproj/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions examples/function/udfproj/entry.sh

This file was deleted.

30 changes: 0 additions & 30 deletions examples/function/udfproj/example.py

This file was deleted.

34 changes: 0 additions & 34 deletions examples/function/udfproj/pipeline-numaflow.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions examples/function/udfproj/pyproject.toml

This file was deleted.

Loading