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

License checker extensions #284

Merged
merged 18 commits into from
Sep 29, 2023
Merged

License checker extensions #284

merged 18 commits into from
Sep 29, 2023

Conversation

netsettler
Copy link
Collaborator

@netsettler netsettler commented Sep 14, 2023

Some additions to license checkers.

  • New license framework for R (tentatively implemented)
  • New license framework for Conda (tentatively implemented)
  • Much new license metadata
  • New script run-license-checker for people to use this without installing it in code.

Having done this, though, we removed the scan2-pipeline policy definition because it can now be modularly added elsewhere, in that code. Such a definition can be added in an external module and then invoked interactively by:

run-license-checker scan2-pipeline --policy-dir <dir>

or from code by:

from dcicutils.license_utils import LicenseCheckerRegistry
Scan2PipelineLicenseChecker = LicenseCheckerRegistry.lookup_checker('scan2-pipeline', policy_dir=<policy-dir>)
Scan2PIpelineLicenseChecker.validate()

Note that if the conda checkers do not run, you may be in the wrong directory or Conda may not have set its CONDA_PREFIX environment variable. You can specify the directory by:

from dcicutils.license_utils import LicenseCheckerRegistry, LicenseOptions
Scan2PipelineLicenseChecker = LicenseCheckerRegistry.lookup_checker('scan2-pipeline', policy_dir="<policy-dir>")
with LicenseOptions.selected_options(conda_prefix="<conda-dir>"):
    Scan2PIpelineLicenseChecker.validate()

or you can override the search for Conda's CONDA_PREFIX environment variable by setting the CONDA_LICENSE_CHECKER_PREFIX environment variable, which can be used to override CONDA_PREFIX.

@coveralls
Copy link

coveralls commented Sep 14, 2023

Pull Request Test Coverage Report for Build 6354777482

  • 254 of 331 (76.74%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 77.659%

Changes Missing Coverage Covered Lines Changed/Added Lines %
dcicutils/license_utils.py 240 317 75.71%
Totals Coverage Status
Change from base Build 6240767306: -0.1%
Covered Lines: 8478
Relevant Lines: 10917

💛 - Coveralls

Copy link
Member

@willronchetti willronchetti left a comment

Choose a reason for hiding this comment

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

These changes look good and the tool in general looks super useful and extendable as needed

Comment on lines +162 to +166
def simplify_license_versions(licenses_spec: str, *, for_package_name) -> str:
m = _GPL_VERSION_CHOICE.match(licenses_spec)
if m:
version_a, version_b = m.groups()
return f"GPL-{version_a}-or-{version_b}"
Copy link
Member

Choose a reason for hiding this comment

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

This could use some docstring as the function name reads like its generic but you've got some GPL specific things going on here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's true that it might not actually matter a lot if someone else used it. I can look at that.

@@ -646,6 +954,109 @@ class C4InfrastructureLicenseChecker(LicenseChecker):
'Zope Public License',
]

EXCEPTIONS = {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be read from a file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to look into that. The trade-off is that these are really things that should be matters of fixed policy, at least insofar as the validator functions are, and people should not be thinking they can just casually edit this stuff to make it go away. It requires a lot of thought about legalities. But, that said, the command line form allows someone to explore whether they're compliant and to work toward getting things in order. For that it can be useful to evolve something and propose it as a coherent whole. So it's not a technical matter but a social, workflow, and legal issue. I'll do a little more functionality on that, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This got done and is now merged to this PR.



@LicenseCheckerRegistry.register_checker('scan2-pipeline')
class Scan2PipelineLicenseChecker(ParkLabGplPipelineLicenseChecker):
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why this needs a separate class? Is this because it uses mixed software not living under one language?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We only have this one worked case of someone new working on things, but my definite sense from the experience is that this is one of those places where exceptions are the most likely. Every now and then you can make exceptions on a broad basis, like for docutils, because it's simply the nature of docutils that people mostly use those at dev time. But for other libraries, the thing is that you only know you can make an exception if the use is conforming because of how that particular repo uses something, like we know we only use it in some maintenance script and it's not part of the core library that gets delivered to pypi, or something like that. So I can't put that kind of exception in the main classes. But there could be some other place these are kept. Maybe someplace maintained by an employer or a corporate division (in our case dbmi or hms).

@netsettler netsettler merged commit 6aad0b4 into master Sep 29, 2023
4 checks passed
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.

3 participants