Thanks for your work on this. In general it looks good. :-)
I have some comments below that I think you should address before we can
merge this in, though. Nothing super complicated, but things that in my
opinion will make the code more clear for whoever comes to look at in in
future.
IMO you should handle the difference between plain URL's and
repositories outside of this function. See below.
> + default = "None"
Don't you mean None (without the quotes) here? Besides, I think the rest
of the function would be more clear if you just used `None` (actual
None, not a string "None") instead of default so someone reading the
code doesn't need to wonder "what does default mean"?
Do you really mean to convert whatever comes from there to a string? If
the JSON contains a null (the default according to the schema MP), you
will get a string containing the word "None".
You probably want something like this:
value = testdef['metadata'].get('key'), default
metadata['key'] = value and str(value) or value
if you don't do anything for all other possible values of `location`, I
don't think this should be in this function, and you don't need to add
`location` as a parameter.
See above, I don't think you should handle that logic inside
_get_testdef_info, so you should't need to add this second argument. IMO
doing the proper handling just after this snippet is fine.
Hello Senthil,
Thanks for your work on this. In general it looks good. :-)
I have some comments below that I think you should address before we can
merge this in, though. Nothing super complicated, but things that in my
opinion will make the code more clear for whoever comes to look at in in
future.
review needs-fixing
> === modified file 'lava_dispatche r/actions/ launch_ control. py' /actions/ launch_ control. py 2013-01-23 22:37:05 +0000 /actions/ launch_ control. py 2013-03-26 13:53:02 +0000 r/actions/ lava_test_ shell.py' /actions/ lava_test_ shell.py 2013-02-11 02:31:22 +0000 /actions/ lava_test_ shell.py 2013-03-26 13:53:02 +0000 error(' Unable to get test definition from bzr\n' + str(e)) info(testdef) : 'metadata' ].get(' version' )) 'description' ] = str(testdef[ 'metadata' ].get(' description' )) 'metadata' ].get(' format' )) info(testdef, location):
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -209,7 +209,7 @@
> if not all_bundles:
> main_bundle = {
> "test_runs": [],
> - "format": "Dashboard Bundle Format 1.5"
> + "format": "Dashboard Bundle Format 1.6"
> }
> else:
> main_bundle = all_bundles.pop(0)
>
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -202,18 +202,23 @@
> logging.
>
>
> -def _get_testdef_
> - metadata = {'os': '', 'devices': '', 'environment': ''}
> - metadata['version'] = str(testdef[
> - metadata[
> - metadata['format'] = str(testdef[
> +def _get_testdef_
IMO you should handle the difference between plain URL's and
repositories outside of this function. See below.
> + default = "None"
Don't you mean None (without the quotes) here? Besides, I think the rest
of the function would be more clear if you just used `None` (actual
None, not a string "None") instead of default so someone reading the
code doesn't need to wonder "what does default mean"?
> + metadata = {'os': default, 'devices': default, 'environment': default} 'description' ] = str(testdef[ 'metadata' ].get(' description' , 'metadata' ].get(' format' , default))
> + metadata[
> + default))
> + metadata['format'] = str(testdef[
Do you really mean to convert whatever comes from there to a string? If
the JSON contains a null (the default according to the schema MP), you
will get a string containing the word "None".
You probably want something like this:
value = testdef[ 'metadata' ].get(' key'), default
metadata['key'] = value and str(value) or value
> + 'metadata' ].get(' version' , default))
> + if location == 'URL':
> + metadata['version'] = str(testdef[
if you don't do anything for all other possible values of `location`, I
don't think this should be in this function, and you don't need to add
`location` as a parameter.
> # Convert list to comma separated string. 'metadata' ].get(' os'): testdef[ 'metadata' ].get(' os')) testdef[ 'metadata' ].get(' os', default)) 'metadata' ].get(' devices' ): testdef[ 'metadata' ].get(' devices' )) testdef[ 'metadata' ].get(' devices' , 'metadata' ].get(' environment' ): 'environment' ] = ','.join( metadata. update( _get_testdef_ info(testdef) ) metadata. update( _get_testdef_ info(testdef, 'URL'))
> if testdef[
> - metadata['os'] = ','.join(
> + metadata['os'] = ','.join(
>
> if testdef[
> - metadata['devices'] = ','.join(
> + metadata['devices'] = ','.join(
> + default))
>
> if testdef[
> metadata[
> @@ -249,7 +254,7 @@
> idx = len(self.testdefs)
>
> testdef_metadata = {'url': url, 'location': 'URL'}
> - testdef_
> + testdef_
See above, I don't think you should handle that logic inside
_get_testdef_info, so you should't need to add this second argument. IMO
doing the proper handling just after this snippet is fine.
> self._append_ testdef( URLTestDefiniti on(self. context, idx, testdef, s/testdef_ metadata' % hostdir, 'w') as f: yaml.dump( self.testdef_ metadata) ) yaml.safe_ dump(self. testdef_ metadata) ) repos(hostdir) metadata. update( {'url': info['branch_ url']}) metadata. update( {'location' : info['branch_ vcs'].upper( )}) metadata. update( {'repo_ rev': info['branch_ revision' ]}) metadata. update( _get_testdef_ info(testdef) ) metadata. update( {'version' : info['branch_ revision' ]})
> testdef_metadata))
>
> @@ -404,7 +409,7 @@
> f.write(self.uuid)
>
> with open('%
> - f.write(
> + f.write(
>
> if 'install' in self.testdef:
> self._create_
> @@ -439,8 +444,8 @@
> testdef_metadata = {}
> testdef_
> testdef_
> - testdef_
> - testdef_
> + testdef_
What happens if the testdef in the YAML file specifies a "version"
attribute explicitly, is that just going to be overwritten?
> + testdef_ metadata. update( _get_testdef_ info(testdef, 'REPO')) on.__init_ _(self, context, idx, testdef, r/lava_ test_shell. py' /lava_test_ shell.py 2013-02-11 02:31:22 +0000 /lava_test_ shell.py 2013-03-26 13:53:02 +0000 testdef_ metadata( test_run_ dir):
>
> URLTestDefiniti
> testdef_metadata)
>
> === modified file 'lava_dispatche
> --- lava_dispatcher
> +++ lava_dispatcher
> @@ -284,6 +284,26 @@
> return attachments
>
>
> +def _get_run_
> + default = "None"
> + testdef_metadata = {
> + 'version': default,
> + 'description': default,
> + 'format': default,
> + 'location': default,
> + 'url': default,
> + 'os': default,
> + 'devices': default,
> + 'environment': default
> + }
Same thing: don't you mean the actual None object instead of a
string "None"?
And again, I think it would be more clear if you just used None directly
instead of that variable