Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
ignore = |
E203, F821
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,generated
max-complexity = 10
max-line-length = 100
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence
* @ab93 @vigith @whynowy
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
labels: "bug"
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. ....
2. ....
3. ....

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**

- Kubernetes: [e.g. v1.18.6]
- Numaflow: [e.g. v0.5.1]
- Numalogic: [e.g. v0.2.0]
- Numaflow-python: [e.g. v0.1.1]

**Additional context**
Add any other context about the problem here.

---

<!-- Issue Author: Don't delete this message to encourage other users to support your issue! -->

**Message from the maintainers**:

Impacted by this bug? Give it a 👍. We often sort issues this way to know what to prioritize.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Feature request
about: Propose an enhancement for this project
labels: 'enhancement'
---
# Summary

What change needs making?

# Use Cases

When would you use this?

---
<!-- Issue Author: Don't delete this message to encourage other users to support your issue! -->
**Message from the maintainers**:

If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Kindly explain what this PR does.
58 changes: 58 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Lint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
black:
name: Black format
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Install dependencies
run: |
poetry env use ${{ matrix.python-version }}
poetry install --no-root

- name: Black format check
run: poetry run black --check .

flake8:
name: flake8 check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.9" ]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: flake8 Lint
uses: py-actions/flake8@v2
with:
config: "./.flake8"
path: "pynumaflow"
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
format:
clean:
@rm -rf build dist .eggs *.egg-info
@rm -rf .benchmarks .coverage coverage.xml htmlcov report.xml .tox
@find . -type d -name '.mypy_cache' -exec rm -rf {} +
@find . -type d -name '__pycache__' -exec rm -rf {} +
@find . -type d -name '*pytest_cache*' -exec rm -rf {} +
@find . -type f -name "*.py[co]" -exec rm -rf {} +

format: clean
poetry run black pynumaflow/


lint: format
poetry run flake8 .


test:
poetry run pytest pynumaflow/tests/


requirements:
poetry export -f requirements.txt --output requirements.txt --without-hashes

# TODO: proto file generate
237 changes: 163 additions & 74 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion pynumaflow/function/_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def __init__(self, value: bytes, event_time: datetime, watermark: datetime):

def __str__(self):
value_string = self._value.decode("utf-8")
return f"value: {value_string}, event_time: {str(self._event_time)}, watermark: {str(self._watermark)}"
return (
f"value: {value_string}, "
f"event_time: {str(self._event_time)}, "
f"watermark: {str(self._watermark)}"
)

