Bug 211249

Summary: Python3: Support Python3 in Tools/webkitpy/benchmark_runner
Product: WebKit Reporter: Pablo Saavedra <psaavedra>
Component: Tools / TestsAssignee: Pablo Saavedra <psaavedra>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, cgarcia, dean_johnson, ews-watchlist, glenn, jbedard, rniwa, slewis, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=211514
Attachments:
Description Flags
patch
none
patch
none
patch none

Description Pablo Saavedra 2020-04-30 13:08:06 PDT
Provide support for Python3 in Tools/webkitpy/benchmark_runner
Comment 1 Pablo Saavedra 2020-04-30 14:21:51 PDT
Created attachment 398089 [details]
patch
Comment 2 Jonathan Bedard 2020-04-30 15:09:13 PDT
Comment on attachment 398089 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=398089&action=review

Just a heads up: webkitpy EWS will run both Python 2 and Python 3 tests, so as long as the Python code you are changing is tested, you can trust EWS.

> Tools/Scripts/run-benchmark:-1
> -#!/usr/bin/env python

We aren't ready to take the dive of only supporting Python 3 yet, let's keep these she-bangs 'python'.

We still have machines without Python 3, so we're holding off transitioning existing scripts.

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:1
> +#!/usr/bin/env python3

Ditto.

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:6
> +import urllib.request

Let's make sure we have Python 2 compatible imports as well...if you grep for urllib imports in webkitpy, you'll see us using two different import calls, one for Python 2 and one for Python 3.

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_results_unittest.py:1
> +#!/usr/bin/env python3

Ditto.
Comment 3 Pablo Saavedra 2020-05-01 10:40:37 PDT
Created attachment 398201 [details]
patch
Comment 4 Pablo Saavedra 2020-05-01 10:41:55 PDT
(In reply to Jonathan Bedard from comment #2)
> Comment on attachment 398089 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=398089&action=review
> 
> Just a heads up: webkitpy EWS will run both Python 2 and Python 3 tests, so
> as long as the Python code you are changing is tested, you can trust EWS.
> 
> > Tools/Scripts/run-benchmark:-1
> > -#!/usr/bin/env python
> 
> We aren't ready to take the dive of only supporting Python 3 yet, let's keep
> these she-bangs 'python'.
> 
> We still have machines without Python 3, so we're holding off transitioning
> existing scripts.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:1
> > +#!/usr/bin/env python3
> 
> Ditto.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:6
> > +import urllib.request
> 
> Let's make sure we have Python 2 compatible imports as well...if you grep
> for urllib imports in webkitpy, you'll see us using two different import
> calls, one for Python 2 and one for Python 3.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_results_unittest.py:1
> > +#!/usr/bin/env python3
> 
> Ditto.

Thanks for your kindly review. I just uploaded a new version compatible with both python versions.
Comment 5 Pablo Saavedra 2020-05-05 04:01:29 PDT
(In reply to Jonathan Bedard from comment #2)
> Comment on attachment 398089 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=398089&action=review
> 
> Just a heads up: webkitpy EWS will run both Python 2 and Python 3 tests, so
> as long as the Python code you are changing is tested, you can trust EWS.
> 
> > Tools/Scripts/run-benchmark:-1
> > -#!/usr/bin/env python
> 
> We aren't ready to take the dive of only supporting Python 3 yet, let's keep
> these she-bangs 'python'.
> 
> We still have machines without Python 3, so we're holding off transitioning
> existing scripts.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:1
> > +#!/usr/bin/env python3
> 
> Ditto.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:6
> > +import urllib.request
> 
> Let's make sure we have Python 2 compatible imports as well...if you grep
> for urllib imports in webkitpy, you'll see us using two different import
> calls, one for Python 2 and one for Python 3.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_results_unittest.py:1
> > +#!/usr/bin/env python3
> 
> Ditto.

Could you take a look again?
Comment 6 Jonathan Bedard 2020-05-05 06:56:51 PDT
Comment on attachment 398201 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=398201&action=review

Before landing, I need to do some brief testing on Apple's side since there is some mission-critical Apple Internal infrastructure that uses this code.

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py:-145
> -        if arg_type == types.ListType and len(a) and (type(a[0]) == types.StringType or type(a[0]) == types.UnicodeType):

Seems like we were treating unicode as a string type in Python 2 also

> Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py:79
> +        print(("\t%s" % plan))

Is this change actually needed? It would surprise me if it is.

> Tools/Scripts/webkitpy/style/checker.py:723
> +            python3_paths = ['Tools/resultsdbpy', 'Tools/Scripts/webkitpy/benchmark_runner']

We shouldn't add it here, since this file is also a Python 2 path. resultsdbpy is somewhat unique in that it is exclusively Python 3 (since it doesn't need to be run locally) and so we need to run it through a different style checker since it contains syntax illegal in Python 2.
Comment 7 Pablo Saavedra 2020-05-05 07:55:54 PDT
(In reply to Jonathan Bedard from comment #6)
> Comment on attachment 398201 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=398201&action=review
> 
> Before landing, I need to do some brief testing on Apple's side since there
> is some mission-critical Apple Internal infrastructure that uses this code.
> 
> > Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py:-145
> > -        if arg_type == types.ListType and len(a) and (type(a[0]) == types.StringType or type(a[0]) == types.UnicodeType):
> 
> Seems like we were treating unicode as a string type in Python 2 also
> 
> > Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py:79
> > +        print(("\t%s" % plan))
> 
> Is this change actually needed? It would surprise me if it is.

not at all. Sorry don't check it before.

> 
> > Tools/Scripts/webkitpy/style/checker.py:723
> > +            python3_paths = ['Tools/resultsdbpy', 'Tools/Scripts/webkitpy/benchmark_runner']
> 
> We shouldn't add it here, since this file is also a Python 2 path.
> resultsdbpy is somewhat unique in that it is exclusively Python 3 (since it
> doesn't need to be run locally) and so we need to run it through a different
> style checker since it contains syntax illegal in Python 2.
ok.
Comment 8 Pablo Saavedra 2020-05-05 07:58:29 PDT
Created attachment 398506 [details]
patch
Comment 9 Pablo Saavedra 2020-05-05 08:00:45 PDT
(In reply to Jonathan Bedard from comment #6)
> Comment on attachment 398201 [details]
...
> 
> > Tools/Scripts/webkitpy/style/checker.py:723
> > +            python3_paths = ['Tools/resultsdbpy', 'Tools/Scripts/webkitpy/benchmark_runner']
> 
> We shouldn't add it here, since this file is also a Python 2 path.
> resultsdbpy is somewhat unique in that it is exclusively Python 3 (since it
> doesn't need to be run locally) and so we need to run it through a different
> style checker since it contains syntax illegal in Python 2.

Not adding this in the python3_paths, I got this error in the style checker:

  ERROR: Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:15:  No name 'request' in module 'urllib'  [pylint/E0611] [5]


Who I should I proceed to ignore this error?
Comment 10 Jonathan Bedard 2020-05-05 08:09:38 PDT
(In reply to Pablo Saavedra from comment #9)
> (In reply to Jonathan Bedard from comment #6)
> > Comment on attachment 398201 [details]
> ...
> > 
> > > Tools/Scripts/webkitpy/style/checker.py:723
> > > +            python3_paths = ['Tools/resultsdbpy', 'Tools/Scripts/webkitpy/benchmark_runner']
> > 
> > We shouldn't add it here, since this file is also a Python 2 path.
> > resultsdbpy is somewhat unique in that it is exclusively Python 3 (since it
> > doesn't need to be run locally) and so we need to run it through a different
> > style checker since it contains syntax illegal in Python 2.
> 
> Not adding this in the python3_paths, I got this error in the style checker:
> 
>   ERROR: Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder.py:15: 
> No name 'request' in module 'urllib'  [pylint/E0611] [5]
> 
> 
> Who I should I proceed to ignore this error?

Just ignore it, I think we have a pretty good case for getting rid of the E0611 because of this. This sort of style error was pretty common when converting webkitpy to Python 3.
Comment 11 Jonathan Bedard 2020-05-05 11:41:34 PDT
Doesn't break anything for python 2, but I tried running jetstream2 with Python 3 and starting the web server didn't work. That's not necessarily a deal-breaker, since I know we have some other issues with web servers and Python 3, but I want to make sure the current patch is compatible with whatever run-benchmark incantation you are using.
Comment 12 Pablo Saavedra 2020-05-05 13:05:10 PDT
(In reply to Jonathan Bedard from comment #11)
> Doesn't break anything for python 2, but I tried running jetstream2 with
> Python 3 and starting the web server didn't work. That's not necessarily a
> deal-breaker, since I know we have some other issues with web servers and
> Python 3, but I want to make sure the current patch is compatible with
> whatever run-benchmark incantation you are using.

It's working in my local Linux environment (for Firefox, Epiphany and Chrome at least). Did you see something relevant in the logs output related the HTTP Server?
Comment 13 Jonathan Bedard 2020-05-06 07:40:34 PDT
It's psutil, we might need to add that to our auto-installers, (probably working for you locally because you have it installed for some other reason).

That should be a different change, though, r+ing.
Comment 14 Pablo Saavedra 2020-05-06 08:15:51 PDT
(In reply to Jonathan Bedard from comment #13)
> It's psutil, we might need to add that to our auto-installers, (probably
> working for you locally because you have it installed for some other reason).
> 
> That should be a different change, though, r+ing.

Ok, great. Created https://bugs.webkit.org/show_bug.cgi?id=211514 to address this.
Comment 15 EWS 2020-05-06 08:39:53 PDT
Committed r261231: <https://trac.webkit.org/changeset/261231>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 398506 [details].
Comment 16 Radar WebKit Bug Importer 2020-05-06 08:40:14 PDT
<rdar://problem/62931875>