-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add timestamp to scan summary #925 #945
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #945 +/- ##
===========================================
- Coverage 78.9% 76.88% -2.02%
===========================================
Files 103 105 +2
Lines 12670 13984 +1314
===========================================
+ Hits 9997 10752 +755
- Misses 2673 3232 +559
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
OPne thing beside the comments is that we need to have the scan start timestamp added to the scan headers outputs, at least in the JSON ones
src/scancode/cli.py
Outdated
@@ -47,7 +47,7 @@ | |||
from scancode_config import scancode_temp_dir | |||
|
|||
from commoncode.fileutils import PATH_TYPE | |||
from commoncode.timeutils import time2tstamp | |||
from commoncode.timeutils import time2tstamp,tstamp2time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep each import on a separate line, but also based on my other comments tstamp2time
is not likely needed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO time2tstamp
returns date time like this 2018-02-19T145640.979020
which is quite hard to read and understand so i converted it to 2018-02-19 14:56:40.979020
using tstamp2time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO It is pure luck if a datetime ends up being serialized alright.
Instead you should use this I just pushed 179d983 with path_safe=False
src/scancode/cli.py
Outdated
@@ -1202,7 +1202,14 @@ def display_summary(codebase, scan_names, processes, verbose): | |||
'%(final_size_count)s' % locals()) | |||
|
|||
echo_stderr('Timings:') | |||
|
|||
timestamp = codebase.timings.get('timestamp',None) | |||
timestamp = tstamp2time(timestamp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you get a time back?
src/scancode/cli.py
Outdated
for name, value, in codebase.timings.items(): | ||
if name == 'timestamp': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should pop() above instead IMHO
e.g. not timestamp = codebase.timings.get('timestamp',None)
but instead timestamp = codebase.timings.pop('timestamp',None)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this should not be in timings... but a proper attribute, so this is moot.
src/scancode/cli.py
Outdated
@@ -724,7 +724,7 @@ def scancode(ctx, input, # NOQA | |||
# TODO: this is weird: may be the timings should NOt be stored on the | |||
# codebase, since they exist in abstract of it?? | |||
codebase.timings.update(setup_timings) | |||
|
|||
codebase.timings['timestamp'] = scan_start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO the scan_start should be its own attribute on the Codebase. This is not a "timing" proper.
ed98c29
to
66f428b
Compare
* this is based on discussions with @techytushar in #945 Signed-off-by: Philippe Ombredanne <[email protected]>
@pombredanne please review, i have made the required changes.. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This now needs some tests for sure. Testing the presence of this timestamp (and not its value since it changes on each run)
src/formattedcode/output_json.py
Outdated
pretty_options=pretty_options, | ||
pretty=True) | ||
|
||
|
||
def write_json(results, output_file, files_count, | ||
scancode_version, scancode_notice, | ||
pretty_options, pretty=False): | ||
timestamp,pretty_options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your code is not properly formatted
4dfec29
to
8c904f3
Compare
@pombredanne please review, added the test |
8c904f3
to
3d4010b
Compare
src/scancode/cli.py
Outdated
@@ -1202,6 +1202,10 @@ def display_summary(codebase, scan_names, processes, verbose): | |||
'%(final_size_count)s' % locals()) | |||
|
|||
echo_stderr('Timings:') | |||
|
|||
timestamp = codebase.scan_start | |||
echo_stderr(' timestamp: %(timestamp)s'% locals()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we call this Scan start instead here and in the JSON output? ... since this is what this is.
3d4010b
to
da96172
Compare
Signed-off-by: Tushar Mittal <[email protected]>
da96172
to
c93f823
Compare
@pombredanne only one test is failing in the travis-ci, but all tests pass on my local machine, please review.. |
The travis failure is an heisenbug. I respun a build |
Merging now. Thanks! |
PR for issue #925
Signed-off-by: Tushar Mittal [email protected]