Bug 225230 - [webkitpy] Support pickling platforminfo
Summary: [webkitpy] Support pickling platforminfo
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jonathan Bedard
URL:
Keywords: InRadar
Depends on: 225242
Blocks:
  Show dependency treegraph
 
Reported: 2021-04-30 08:56 PDT by Jonathan Bedard
Modified: 2021-05-03 16:42 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.75 KB, patch)
2021-04-30 09:03 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff
Patch (5.18 KB, patch)
2021-04-30 13:37 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff
Patch for landing (5.27 KB, patch)
2021-05-03 15:52 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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].