You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@aurora.apache.org by Joe Smith <ya...@gmail.com> on 2015/06/06 02:01:19 UTC

Re: Review Request 34570: Use set-literals and set-comprehensions where possible

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/34570/#review86872
-----------------------------------------------------------

Ship it!


Also LGTM pending jcohen's comment

- Joe Smith


On May 21, 2015, 4:28 p.m., Kevin Sweeney wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/34570/
> -----------------------------------------------------------
> 
> (Updated May 21, 2015, 4:28 p.m.)
> 
> 
> Review request for Aurora, Joshua Cohen and Brian Wickman.
> 
> 
> Repository: aurora
> 
> 
> Description
> -------
> 
> Use Python 2.7 set-literal and set-comprehension syntax where possible.
> 
> There are theoretical performance gains here, for example we now often avoid the creation of an intermediate list. The main reason I did this was consistency though - as you'll see in this review there's no single agreed-upon way to do this.
> 
> 
> Diffs
> -----
> 
>   3rdparty/python/requirements.txt 439554d0980a4f3cd5b65a809547c7ac32d3cbf5 
>   src/main/python/apache/aurora/admin/admin.py d2f7bd13ef335bdca7dc02177c031ac36574658d 
>   src/main/python/apache/aurora/admin/host_maintenance.py c31e2a6fb0348c5e7074e46d61c2d2723afaf14d 
>   src/main/python/apache/aurora/client/api/__init__.py 4b9c48e84bc203fc7b28d7efd0b2e6b8a6f18302 
>   src/main/python/apache/aurora/client/api/instance_watcher.py 6ed815423f48301ecb3faaadcdfa1e46f50b6ca2 
>   src/main/python/apache/aurora/client/api/job_monitor.py aa7e9760d0f4f74a5ddf97e0642bf53efc555644 
>   src/main/python/apache/aurora/client/api/sla.py 5855685bda7188c55432dc6f1ad3c676a38309da 
>   src/main/python/apache/aurora/client/api/updater.py acbce21e991981a2e85c1a00a68e57d88c5509bb 
>   src/main/python/apache/aurora/client/cli/command_hooks.py e95b1b11e16b8e2cfc83ace8654e146be208d14e 
>   src/main/python/apache/aurora/client/cli/context.py c850223588df9d9be4a644aa51adc6419a751af0 
>   src/main/python/apache/aurora/client/cli/jobs.py 5f608419e1235f14836865b46be05d13963deb37 
>   src/main/python/apache/aurora/client/cli/task.py b541d03d6e34dce7f4f1e38e2d970c71c8d94e08 
>   src/main/python/apache/aurora/config/__init__.py dd2f89014a3da730364b14e01c499ac0f2c288c1 
>   src/main/python/apache/aurora/executor/gc_executor.py d4392faf50f8c72f08f951962913248045d7fcb5 
>   src/main/python/apache/thermos/cli/commands/tail.py 47b52eee7cb43a46f75d62b648d293a9c603efc3 
>   src/main/python/apache/thermos/common/planner.py da5120f8f0c2489927a03e9d78ccb4f9b6eb275f 
>   src/main/python/apache/thermos/core/helper.py 8cd32948663a5d5a1e975e1661b78de701710436 
>   src/test/python/apache/aurora/BUILD 0701440ae47034c580b5baae40e5f6feec4bb4fd 
>   src/test/python/apache/aurora/client/api/BUILD 65b378b0b4c5fa11f9899ef04a4a10a211f37245 
>   src/test/python/apache/aurora/client/api/test_job_monitor.py ccc8b551c15df2d726291675a90a62c30ad5ebd4 
>   src/test/python/apache/aurora/client/api/test_sla.py 22b9f995eaa1deae9f5c5467e0939670c099f438 
>   src/test/python/apache/aurora/client/cli/BUILD 0d85f5fba9d19ae0e9c36546f130b93664b4f6de 
>   src/test/python/apache/aurora/client/cli/test_command_hooks.py 2130f1fa71be02a004cdf8e476a270c81a7105d3 
>   src/test/python/apache/aurora/client/cli/test_create.py 9f32ca3474ea51529217db29b88911010fa73602 
>   src/test/python/apache/aurora/client/cli/test_plugins.py a545fece5e2b3e0017a61e1be9ac478372b1f34d 
>   src/test/python/apache/aurora/thrift_util.py PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/34570/diff/
> 
> 
> Testing
> -------
> 
> I've left most of the tests out of the scope of this review to provide more confidence; however, I've fixed them in a few places where using sets consistently broke things. Specifically I changed construction of some Thrift structs to use set-literals instead of list-literals (since their IDL type is set and not list) and this broke some tests due to a long-standing bug in Thrift.
> 
> To fix them I've introduced a test dependency on [PyHamcrest](http://pyhamcrest.readthedocs.org/en/release-1.8/tutorial/) for matchers support (it's pretty much the same as Java for those who are familiar). Usage of PyHamcrest is [suggested in the mock documentation for this use case](https://docs.python.org/3/library/unittest.mock-examples.html#more-complex-argument-matching).
> 
> ./pants test.pytest --no-fast src/test/python::
> 
> 
> Thanks,
> 
> Kevin Sweeney
> 
>