Not able to map float value to measurement field

Bug #1163661 reported by HariGopal
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
LAVA Dispatcher
Fix Released
High
Senthil Kumaran S

Bug Description

After parsing, while mapping the fields to values lava_test_shell, It was throwing error

root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING: [ACTION-E] lava_test_shell is finished with error (ValidationError: Object has incorrect type (expected number) object_expr='object.test_runs[0].test_results[0].measurement', schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).

Changed in lava-dispatcher:
assignee: nobody → Senthil Kumaran S (stylesen)
importance: Undecided → Medium
Revision history for this message
Senthil Kumaran S (stylesen) wrote :

After more analysis, I could see this is a problem with how measurement values are handled within lava-test-shell. They are pushed as decimal.Decimal which is not understood by JSON. Am in the process of converting everything to a float before handing over to JSON.

Changed in lava-dispatcher:
milestone: none → 2013.04
status: New → In Progress
importance: Medium → High
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 1163661] Re: Not able to map float value to measurement field

Senthil Kumaran S <email address hidden> writes:

> After more analysis, I could see this is a problem with how measurement
> values are handled within lava-test-shell.

This much makes sense.

> They are pushed as decimal.Decimal which is not understood by JSON.

This is a simplification though. Looking at the dashboard bundle code,
it seems json.dumps has a use_decimal argument -- probably somewhere in
the dispatcher code we need to be using that.

> Am in the process of converting everything to a float before handing
> over to JSON.

Please don't do this if we don't have too -- everything else treats
measurements as decimal floating point values, not C doubles.

Cheers,
mwh

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

in the _get_test_results method of this file
http://bazaar.launchpad.net/~linaro-validation/lava-dispatcher/trunk/view/head:/lava_dispatcher/lava_test_shell.py#L214

add some lines like following should be OK I guess:

if 'measurement' in in res:
   res['measurement'] = float(res['measurement'])

Thanks,
Yongqin Liu
On 8 April 2013 06:00, Michael Hudson-Doyle <email address hidden>wrote:

> Senthil Kumaran S <email address hidden> writes:
>
> > After more analysis, I could see this is a problem with how measurement
> > values are handled within lava-test-shell.
>
> This much makes sense.
>
> > They are pushed as decimal.Decimal which is not understood by JSON.
>
> This is a simplification though. Looking at the dashboard bundle code,
> it seems json.dumps has a use_decimal argument -- probably somewhere in
> the dispatcher code we need to be using that.
>
> > Am in the process of converting everything to a float before handing
> > over to JSON.
>
> Please don't do this if we don't have too -- everything else treats
> measurements as decimal floating point values, not C doubles.
>
> Cheers,
> mwh
>
> --
> You received this bug notification because you are a member of Linaro
> Validation Team, which is subscribed to LAVA Dispatcher.
> https://bugs.launchpad.net/bugs/1163661
>
> Title:
> Not able to map float value to measurement field
>
> Status in LAVA Dispatcher:
> In Progress
>
> Bug description:
> After parsing, while mapping the fields to values lava_test_shell, It
> was throwing error
>
> root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING:
> [ACTION-E] lava_test_shell is finished with error (ValidationError:
> Object has incorrect type (expected number)
> object_expr='object.test_runs[0].test_results[0].measurement',
>
> schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lava-dispatcher/+bug/1163661/+subscriptions
>

--
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
<email address hidden> <email address hidden>
http://lists.linaro.org/mailman/listinfo/linaro-android
<email address hidden> <email address hidden>
http://lists.linaro.org/pipermail/linaro-validation

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Hi Yongqin,

On Mon, 2013-04-08 at 03:08 +0000, Yongqin Liu wrote:
> add some lines like following should be OK I guess:
>
> if 'measurement' in in res:
> res['measurement'] = float(res['measurement'])

This will not be the right fix as Michael pointed out. The DocumentIO
class in io.py of linaro-python-dashboard-bundle says 'use_decimal' for
json.dumps() hence the above fix will not work. Will come with a better
fix in sometime.

Thank You.

--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

in lava-android-test, it is done in such way.
If that's not right, please help to fix the following place too.
http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/testdef.py#L527

On 8 April 2013 11:21, Senthil Kumaran S <email address hidden> wrote:

> Hi Yongqin,
>
> On Mon, 2013-04-08 at 03:08 +0000, Yongqin Liu wrote:
> > add some lines like following should be OK I guess:
> >
> > if 'measurement' in in res:
> > res['measurement'] = float(res['measurement'])
>
> This will not be the right fix as Michael pointed out. The DocumentIO
> class in io.py of linaro-python-dashboard-bundle says 'use_decimal' for
> json.dumps() hence the above fix will not work. Will come with a better
> fix in sometime.
>
> Thank You.
>
> --
> Senthil Kumaran
> http://www.stylesen.org/
> http://www.sasenthilkumaran.com/
>
> --
> You received this bug notification because you are a member of Linaro
> Validation Team, which is subscribed to LAVA Dispatcher.
> https://bugs.launchpad.net/bugs/1163661
>
> Title:
> Not able to map float value to measurement field
>
> Status in LAVA Dispatcher:
> In Progress
>
> Bug description:
> After parsing, while mapping the fields to values lava_test_shell, It
> was throwing error
>
> root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING:
> [ACTION-E] lava_test_shell is finished with error (ValidationError:
> Object has incorrect type (expected number)
> object_expr='object.test_runs[0].test_results[0].measurement',
>
> schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lava-dispatcher/+bug/1163661/+subscriptions
>

--
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
<email address hidden> <email address hidden>
http://lists.linaro.org/mailman/listinfo/linaro-android
<email address hidden> <email address hidden>
http://lists.linaro.org/pipermail/linaro-validation

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Hi Yongqin,

On Mon, 2013-04-08 at 04:08 +0000, Yongqin Liu wrote:
> in lava-android-test, it is done in such way.
> If that's not right, please help to fix the following place too.
> http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/testdef.py#L527

In lava-android-test the situation is different, we do not validate
against the json schema in dashboard bundle format. It is just being
used by the parser. We do validate against the schema during upload of
bundle, where the measurement is a number by then and not a string.

Thank You.

--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

I just committed a fix for this in lava-dispatcher trunk @ r578. Following is the patch for reference:

<snip>
=== modified file 'lava_dispatcher/lava_test_shell.py'
--- lava_dispatcher/lava_test_shell.py 2013-04-05 09:27:07 +0000
+++ lava_dispatcher/lava_test_shell.py 2013-04-08 04:31:13 +0000
@@ -239,6 +239,13 @@
                     continue
             res['log_lineno'] = lineno
             res['log_filename'] = 'stdout.log'
+ if 'measurement' in res:
+ try:
+ res['measurement'] = decimal.Decimal(res['measurement'])
+ except decimal.InvalidOperation:
+ logging.warning("Invalid measurement %s" % (
+ res['measurement']))
+ del res['measurement']
             results_from_log_file.append(res)

     results_from_directories = []
</snip>

Changed in lava-dispatcher:
status: In Progress → Fix Committed
Revision history for this message
Yongqin Liu (liuyq0307) wrote :

In lava-android-test, the validation is done too.
It is done by he DocumentIO.dump like here:
http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/commands.py#L412

On 8 April 2013 12:21, Senthil Kumaran S <email address hidden> wrote:

> Hi Yongqin,
>
> On Mon, 2013-04-08 at 04:08 +0000, Yongqin Liu wrote:
> > in lava-android-test, it is done in such way.
> > If that's not right, please help to fix the following place too.
> >
> http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/testdef.py#L527
>
> In lava-android-test the situation is different, we do not validate
> against the json schema in dashboard bundle format. It is just being
> used by the parser. We do validate against the schema during upload of
> bundle, where the measurement is a number by then and not a string.
>
> Thank You.
>
> --
> Senthil Kumaran
> http://www.stylesen.org/
> http://www.sasenthilkumaran.com/
>
> --
> You received this bug notification because you are a member of Linaro
> Validation Team, which is subscribed to LAVA Dispatcher.
> https://bugs.launchpad.net/bugs/1163661
>
> Title:
> Not able to map float value to measurement field
>
> Status in LAVA Dispatcher:
> In Progress
>
> Bug description:
> After parsing, while mapping the fields to values lava_test_shell, It
> was throwing error
>
> root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING:
> [ACTION-E] lava_test_shell is finished with error (ValidationError:
> Object has incorrect type (expected number)
> object_expr='object.test_runs[0].test_results[0].measurement',
>
> schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lava-dispatcher/+bug/1163661/+subscriptions
>

--
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
<email address hidden> <email address hidden>
http://lists.linaro.org/mailman/listinfo/linaro-android
<email address hidden> <email address hidden>
http://lists.linaro.org/pipermail/linaro-validation

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Mon, 2013-04-08 at 05:02 +0000, Yongqin Liu wrote:
> In lava-android-test, the validation is done too.
> It is done by he DocumentIO.dump like here:
> http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/commands.py#L412

Thanks for pointing it out! I did not get on to those bits. Anyway now
the proper fix is in for lava-test-shell.

Thank You.

--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Mon, 2013-04-08 at 05:02 +0000, Yongqin Liu wrote:
> In lava-android-test, the validation is done too.
> It is done by he DocumentIO.dump like here:
> http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/commands.py#L412

To be consistent with what we do, a patch to fix lava-android-test
(untested) will look like the following:

<snip>
=== modified file 'lava_android_test/testdef.py'
--- lava_android_test/testdef.py 2012-12-06 11:02:22 +0000
+++ lava_android_test/testdef.py 2013-04-08 05:29:14 +0000
@@ -23,6 +23,7 @@
 import string
 import time
 import tempfile
+import decimal
 from datetime import datetime
 from uuid import uuid4

@@ -525,11 +526,18 @@
         return False

     def fixmeasurements(self):
- """Measurements are often read as strings, but need to be float
+ """Measurements are often read as strings, but need to be
+ decimal.Decimal as per dashboard bundle format JSON schema.
         """
         for test_case in self.results['test_results']:
             if 'measurement' in test_case:
- test_case['measurement'] =
float(test_case['measurement'])
+ try:
+ test_case['measurement'] = decimal.Decimal(
+ test_case['measurement'])
+ except decimal.InvalidOperation:
+ logging.warning("Invalid measurement %s" % (
+ test_case['measurement']))
+ del test_case['measurement']

     def fixids(self, test_name=''):
         """
</snip>

Do we need to fix this in lava-android-test ? If so I feel a separate
bug will be appropriate.

Thank You.

--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Yongqin Liu (liuyq0307) wrote :
Download full text (3.3 KiB)

For consistency, I think we need to fix it.
could you help to file a new bug and fix that?

And BTW, I can't image the difference on dashboard between the float and
Decimal.
do you know that?

Thanks,
Yongqin Liu

On 8 April 2013 13:35, Senthil Kumaran S <email address hidden> wrote:

> On Mon, 2013-04-08 at 05:02 +0000, Yongqin Liu wrote:
> > In lava-android-test, the validation is done too.
> > It is done by he DocumentIO.dump like here:
> >
> http://bazaar.launchpad.net/~linaro-validation/lava-android-test/trunk/view/head:/lava_android_test/commands.py#L412
>
> To be consistent with what we do, a patch to fix lava-android-test
> (untested) will look like the following:
>
> <snip>
> === modified file 'lava_android_test/testdef.py'
> --- lava_android_test/testdef.py 2012-12-06 11:02:22 +0000
> +++ lava_android_test/testdef.py 2013-04-08 05:29:14 +0000
> @@ -23,6 +23,7 @@
> import string
> import time
> import tempfile
> +import decimal
> from datetime import datetime
> from uuid import uuid4
>
> @@ -525,11 +526,18 @@
> return False
>
> def fixmeasurements(self):
> - """Measurements are often read as strings, but need to be float
> + """Measurements are often read as strings, but need to be
> + decimal.Decimal as per dashboard bundle format JSON schema.
> """
> for test_case in self.results['test_results']:
> if 'measurement' in test_case:
> - test_case['measurement'] =
> float(test_case['measurement'])
> + try:
> + test_case['measurement'] = decimal.Decimal(
> + test_case['measurement'])
> + except decimal.InvalidOperation:
> + logging.warning("Invalid measurement %s" % (
> + test_case['measurement']))
> + del test_case['measurement']
>
> def fixids(self, test_name=''):
> """
> </snip>
>
> Do we need to fix this in lava-android-test ? If so I feel a separate
> bug will be appropriate.
>
> Thank You.
>
> --
> Senthil Kumaran
> http://www.stylesen.org/
> http://www.sasenthilkumaran.com/
>
> --
> You received this bug notification because you are a member of Linaro
> Validation Team, which is subscribed to LAVA Dispatcher.
> https://bugs.launchpad.net/bugs/1163661
>
> Title:
> Not able to map float value to measurement field
>
> Status in LAVA Dispatcher:
> Fix Committed
>
> Bug description:
> After parsing, while mapping the fields to values lava_test_shell, It
> was throwing error
>
> root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING:
> [ACTION-E] lava_test_shell is finished with error (ValidationError:
> Object has incorrect type (expected number)
> object_expr='object.test_runs[0].test_results[0].measurement',
>
> schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lava-dispatcher/+bug/1163661/+subscriptions
>

--
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
linaro-...

Read more...

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

On Mon, 2013-04-08 at 05:58 +0000, Yongqin Liu wrote:
> And BTW, I can't image the difference on dashboard between the float and
> Decimal.
> do you know that?

It is because of the following two lines in
linaro-python-dashboard-bundle :

http://bazaar.launchpad.net/~linaro-validation/linaro-python-dashboard-bundle/trunk/view/head:/linaro_dashboard_bundle/io.py#L123
http://bazaar.launchpad.net/~linaro-validation/linaro-python-dashboard-bundle/trunk/view/head:/linaro_dashboard_bundle/io.py#L133

Thank You.

--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Hi Yongqin,

On Mon, 2013-04-08 at 05:58 +0000, Yongqin Liu wrote:
> For consistency, I think we need to fix it.
> could you help to file a new bug and fix that?

I fixed it via bug #1166009

Thank You.
--
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

Hi, Senthil

Thank you very much!

Thanks,
Yongqin Liu
On 8 April 2013 14:39, Senthil Kumaran S <email address hidden> wrote:

> Hi Yongqin,
>
> On Mon, 2013-04-08 at 05:58 +0000, Yongqin Liu wrote:
> > For consistency, I think we need to fix it.
> > could you help to file a new bug and fix that?
>
> I fixed it via bug #1166009
>
> Thank You.
> --
> Senthil Kumaran
> http://www.stylesen.org/
> http://www.sasenthilkumaran.com/
>
> --
> You received this bug notification because you are a member of Linaro
> Validation Team, which is subscribed to LAVA Dispatcher.
> https://bugs.launchpad.net/bugs/1163661
>
> Title:
> Not able to map float value to measurement field
>
> Status in LAVA Dispatcher:
> Fix Committed
>
> Bug description:
> After parsing, while mapping the fields to values lava_test_shell, It
> was throwing error
>
> root@master [rc=0]# <LAVA_DISPATCHER>2013-04-02 09:06:13 AM WARNING:
> [ACTION-E] lava_test_shell is finished with error (ValidationError:
> Object has incorrect type (expected number)
> object_expr='object.test_runs[0].test_results[0].measurement',
>
> schema_expr='schema.properties.test_runs.items.properties.test_results.items.properties.measurement.type')).
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/lava-dispatcher/+bug/1163661/+subscriptions
>

--
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
<email address hidden> <email address hidden>
http://lists.linaro.org/mailman/listinfo/linaro-android
<email address hidden> <email address hidden>
http://lists.linaro.org/pipermail/linaro-validation

Changed in lava-dispatcher:
status: Fix Committed → Fix Released
status: Fix Released → Fix Committed
Changed in lava-dispatcher:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.