scancode-toolkit icon indicating copy to clipboard operation
scancode-toolkit copied to clipboard

add duration of the scan to JSON

Open armijnhemel opened this issue 6 years ago • 16 comments

Short Description

currently there is already a start time stamp and end time stamp in the JSON output. It would be nice to also have a "duration" field so I don't have to compute that myself.

Possible Labels

  • new feature

Select Category

  • Enhancement [X]
  • Add License/Copyright []
  • Scan Feature []
  • Packaging []
  • Documentation []
  • Expand Support []
  • Other []

Describe the Update

How This Feature will help you/your organization

Possible Solution/Implementation Details

end_timestamp - start_timestamp

Example/Links if Any

Can you help with this Feature

armijnhemel avatar Feb 19 '20 14:02 armijnhemel

@armijnhemel Thank you for this: would a duration in seconds work as in 7776045? (as opposed to a human readable and formatted string such as 3:12:45 for 3 hours, 12 minutes and 45 seconds? Note also this cannot be 100% accurate as the actual time it takes to write the JSON cannot be integrated, and this could be several seconds on large scans.

pombredanne avatar Feb 21 '20 08:02 pombredanne

@armijnhemel Thank you for this: would a duration in seconds work as in 7776045? (as opposed to a human readable and formatted string such as 3:12:45 for 3 hours, 12 minutes and 45 seconds? Note also this cannot be 100% accurate as the actual time it takes to write the JSON cannot be integrated, and this could be several seconds on large scans.

Having just seconds would be perfect. I could do formatting myself later.

armijnhemel avatar Feb 21 '20 10:02 armijnhemel

@pombredanne i would like to work on this feature. Anything I should know that might help me or I should take care of?

mnv936 avatar Feb 23 '20 13:02 mnv936

@pombredanne even I would love to work on this feature

shivam-bit avatar Feb 23 '20 13:02 shivam-bit

Hi, I have added the requested feature in the following pull requests: https://github.com/nexB/scancode-toolkit/pull/1939

Now, you can see a 'time_taken' field in the header of the output JSON file,

MankaranSingh avatar Feb 24 '20 20:02 MankaranSingh

i guess i need to edit the test cases too since this feature requires direct change in the output JSON file, alot of test cases.

So how should i go dealing with this ? any help is appreciated

MankaranSingh avatar Feb 25 '20 07:02 MankaranSingh

@MankaranSingh thank you for this! @armijnhemel do you see this feature as something always present in the JSON scan outputs? Or as guarded by a command line option?

pombredanne avatar Feb 25 '20 15:02 pombredanne

@MankaranSingh let's see if this need to be enabled at all times or not first before updating the tests. There are ways to regenerate test fixtures to help a bit

pombredanne avatar Feb 25 '20 15:02 pombredanne

I think that we can avoid yet another command line option.

mjherzog avatar Feb 25 '20 16:02 mjherzog

I would just always include it.

armijnhemel avatar Feb 25 '20 16:02 armijnhemel

@MankaranSingh so you will have indeed to update a good bunch of test scan files since they will now contain your new field... On te other hand, since this field will have a different value on each run, it is best excluded from most of the scan tests assertions, except for a few tests focused only on the tests of that feature. Does it make sense? There are very few places where these checks are done, mostly in this place https://github.com/nexB/scancode-toolkit/blob/develop/src/scancode/cli_test_utils.py

pombredanne avatar Feb 25 '20 20:02 pombredanne

ok, on it. So, if i need further help, shall i ask here or on the gitter discussion channel ?

MankaranSingh avatar Feb 26 '20 03:02 MankaranSingh

@MankaranSingh best is to keep ticket related discussions on the ticket and you can ask for help in the chat linking to the ticket.

pombredanne avatar Feb 26 '20 06:02 pombredanne

I have opened another pull request https://github.com/nexB/scancode-toolkit/pull/1942 Here are all the changes @pombredanne ok, so all the tests seem to be passing now. What i found out was, that the "start_timestamp" and "end_timestamp" were excluded from the JSON file prior to comparing with the expected JSON file. So, it made sense for me to exclude the new "time_taken" field too !

also, i found no other tests that specifically tested the "start_timestamp" and "end_timestamp", so i too didn't write any other test for the "time_taken" feature.

Also, @armijnhemel, i have updated my commit to store time as float instead of string.

MankaranSingh avatar Feb 26 '20 16:02 MankaranSingh

I wish to work on this issue. Is it still available?

dakshaladia avatar Feb 29 '20 08:02 dakshaladia

I wish to work on this issue. Is it still available?

I suppose it is no longer available, but perhaps @pombredanne can clarify?

armijnhemel avatar Mar 03 '20 23:03 armijnhemel