def __repr__(self):
return str(self)
Expand Down
6 changes: 5 additions & 1 deletion pynumaflow/sink/_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def __init__(self, sink_msg_id: str, value: bytes, event_time: datetime, waterma

def __str__(self):
value_string = self._value.decode("utf-8")
return f"id: {self._id}, value: {value_string}, event_time: {str(self._event_time)}, watermark: {str(self._watermark)}"
return (
f"id: {self._id}, value: {value_string}, "
f"event_time: {str(self._event_time)}, "
f"watermark: {str(self._watermark)}"
)

def __repr__(self):
return str(self)
Expand Down
13 changes: 9 additions & 4 deletions pynumaflow/tests/function/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_err_event_time(self):
with self.assertRaises(Exception) as context:
Datum(value=mock_message(), event_time=ts, watermark=ts)
self.assertEqual(
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> for Datum.event_time",
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> "
"for Datum.event_time",
str(context.exception),
)

Expand All @@ -52,7 +53,8 @@ def test_err_watermark(self):
with self.assertRaises(Exception) as context:
Datum(value=mock_message(), event_time=mock_event_time(), watermark=ts)
self.assertEqual(
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> for Datum.watermark",
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> "
"for Datum.watermark",
str(context.exception),
)

Expand All @@ -61,11 +63,14 @@ def test_value(self):
self.assertEqual(mock_message(), d.value)
self.assertEqual(
"value: test_mock_message, "
"event_time: 2022-09-12 16:00:00+00:00, watermark: 2022-09-12 16:01:00+00:00",
"event_time: 2022-09-12 16:00:00+00:00, "
"watermark: 2022-09-12 16:01:00+00:00",
str(d),
)
self.assertEqual(
"value: test_mock_message, event_time: 2022-09-12 16:00:00+00:00, watermark: 2022-09-12 16:01:00+00:00",
"value: test_mock_message, "
"event_time: 2022-09-12 16:00:00+00:00, "
"watermark: 2022-09-12 16:01:00+00:00",
repr(d),
)

Expand Down
13 changes: 6 additions & 7 deletions pynumaflow/tests/function/test_server.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import tempfile
import unittest
from datetime import datetime, timezone

from google.protobuf import empty_pb2 as _empty_pb2
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from grpc import StatusCode
from grpc_testing import server_from_dictionary, strict_real_time
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf import empty_pb2 as _empty_pb2


from pynumaflow._constants import DATUM_KEY
from pynumaflow.function.generated import udfunction_pb2
from pynumaflow.function.server import UserDefinedFunctionServicer
from pynumaflow.function._dtypes import (
Message,
Messages,
Datum,
)
from pynumaflow.function.generated import udfunction_pb2
from pynumaflow.function.server import UserDefinedFunctionServicer


def map_handler(key: str, datum: Datum) -> Messages:
Expand Down Expand Up @@ -102,7 +100,8 @@ def test_forward_message(self):
self.assertEqual("test", response.elements[0].key)
self.assertEqual(
bytes(
"payload:test_mock_message event_time:2022-09-12 16:00:00 watermark:2022-09-12 16:01:00",
"payload:test_mock_message "
"event_time:2022-09-12 16:00:00 watermark:2022-09-12 16:01:00",
encoding="utf-8",
),
response.elements[0].value,
Expand Down
10 changes: 7 additions & 3 deletions pynumaflow/tests/sink/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def test_err_event_time(self):
with self.assertRaises(Exception) as context:
Datum(sink_msg_id="test_id_0", value=mock_message(), event_time=ts, watermark=ts)
self.assertEqual(
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> for Datum.event_time",
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> "
"for Datum.event_time",
str(context.exception),
)

Expand All @@ -45,7 +46,8 @@ def test_err_watermark(self):
watermark=ts,
)
self.assertEqual(
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> for Datum.watermark",
"Wrong data type: <class 'google.protobuf.timestamp_pb2.Timestamp'> "
"for Datum.watermark",
str(context.exception),
)

Expand All @@ -63,7 +65,9 @@ def test_value(self):
str(d),
)
self.assertEqual(
"id: test_id_0, value: test_mock_message, event_time: 2022-09-12 16:00:00+00:00, watermark: 2022-09-12 16:01:00+00:00",
"id: test_id_0, value: test_mock_message, "
"event_time: 2022-09-12 16:00:00+00:00, "
"watermark: 2022-09-12 16:01:00+00:00",
repr(d),
)

Expand Down
7 changes: 2 additions & 5 deletions pynumaflow/tests/sink/test_server.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import tempfile
import unittest
from datetime import datetime, timezone
from typing import List

from google.protobuf import empty_pb2 as _empty_pb2
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from grpc import StatusCode
from grpc_testing import server_from_dictionary, strict_real_time
from google.protobuf import timestamp_pb2 as _timestamp_pb2
from google.protobuf import empty_pb2 as _empty_pb2


from pynumaflow._constants import DATUM_KEY
from pynumaflow.sink import Responses, Datum, Response, UserDefinedSinkServicer
from pynumaflow.sink.generated import udsink_pb2

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pynumaflow"
version = "0.2.2"
version = "0.2.3"
description = "Provides the interfaces of writing Python User Defined Functions and Sinks for NumaFlow."
authors = ["NumaFlow Developers"]
readme = "README.md"
Expand Down Expand Up @@ -31,6 +31,7 @@ pytest-aiohttp = "^1.0"
pytest-cov = "^3.0"
black = "^22.1"
grpcio-testing = "^1.48.1"
flake8 = "^4.0.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down