Skip to content
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

Merged
merged 1 commit into from
May 25, 2018

Conversation

techytushar
Copy link
Contributor

PR for issue #925
Signed-off-by: Tushar Mittal [email protected]

@codecov
Copy link

codecov bot commented Feb 18, 2018

Codecov Report

Merging #945 into develop will decrease coverage by 2.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
src/formattedcode/output_json.py 100% <ø> (ø) ⬆️
src/formattedcode/output_jsonlines.py 100% <ø> (ø) ⬆️
src/scancode/cli_test_utils.py 76.81% <100%> (-3.19%) ⬇️
src/scancode/resource.py 73.95% <100%> (-7.87%) ⬇️
src/scancode/cli.py 77.68% <100%> (+0.33%) ⬆️
src/cluecode/copyrights.py 65.1% <0%> (-32.2%) ⬇️
src/licensedcode/frequent_tokens.py 77.77% <0%> (-22.23%) ⬇️
src/scancode/api.py 71.2% <0%> (-21.6%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7884468...c93f823. Read the comment docs.

Copy link
Member

@pombredanne pombredanne left a 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

@@ -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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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

@@ -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)
Copy link
Member

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?

for name, value, in codebase.timings.items():
if name == 'timestamp':
Copy link
Member

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)

Copy link
Member

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.

@@ -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
Copy link
Member

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.

pombredanne added a commit that referenced this pull request Feb 19, 2018
 * this is based on discussions with @techytushar in #945

Signed-off-by: Philippe Ombredanne <[email protected]>
@techytushar
Copy link
Contributor Author

@pombredanne please review, i have made the required changes.. 😅

Copy link
Member

@pombredanne pombredanne left a 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)

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,
Copy link
Member

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

@techytushar techytushar force-pushed the timestamp branch 2 times, most recently from 4dfec29 to 8c904f3 Compare February 20, 2018 23:59
@techytushar
Copy link
Contributor Author

techytushar commented Feb 21, 2018

@pombredanne please review, added the test

@@ -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())
Copy link
Member

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.

@techytushar
Copy link
Contributor Author

techytushar commented Feb 28, 2018

@pombredanne only one test is failing in the travis-ci, but all tests pass on my local machine, please review..

@pombredanne
Copy link
Member

The travis failure is an heisenbug. I respun a build

@pombredanne
Copy link
Member

Merging now. Thanks!

@pombredanne pombredanne merged commit ec96739 into aboutcode-org:develop May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants