Skip to content

Add origin summary plugin - #1588

Merged
pombredanne merged 154 commits into
developfrom
origin-summary-plugin
Jul 31, 2019
Merged

Add origin summary plugin#1588
pombredanne merged 154 commits into
developfrom
origin-summary-plugin

Conversation

@JonoYang

@JonoYang JonoYang commented Jun 7, 2019

Copy link
Copy Markdown
Member

This is a plugin that performs license and copyright holder summarization at the directory level. If a certain copyright holder and license expression shows up in 75% of files in a directory, then that copyright holder and license expression is brought to the directory level. The summarized clues are stored in a new field called origin_summary, which is a mapping that contains three keys: license_expression, holders, and count (the number of files with this particular license expression and copyright holders). There is another new field called summarized_to, which is a string that contains the path to the directory a Resource has been summarized to.

JonoYang added 11 commits May 28, 2019 18:18
    * If a license or copyright is detected in 80% of files in a given directory, that license and copyright is summarized at the directory level

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Register origin summary plugin

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Define majority to be 50% or more of a directory

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Add new flags for summarized rows or if a row is a summary

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Group holders and licenses together when counting
    * Check to see if copyrights or licenses is an attribute instead of requiring the copyright or license option to run the plugin

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Increase majority threshold to 0.75

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * This is so we do not have to walk the codebase twice to find children that have been summarized
    * We can instead just iterate through the list of RIDs and modify them
    * Update tests due to previous methods of tagging summarized Resources being flawed

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
@codecov

codecov Bot commented Jun 7, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1588 into develop will increase coverage by 0.07%.
The diff coverage is 93.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1588      +/-   ##
===========================================
+ Coverage    81.22%   81.29%   +0.07%     
===========================================
  Files          126      126              
  Lines        15612    15655      +43     
===========================================
+ Hits         12681    12727      +46     
+ Misses        2931     2928       -3
Impacted Files Coverage Δ
src/commoncode/ignore.py 74.35% <ø> (ø) ⬆️
src/packagedcode/rubygems.py 66.55% <ø> (ø) ⬆️
src/packagedcode/nuget.py 78.04% <ø> (ø) ⬆️
src/commoncode/fileutils.py 79.61% <100%> (+0.06%) ⬆️
src/packagedcode/models.py 93% <100%> (+0.21%) ⬆️
src/packagedcode/about.py 71.92% <100%> (+1.02%) ⬆️
src/packagedcode/chef.py 94.39% <100%> (+0.1%) ⬆️
src/packagedcode/npm.py 86.54% <100%> (+0.12%) ⬆️
src/packagedcode/pypi.py 85.13% <100%> (ø) ⬆️
src/packagedcode/__init__.py 82.05% <100%> (+3.92%) ⬆️
... and 9 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 8b69166...8f94757. Read the comment docs.

JonoYang added 4 commits June 7, 2019 18:47
    * TODO: Think about how to structure data in results

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Make this a nested defaultdict instead of using a tuple for the key

Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from 6053141 to d070252 Compare June 10, 2019 23:37
Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from d070252 to 706e3da Compare June 10, 2019 23:37
JonoYang added 3 commits June 10, 2019 16:53
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from 1c9f6ee to 8303aee Compare June 11, 2019 00:32
Signed-off-by: Jono Yang <jyang@nexb.com>
@pombredanne pombredanne changed the title Origin summary plugin Add origin summary plugin Jun 12, 2019
JonoYang added 4 commits June 12, 2019 18:40
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Change summarized_directories codebase attribute to summaries

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Change summary codebase attribute to be a list instead of an OrderedDict

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
JonoYang added 15 commits July 24, 2019 13:33
    * Pass files, directories, and special files through is_ignored

Signed-off-by: Jono Yang <jyang@nexb.com>
    * We now return consolidated components and consolidated packages in two top-level attributes

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Replace references to codebase.get_root(0) with codebase.root

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update some package parsers with path patterns to ignore
    * Update tests for get_package_resource

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update about.py with ignorable_path_patterns

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update about.py with ignorable_path_patterns

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Do not combine license-holder components
    * Add and update tests
    * Update docs and comments

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Package parsers can define what resources to ignore when returning package files
    * Resource and Codebase have been updated to support using this callable
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * If we are in a directory with no majority, we check the child directories if they have any majorities and return those
    * This prevents us from reported the same majority thing as we come up the codebase
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from 31074d2 to 75fefb6 Compare July 29, 2019 23:29
JonoYang added 4 commits July 29, 2019 17:10
    * Add new test

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Use proper test data as it appears in the real world
    * Reorder attributes on Consolidation
    * Update comments

Signed-off-by: Jono Yang <jyang@nexb.com>

@pombredanne pombredanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! See my comment inline. The only significant point is the names and order of the attributes on the Consolidation.

Comment thread .gitignore Outdated

# Nested ScanCode plugins
*build*
*dist*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be instead moved to plugins/scancode-consolidate-scan/.gitignore ?
I fear that this may be catching too many things

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a .gitignore to scancode-consolidate-scan

core_holders = attr.ib(default=attr.Factory(list))
other_holders = attr.ib(default=attr.Factory(list))
resources = attr.ib(default=attr.Factory(list))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might want instead somthing like this:

    consolidated_license_expression = attr.ib(default=None)
    consolidated_holders = attr.ib(default=attr.Factory(list))
    consolidated_copyright = attr.ib(default=None)

    core_license_expression = attr.ib(default=None)
    core_holders = attr.ib(default=attr.Factory(list))

    other_license_expression = attr.ib(default=None)
    other_holders = attr.ib(default=attr.Factory(list))

....


def consolidate_core_copyright(self):
# TODO: Verify and test that we are generating detectable copyrights
holders = list(self.core_holders) + list(self.other_holders)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one area where we would want to avoid duplicates (but we still want to have the core before the other)


def consolidate_other_copyright(self):
# TODO: Verify and test that we are generating detectable copyrights
other_holders = list(self.other_holders)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is wrapping in a list really needed there and elsewhere?


discovered_license_expressions = []
discovered_holders = []
for package_resource in package_resources:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: there is something called key files (from the --classify option) and they should be used when we have a package to craft the things that go in the core vs. other. That could be added later though

if child.extra_data.get('in_package_component'):
continue
if child.is_file:
license_expression = combine_expressions(child.license_expressions)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add a reminder to consider the license match coverage and/or score here in the near future. Otherwise we may end up creating consolidated things that have licenses that were weakly detected.

@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from a1493a1 to e6a5f99 Compare July 30, 2019 22:35
    * Remove plugin specific gitignore from project level gitignore
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
JonoYang force-pushed the origin-summary-plugin branch from e6a5f99 to aea1175 Compare July 30, 2019 22:44
JonoYang added 3 commits July 30, 2019 15:50
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update expected test results

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update expected test results

Signed-off-by: Jono Yang <jyang@nexb.com>
@pombredanne

Copy link
Copy Markdown
Member

LGTM. Thank you ++
Merging now.

@pombredanne
pombredanne merged commit 73e083d into develop Jul 31, 2019
@pombredanne
pombredanne deleted the origin-summary-plugin branch July 31, 2019 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants