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

Improve License Clarity at Top Package Level #3792

Draft
wants to merge 59 commits into
base: develop
Choose a base branch
from

Conversation

swastkk
Copy link
Collaborator

@swastkk swastkk commented Jun 1, 2024

Fixes #3802

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)
    Run tests locally to check for errors.

Signed-off-by: swastkk swastkk@gmail.com

Signed-off-by: swastik <swastkk@gmail.com>
swastkk added 2 commits June 7, 2024 17:59
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

@swastkk you are regenerating all the tests with useless churn. This adds more things to review and is not ideal. Let's do things differently. You can delete your last commit and push regenerated test fixtures for only the tests which were failing.

@swastkk swastkk force-pushed the improve-license-clarity branch from c5791ba to fa8fcfc Compare June 10, 2024 19:33
Signed-off-by: swastik <swastkk@gmail.com>
@swastkk swastkk force-pushed the improve-license-clarity branch from fa8fcfc to 64957ec Compare June 14, 2024 20:52
@AyanSinhaMahapatra
Copy link
Member

@swastkk this is not correct atm:

  1. why use license_clarity and not license_clarity_score? This is what we use on the summery option.
  2. We want this new attribute license_clarity_score added to top-level packages if and only if the --package-summary option is used, and not in every package like you have here.

This new plugin could be there in packagedcode/plugin_package.py possibly, as we need to check if this option is enabled or not in process_codebase step for the package plugin, and then this should be passed on below to package.to_dict() fucntion for the same.

Signed-off-by: swastik <swastkk@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

Does this make sure the license_clarity_score attribute is added only on using the --summary-package command line option? No. Look at your test regenerations, none of these tests have this option enabled, still have this attribute added.

You have to pass the package_summary option like we have the package_only CLI option here: https://github.com/nexB/scancode-toolkit/blob/develop/src/packagedcode/plugin_package.py#L203, then further pass it down to create_package_and_deps at https://github.com/nexB/scancode-toolkit/blob/develop/src/packagedcode/plugin_package.py#L263 and further to package.to_dict() at https://github.com/nexB/scancode-toolkit/blob/develop/src/packagedcode/plugin_package.py#L367 to actually be able to correctly set the attribute package_summary at https://github.com/swastkk/scancode-toolkit/blob/improve-license-clarity/src/packagedcode/models.py#L1544 you added thorugh this PR. Otherwise it's always set to one value.

…mary as Postscan Plugin

Signed-off-by: swastik <swastkk@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

More changes required.
Please merge latest develop afterwards.

tests/packagedcode/data/plugin/help.txt Outdated Show resolved Hide resolved
src/packagedcode/plugin_package.py Outdated Show resolved Hide resolved
src/packagedcode/plugin_package.py Outdated Show resolved Hide resolved
src/packagedcode/models.py Outdated Show resolved Hide resolved
src/packagedcode/models.py Outdated Show resolved Hide resolved
tests/scancode/data/help/help.txt Outdated Show resolved Hide resolved
swastkk added 3 commits June 26, 2024 17:39
…inor changes

Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
@swastkk swastkk force-pushed the improve-license-clarity branch from eb60d58 to 9da7f6e Compare June 26, 2024 16:46
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

See comments above. And sup on populating license clarity and other attributes?

Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

Couple more nits.

tests/packagedcode/test_plugin_package.py Outdated Show resolved Hide resolved
tests/scancode/data/help/help.txt Outdated Show resolved Hide resolved
src/packagedcode/models.py Outdated Show resolved Hide resolved
src/packagedcode/plugin_package.py Outdated Show resolved Hide resolved
src/packagedcode/plugin_package.py Outdated Show resolved Hide resolved
swastkk added 2 commits July 4, 2024 18:18
Signed-off-by: swastik <swastkk@gmail.com>
@swastkk swastkk linked an issue Jul 4, 2024 that may be closed by this pull request
…e(Without other_license_detections)

Signed-off-by: swastik <swastkk@gmail.com>
@swastkk swastkk self-assigned this Jul 5, 2024
swastkk added 3 commits August 9, 2024 16:25
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

@swastkk See comments and another comment I made above which is still unresolved.

src/summarycode/score.py Outdated Show resolved Hide resolved
Signed-off-by: swastik <swastkk@gmail.com>
… license-clarity-score plugins

Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

@swastkk you've made changes to the get_field_values_from_resources to send a resources list and not codebase object correctly, but note that we are still not sending anything in score.py: https://github.com/swastkk/scancode-toolkit/blob/improve-license-clarity/src/summarycode/score.py#L78 which would not work effectively if we run only the score option without summary.

You seem to be failing the tests for the same reason, please fix this part. You should be passing all tests to make sure no previous functionality is breaking in this refactor of the compute_license_score to suit the new plugin you're writing.

One minor thing:
The get_codebase_resources seems okay in summarizer.py but we are using dicts: https://github.com/swastkk/scancode-toolkit/blob/improve-license-clarity/src/summarycode/summarizer.py#L323, we should use resource objects here, and also in get_field_values_from_resources we should use resource objects, not list of resource dicts (this means wherever we have resource dicts, we should convert them to Resource objects first and then send in these functions)

Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Signed-off-by: swastik <swastkk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants