Bug 146175

Summary: Get rid of factory json files in benchmark_runner
Product: WebKit Reporter: dewei_zhu
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dewei_zhu, glenn, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description dewei_zhu 2015-06-19 17:45:45 PDT
Fix the bug introduced by patch 146125 and polish the code.
Comment 1 dewei_zhu 2015-06-19 17:49:38 PDT
Created attachment 255257 [details]
Patch
Comment 2 dewei_zhu 2015-06-20 00:33:37 PDT
Created attachment 255284 [details]
Patch
Comment 3 WebKit Commit Bot 2015-06-20 00:36:11 PDT
Attachment 255284 [details] did not pass style-queue:


ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:39:  [OSXBrowserDriver.terminateProcesses] No name 'NSRunningApplication' in module 'AppKit'  [pylint/E0611] [5]
ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:52:  [OSXBrowserDriver.screenSize] No name 'NSScreen' in module 'AppKit'  [pylint/E0611] [5]
Total errors found: 2 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 dewei_zhu 2015-06-20 00:41:05 PDT
Created attachment 255286 [details]
Patch
Comment 5 WebKit Commit Bot 2015-06-20 00:44:06 PDT
Attachment 255286 [details] did not pass style-queue:


ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:39:  [OSXBrowserDriver.terminateProcesses] No name 'NSRunningApplication' in module 'AppKit'  [pylint/E0611] [5]
ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:52:  [OSXBrowserDriver.screenSize] No name 'NSScreen' in module 'AppKit'  [pylint/E0611] [5]
Total errors found: 2 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Ryosuke Niwa 2015-06-20 00:55:07 PDT
Comment on attachment 255286 [details]
Patch

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

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/__init__.py:15
> +import imp

We don't need imp here.

> Tools/Scripts/webkitpy/benchmark_runner/browser_driver/__init__.py:15
> +import imp

Ditto.

> Tools/Scripts/webkitpy/benchmark_runner/browser_driver/__init__.py:23
> +        BrowserDriverFactory.add_product([browser_driver_class.platform, browser_driver_class.browser_name], browser_driver_class)

This code is unreadable. We should just not use GenericFactory.add_product here.
Just add add_browser_driver(platform, browser_name, browser_driver_class) or something to BrowserDriverFactory.

> Tools/Scripts/webkitpy/benchmark_runner/generic_factory.py:38
> +    @classmethod
> +    def add_product(cls, descriptions, product):
> +        item = cls.products
> +        for description in descriptions[:-1]:
> +            if description not in item:
> +                item[description] = {}
> +            item = item[description]
> +        item[descriptions[-1]] = product

This method is super generic and impossible to reason about.
I'd much prefer duplicating the code in each driver factory instead.

> Tools/Scripts/webkitpy/benchmark_runner/utils.py:21
> +    if inspect.isclass(child):
> +        if parent_name in [cls.__name__ for cls in inspect.getmro(child)]:
> +            return True
> +    return False

This should be re-rewritten as:
return inspect.isclass(child) and parent_name in [cls.__name__ for cls in inspect.getmro(child)]

> Tools/Scripts/webkitpy/benchmark_runner/utils.py:26
> +        if filename.endswith('.py') and filename not in ['__init__.py']:

Instead of nesting if-s, use "continue" and detect the rest per WebKit coding style.
Alternatively, use list comprehension.
Comment 7 dewei_zhu 2015-06-22 10:35:52 PDT
Comment on attachment 255286 [details]
Patch

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

> Tools/Scripts/webkitpy/benchmark_runner/benchmark_builder/__init__.py:23
> +        BenchmarkBuilderFactory.add_product([benchmark_builder_class.builder_name], benchmark_builder_class)

Should I add a add_benchmark_builder method instead?

> Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/__init__.py:23
> +        HTTPServerDriverFactory.add_product([http_server_driver_class.name], http_server_driver_class)

Should I change here as well?

>> Tools/Scripts/webkitpy/benchmark_runner/utils.py:21
>> +    return False
> 
> This should be re-rewritten as:
> return inspect.isclass(child) and parent_name in [cls.__name__ for cls in inspect.getmro(child)]

Nice!
Comment 8 dewei_zhu 2015-06-22 13:51:26 PDT
Created attachment 255366 [details]
Patch
Comment 9 WebKit Commit Bot 2015-06-22 13:54:56 PDT
Attachment 255366 [details] did not pass style-queue:


ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:39:  [OSXBrowserDriver.terminateProcesses] No name 'NSRunningApplication' in module 'AppKit'  [pylint/E0611] [5]
ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:52:  [OSXBrowserDriver.screenSize] No name 'NSScreen' in module 'AppKit'  [pylint/E0611] [5]
Total errors found: 2 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Ryosuke Niwa 2015-06-22 17:39:47 PDT
Comment on attachment 255366 [details]
Patch

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

> Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver_factory.py:32
> +    def get(cls, platform, browser_name):

I don't think we should rename this to `get`.
`create` is more semantically correct name.
Comment 11 dewei_zhu 2015-06-22 18:03:53 PDT
Created attachment 255381 [details]
Patch
Comment 12 WebKit Commit Bot 2015-06-22 18:05:57 PDT
Attachment 255381 [details] did not pass style-queue:


ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:39:  [OSXBrowserDriver.terminateProcesses] No name 'NSRunningApplication' in module 'AppKit'  [pylint/E0611] [5]
ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:52:  [OSXBrowserDriver.screenSize] No name 'NSScreen' in module 'AppKit'  [pylint/E0611] [5]
Total errors found: 2 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 dewei_zhu 2015-06-22 18:08:14 PDT
Created attachment 255383 [details]
Patch
Comment 14 WebKit Commit Bot 2015-06-22 18:09:54 PDT
Attachment 255383 [details] did not pass style-queue:


ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:39:  [OSXBrowserDriver.terminateProcesses] No name 'NSRunningApplication' in module 'AppKit'  [pylint/E0611] [5]
ERROR: Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:52:  [OSXBrowserDriver.screenSize] No name 'NSScreen' in module 'AppKit'  [pylint/E0611] [5]
Total errors found: 2 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 WebKit Commit Bot 2015-06-22 20:48:12 PDT
Comment on attachment 255383 [details]
Patch

Clearing flags on attachment: 255383

Committed r185859: <http://trac.webkit.org/changeset/185859>
Comment 16 WebKit Commit Bot 2015-06-22 20:48:16 PDT
All reviewed patches have been landed.  Closing bug.