[ 
https://issues.apache.org/jira/browse/BEAM-5745?focusedWorklogId=155542&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-155542
 ]

ASF GitHub Bot logged work on BEAM-5745:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Oct/18 18:20
            Start Date: 17/Oct/18 18:20
    Worklog Time Spent: 10m 
      Work Description: HuangLED commented 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 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. 
   
   Please make recommendations if you know an Option#3.  Thanks.

----------------------------------------------------------------
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 155542)
    Time Spent: 50m  (was: 40m)

> 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: 50m
>  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)

Reply via email to