Uh oh!
There was an error while loading. Please reload this page.
[BEAM-7984] The coder returned for typehints.List should be IterableCoder - #9344
Conversation
chadrik
commented
Aug 15, 2019
R: @robertwb |
robertwb
left a comment
There was a problem hiding this comment.
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 classSequenceCoderImpl(StreamCoderImpl):
def__init__(self, elem_coder,
read_state=None, write_state=None, write_state_threshold=0):
self._elem_coder=elem_coderself._read_state=read_stateself._write_state=write_stateself._write_state_threshold=write_state_threshold
...
defdecode_from_stream(self, in_stream, nested):
size=in_stream.read_bigendian_int32()
ifsize>=0:
elements= [self._elem_coder.decode_from_stream(in_stream, True)
for_inrange(size)]
else:
elements= []
count=in_stream.read_var_int64()
whilecount>0:
for_inrange(count):
elements.append(self._elem_coder.decode_from_stream(in_stream, True))
count=in_stream.read_var_int64()
ifcount==-1:
ifself._read_stateisNone:
raiseValueError(
'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))
returnself._construct_from_sequence(elements)
Some options:
So as it is, |
robertwb
commented
Aug 28, 2019
Yeah, leaving as is, with some comments, seems the best path forward. |
5568da6 to
f88989bComparechadrik
commented
Aug 29, 2019
Addressed |
robertwb
commented
Aug 30, 2019
Run Python PreCommit |
robertwb
left a comment
There was a problem hiding this comment.
LGTM pending tests passing.
chadrik
commented
Aug 30, 2019
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. |
mxm
commented
Aug 30, 2019
Run Python PreCommit |
mxm
commented
Aug 30, 2019
These failures could be related to the PR changes: https://builds.apache.org/job/beam_PreCommit_Python_Phrase/761/ |
robertwb
commented
Sep 3, 2019
Run Python PreCommit |
robertwb
commented
Sep 3, 2019
I can't reproduce these test failures locally. |
mxm
commented
Sep 4, 2019
Tests are also failing locally for me with the same error: |
chadrik
commented
Sep 4, 2019
via email
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>
.
|
mxm
commented
Sep 4, 2019
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 |
chadrik
commented
Sep 4, 2019
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. |
chadrik
commented
Sep 4, 2019
Update: I get the error using python 3.7, and I confirmed that I do not get it on master: |
mxm
commented
Sep 4, 2019
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: defrotate_key(element):
"""Returns a new key-value pair of the same size but with a different key."""
(key, value) =elementreturnkey[-1:] +key[:-1], valuepython3: In [1]: fromapache_beam.typehints.trivial_inferenceimportinfer_return_typeIn [2]: fromapache_beam.testing.synthetic_pipelineimportrotate_keyIn [3]: fromapache_beam.typehintsimportAnyIn [4]: infer_return_type(rotate_key, [Any]) Out[4]: Tuple[List[Any], Any]python2: In [1]: fromapache_beam.typehints.trivial_inferenceimportinfer_return_typeIn [2]: fromapache_beam.testing.synthetic_pipelineimportrotate_keyIn [3]: fromapache_beam.typehintsimportAnyIn [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 |
robertwb
commented
Sep 5, 2019
Thanks for tracking this down. #9486 |
robertwb
commented
Sep 5, 2019
Run Python PreCommit |
chadrik
commented
Sep 5, 2019
wow, Python PreCommit takes forever |
chadrik
commented
Sep 6, 2019
yay, it works! |
robertwb
commented
Sep 6, 2019
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.