-
Notifications
You must be signed in to change notification settings - Fork 68
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
New version of Python API based on decorators #1833
Conversation
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.
I think this is a good improvement over the current API.
|
||
`payload_length` is used to decode our message header to determine how long the payload is going to be. In this case, we are relying on the Python `struct` package to decode the bytes. If you aren't familiar with `struct`, you can check out [the documentation](https://docs.python.org/2/library/struct.html) to learn more. Remember, when using `struct`, don't forget to import it! | ||
`fmt` is used internally to decode our message header to determine how long the payload is going to be. We rely on the Python `struct` package to decode the bytes. If you aren't familiar with `struct`, you can check out [the documentation](https://docs.python.org/2/library/struct.html) to learn more. Remember, when using `struct`, don't forget to import it! |
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.
Should be length_fmt
, not fmt
.
machida/wallaroo.py
Outdated
class TCPSourceConfig(object): | ||
def __init__(self, host, port, decoder): |
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.
Somehow decoder
s and encoder
s got switch around here and in TCPSinkConfig
.
machida/wallaroo.py
Outdated
class TCPSourceConfig(object): | ||
def __init__(self, host, port, decoder): | ||
def __init__(self, host, port, encoder): |
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.
encoder
-> decoder
machida/wallaroo.py
Outdated
self._host = host | ||
self._port = port | ||
self._decoder = decoder | ||
self._encoder = encoder |
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.
encoder
-> decoder
machida/wallaroo.py
Outdated
|
||
def to_tuple(self): | ||
return ("tcp", self._host, self._port, self._decoder) | ||
return ("tcp", self._host, self._port, self._encoder) |
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.
encoder
-> decoder
machida/wallaroo.py
Outdated
|
||
|
||
class TCPSinkConfig(object): | ||
def __init__(self, host, port, encoder): | ||
def __init__(self, host, port, decoder): |
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.
decoder
-> encoder
machida/wallaroo.py
Outdated
self._host = host | ||
self._port = port | ||
self._encoder = encoder | ||
self._decoder = decoder |
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.
decoder
-> encoder
machida/wallaroo.py
Outdated
|
||
def to_tuple(self): | ||
return ("tcp", self._host, self._port, self._encoder) | ||
return ("tcp", self._host, self._port, self._decoder) |
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.
decoder
-> encoder
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.
There's a few things that need to be fixed.
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.
Looks ok now.
8c3b5c3
to
983f74f
Compare
return ab.build() | ||
|
||
@wallaroo.computation_multi(name="split into words") |
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.
You need another newline before this for PEP8 compatibility
machida/wallaroo.py
Outdated
@@ -79,13 +79,16 @@ def build(self): | |||
|
|||
|
|||
def computation(name): | |||
print 'computation', name |
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.
This doesn't need to be here does it?
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.
Ah good catch! Thanks!
f750365
to
0d4d7f7
Compare
@SeanTAllen @nitbix @aturley |
The Python API was using a ''class-based'' approach that was very similar to the C++ API. This wasn't very pythonic, so this change adds decorators in place of a lot of the boiler-plate classes and builders we were using. This results in shorter application code, and less responsibility on the developer to respect Wallaroo interfaces.
This is a breaking API change, so I've made this speculative PR while I prepare all the changes to examples and documentation so that we can start discussing potential other changes to the API.