[
https://issues.apache.org/jira/browse/BEAM-5745?focusedWorklogId=155550&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-155550
]
ASF GitHub Bot logged work on BEAM-5745:
----------------------------------------
Author: ASF GitHub Bot
Created on: 17/Oct/18 18:38
Start Date: 17/Oct/18 18:38
Worklog Time Spent: 10m
Work Description: HuangLED edited a comment on issue #6687: [BEAM-5745]
Fix annotation test for py3
URL: https://github.com/apache/beam/pull/6687#issuecomment-430734886
> It seems odd to set this globally once a function is called (and not in a
context).
An alternative way, for the sake of fixing this failing test, is to
explicitly call warnings.simplefilter() in each test case. This Option#2 of fix
works as well. The downside though, is that the discrepency between py2 and
py3 would still exist.
My hypothesis on the root cause, is that python2 and python3 treat unscoped
global function call differently. (funny thing is, this warning.simplefilter is
called in py3, there is something else under the hood for which I don't know
how) Didn't find a definitive documentation on this though, please fill in if
you are aware of good discussions on this. (+python experts @pabloem
@tvalentyn )
Weighing these two options, I slightly prefer option#1 in this PR because
with this fix, this module by itself behave exactly the same behavior
regardless in an py2 or py3 environment. And I don't think there is performance
concern. The downside here is the code does not look elegant enough.
to wrap it up:
Option#1: Pro: this annotations.py module behaves the same in py2 and py3 ;
Cons: Code does not look elegant.
Option#2: Pro: only need to change test file. Cons: We will need to
handle the py2/py3 discrepency in all related test cases, and will need to do
that in the future non-testing module if anything depend on this
annotations.py.
Other alternative, feel free to recommend. I'd be happy to try out.
Or, if our consensus is to go with Option#2, I shall update this PR
accordingly.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 155550)
Time Spent: 1h (was: 50m)
> Util test on annotations fails
> -------------------------------
>
> Key: BEAM-5745
> URL: https://issues.apache.org/jira/browse/BEAM-5745
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Ruoyun Huang
> Assignee: Ruoyun Huang
> Priority: Minor
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Traceback (most recent call last):
> File
> "/usr/local/google/home/ruoyun/projects/beam/sdks/python/apache_beam/utils/annotations_test.py",
> line 142, in test_frequency
> label_check_list=[])
> File
> "/usr/local/google/home/ruoyun/projects/beam/sdks/python/apache_beam/utils/annotations_test.py",
> line 149, in check_annotation
> self.assertIn(fnc_name + ' is ' + annotation_type,
> str(warning[-1].message))
> AssertionError: 'fnc2_test_annotate_frequency is experimental' not found in
> 'fnc_test_annotate_frequency is experimental.'
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)