aurora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maxim Khutornenko" <ma...@apache.org>
Subject Re: Review Request 16311: Fixing updater diff.
Date Thu, 02 Jan 2014 22:08:59 GMT


> On Jan. 2, 2014, 9:11 p.m., Brian Wickman wrote:
> > src/main/python/twitter/aurora/client/api/updater.py, lines 170-191
> > <https://reviews.apache.org/r/16311/diff/3/?file=413507#file413507line170>
> >
> >     this seems a bit elaborate.  would the following work?
> >     
> >     
> >     import json
> >     import pprint
> >     import sys
> >     
> >     
> >     def hashable(element):  
> >       if isinstance(element, (list, set)):  
> >         return tuple(sorted(hashable(item) for item in element))  
> >       elif isinstance(element, dict):  
> >         return tuple(sorted((hashable(key), hashable(value)) for (key, value) in
element.items()))  
> >       return element  
> >     
> >     
> >     pprint.pprint(hashable(json.load(sys.stdin)))
> >     
> >     
> >     
> >     mba=~=; unzip -p ~/.pants.d/bin/pants.pex/pants-0.0.4-science-py26.pex PEX-INFO
 | python foo.py
> >     ((u'always_write_cache', False),
> >      (u'build_properties',
> >       ((u'branch', u'git-review/branches/243585'),
> >        (u'class', u'CPython'),
> >        (u'date', u'Wednesday Dec 04, 2013'),
> >        (u'machine', u'ramanujan.uthcode.com'),
> >        (u'path', u'/Users/skumaran/twitter/science'),
> >        (u'platform', u'macosx-10.4-x86_64'),
> >        (u'sha', u'6084f8a289767979535575053a5b26aa8c1fe19b'),
> >        (u'tag', u'com.twitter-ibis-thrift-service-4.0.8-24-g6084f8a'),
> >        (u'time', u'18:28:38'),
> >        (u'timestamp', u'12.04.2013 18:28'),
> >        (u'user', u'skumaran'),
> >        (u'version', (2, 6, 8)))),
> >      (u'egg_caches', ()),
> >      (u'entry_point', u'twitter.pants.bin.pants_exe:main'),
> >      (u'ignore_errors', False),
> >      (u'indices', ()),
> >      (u'inherit_path', False),
> >      (u'repositories', ()),
> >      (u'requirements',
> >       ((None, False, u'ansicolors'),
> >        (None, False, u'elementtree'),
> >        (None, False, u'mako'),
> >        (None, False, u'markdown'),
> >        (None, False, u'psutil==1.1.2'),
> >        (None, False, u'pygments'),
> >        (None, False, u'pylint'),
> >        (None, False, u'pytest'),
> >        (None, False, u'pytest-cov'),
> >        (None, False, u'setuptools==1.1.7'))),
> >      (u'zip_safe', True))
> >

Sure, this will work too. It's a bit less readable due to tuple syntax though:

tuples:
((u'constraints', (((u'constraint', ((u'limit', ((u'limit', 10),)),)), (u'name', u'limit')),
((u'constraint', ((u'values', (u'1', u'2')),)), (u'name', u'value')))),)

list/tuples:
[(u'constraints', [[(u'constraint', [(u'limit', [(u'limit', 10)])]), (u'name', u'limit')],
[(u'constraint', [(u'values', [u'1', u'2'])]), (u'name', u'value')]])] 

However, I can definitely appreciate code brevity of your approach. Changed.


- Maxim


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


On Jan. 2, 2014, 8:57 p.m., Maxim Khutornenko wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/16311/
> -----------------------------------------------------------
> 
> (Updated Jan. 2, 2014, 8:57 p.m.)
> 
> 
> Review request for Aurora, Bill Farner and Brian Wickman.
> 
> 
> Repository: aurora
> 
> 
> Description
> -------
> 
> Hopefully fixing the thrift object diff once an for all. Instead of sorting __dict__
that proved to not cover all cases, converting thrift to sorted tuples via json serialization.
> 
> 
> Diffs
> -----
> 
>   src/main/python/twitter/aurora/client/api/updater.py 6e8e8a9fdfcf63a8fe0558d5ac36298601fd0552

>   src/test/python/twitter/aurora/client/api/test_updater.py ae4de2b57be16f8daf030210abda1ba05f9f30a0

> 
> Diff: https://reviews.apache.org/r/16311/diff/
> 
> 
> Testing
> -------
> 
> ./pants src/test/python/twitter/aurora/client/api:updater
> 
> 
> Thanks,
> 
> Maxim Khutornenko
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message