-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-7984] The coder returned for typehints.List should be IterableCoder #9344
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
Conversation
|
R: @robertwb |
robertwb
left a comment
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.
If the user specifies the type as List, should we ensure that we always return a List? (I.e should we explicitly state our assumption here that IterableCoder returns a list and also adda note in the implementation of IterableCoderImpl that if this changes we need to create a separate ListCoder? Or should we go ahead and create a separate ListCoder now?
I dug into this a bit more and realized that I was mistaken about my assertion that class SequenceCoderImpl(StreamCoderImpl):
def __init__(self, elem_coder,
read_state=None, write_state=None, write_state_threshold=0):
self._elem_coder = elem_coder
self._read_state = read_state
self._write_state = write_state
self._write_state_threshold = write_state_threshold
...
def decode_from_stream(self, in_stream, nested):
size = in_stream.read_bigendian_int32()
if size >= 0:
elements = [self._elem_coder.decode_from_stream(in_stream, True)
for _ in range(size)]
else:
elements = []
count = in_stream.read_var_int64()
while count > 0:
for _ in range(count):
elements.append(self._elem_coder.decode_from_stream(in_stream, True))
count = in_stream.read_var_int64()
if count == -1:
if self._read_state is None:
raise ValueError(
'Cannot read state-written iterable without state reader.')
state_token = in_stream.read_all(True)
elements = _ConcatSequence(
elements, self._read_state(state_token, self._elem_coder))
return self._construct_from_sequence(elements)
Some options:
So as it is, |
|
Yeah, leaving as is, with some comments, seems the best path forward. |
5568da6 to
f88989b
Compare
|
Addressed |
|
Run Python PreCommit |
robertwb
left a comment
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.
LGTM pending tests passing.
|
I find the python precommit test rather inscrutable. It seems that it always fails on :sdks:python:setupVirtualenv and I don't understand whether I should care or not. |
|
Run Python PreCommit |
|
These failures could be related to the PR changes: https://builds.apache.org/job/beam_PreCommit_Python_Phrase/761/ |
|
Run Python PreCommit |
|
I can't reproduce these test failures locally. |
|
Tests are also failing locally for me with the same error: |
|
There are a handful of levels from which the python tests can be invoked
(gradle, tox, setup.py, nose): can you provide the exact command you're
running?
…On Wed, Sep 4, 2019 at 9:36 AM Maximilian Michels ***@***.***> wrote:
Tests are also failing locally for me with the same error:
TypeError: can only concatenate list (not "bytes") to list [while running 'FormatOutput']```
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9344?email_source=notifications&email_token=AAAPOE6CF4RUU7HEMAGQJTDQH7PZ7A5CNFSM4IL2TD2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD54GEJQ#issuecomment-527983142>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAPOE5RXOZFVWDYBVHRSMDQH7PZ7ANCNFSM4IL2TD2A>
.
|
|
Haven't fully figured out how to run a specific test through Gradle. What I do is to run this from the test directory ( You need to activate the virtual environment that Gradle uses first. It's in |
|
I gave up trying to figure out how to run specific tests from gradle as well, so I just created a PR #9474 to enable running individual tests using tox. This should theoretically be the same environment as gradle, since gradle calls tox. I'm cherry-picking the commit from my PR and running the tests like this: Running this on my Macbook Pro succeeds, so I'm not sure where to go from here. |
|
Update: I get the error using python 3.7, and I confirmed that I do not get it on master: |
|
That makes sense. I was testing with 3.7 as well. |
|
What's happened here is that this change has exposed a difference in the inference code between python2 and python3. Here's the function that's being analyzed differently: def rotate_key(element):
"""Returns a new key-value pair of the same size but with a different key."""
(key, value) = element
return key[-1:] + key[:-1], valuepython3: In [1]: from apache_beam.typehints.trivial_inference import infer_return_type
In [2]: from apache_beam.testing.synthetic_pipeline import rotate_key
In [3]: from apache_beam.typehints import Any
In [4]: infer_return_type(rotate_key, [Any])
Out[4]: Tuple[List[Any], Any]python2: In [1]: from apache_beam.typehints.trivial_inference import infer_return_type
In [2]: from apache_beam.testing.synthetic_pipeline import rotate_key
In [3]: from apache_beam.typehints import Any
In [4]: infer_return_type(rotate_key, [Any])
Out[4]: AnyThe actual return type of Personally, it seems like an overreach to infer that Edit: clarity |
|
Thanks for tracking this down. #9486 |
|
Run Python PreCommit |
|
wow, Python PreCommit takes forever |
|
yay, it works! |
|
Long queue... |
Please add a meaningful description for your change here
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username).[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.Post-Commit Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.