Bug 225230

Summary: [webkitpy] Support pickling platforminfo
Product: WebKit Reporter: Jonathan Bedard <jbedard>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, commit-queue, dewei_zhu, ews-watchlist, glenn, gsnedders, 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=225221
Bug Depends on: 225242    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Description Jonathan Bedard 2021-04-30 08:56:43 PDT
We need to be able to pickle the platforminfo object.
Comment 1 Radar WebKit Bug Importer 2021-04-30 08:58:24 PDT
<rdar://problem/77384913>
Comment 2 Jonathan Bedard 2021-04-30 09:03:47 PDT
Created attachment 427427 [details]
Patch
Comment 3 Stephanie Lewis 2021-04-30 09:13:21 PDT
Comment on attachment 427427 [details]
Patch

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

> Tools/Scripts/webkitpy/common/system/platforminfo.py:66
>          self._platform_module = platform_module

Why not self.platform_module or platform?
Comment 4 Jonathan Bedard 2021-04-30 09:15:47 PDT
Comment on attachment 427427 [details]
Patch

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

>> Tools/Scripts/webkitpy/common/system/platforminfo.py:66
>>          self._platform_module = platform_module
> 
> Why not self.platform_module or platform?

Because you can't pickle a module. Doing `self.platform_module or platform` would mean we could not pickle the PlatformInfo object
Comment 5 Jonathan Bedard 2021-04-30 09:33:37 PDT
Waiting on EWS before landing.
Comment 6 Sam Sneddon [:gsnedders] 2021-04-30 09:33:42 PDT
Comment on attachment 427427 [details]
Patch

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

> Tools/Scripts/webkitpy/common/system/platforminfo.py:62
> +    def __init__(self, sys_module=None, platform_module=None, executive=None):

I'm still marginally worried about making these optional, in case we forget that these to need to be passed, especially when in WebKit these are always the 'standard' objects. Do you have any idea of any approach to make sure that we remember to pass these when needed?

> Tools/Scripts/webkitpy/common/system/platforminfo.py:139
> +            return "Mac OS X %s" % (self._platform_module or platform).mac_ver()[0]

I feel like it would be clearer to just use self._platform_module everywhere and then delete it if it is platform in __getstate__ (and reintroduce it if omitted in __setstate__)?

Either that or make it self._platform_module_override and add a getter for _platform_module which does this?
Comment 7 Jonathan Bedard 2021-04-30 09:54:59 PDT
(In reply to Sam Sneddon [:gsnedders] from comment #6)
> Comment on attachment 427427 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=427427&action=review
> 
> > Tools/Scripts/webkitpy/common/system/platforminfo.py:62
> > +    def __init__(self, sys_module=None, platform_module=None, executive=None):
> 
> I'm still marginally worried about making these optional, in case we forget
> that these to need to be passed, especially when in WebKit these are always
> the 'standard' objects. Do you have any idea of any approach to make sure
> that we remember to pass these when needed?

PlatformInfo objects shouldn't be instantiated outside of the Host, and the defaults we're setting here are correct unless you have a specific reason to override them. It seems to me that naively instantiation the PlatformInfo object with this set of default arguments would give you what you're looking for.

The other option would be to not set defaults here, but still support "None" as an argument.

> 
> > Tools/Scripts/webkitpy/common/system/platforminfo.py:139
> > +            return "Mac OS X %s" % (self._platform_module or platform).mac_ver()[0]
> 
> I feel like it would be clearer to just use self._platform_module everywhere
> and then delete it if it is platform in __getstate__ (and reintroduce it if
> omitted in __setstate__)?
> 
> Either that or make it self._platform_module_override and add a getter for
> _platform_module which does this?

The problem I see with this approach is that if the platform_module isn't the default, it likely is able to be pickled (and that's probably what we want to do).
Comment 8 EWS 2021-04-30 11:22:36 PDT
Committed r276846 (237197@main): <https://commits.webkit.org/237197@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427427 [details].
Comment 9 WebKit Commit Bot 2021-04-30 12:10:39 PDT
Re-opened since this is blocked by bug 225242
Comment 10 Jonathan Bedard 2021-04-30 13:37:15 PDT
Created attachment 427443 [details]
Patch
Comment 11 Aakash Jain 2021-05-03 15:25:50 PDT
rs=me
Comment 12 Jonathan Bedard 2021-05-03 15:52:36 PDT
Created attachment 427608 [details]
Patch for landing
Comment 13 EWS 2021-05-03 16:41:59 PDT
Committed r276935 (237271@main): <https://commits.webkit.org/237271@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427608 [details].