4dn-dcic / utils

various util modules shared amongst several projects in our organization
MIT License
4 stars 1 forks source link

License checker changes to make license support data-driven #287

Closed netsettler closed 11 months ago

netsettler commented 11 months ago

Branch to branch PR following up on Will's comments suggesting this should be data-driven. There was a bit more complexity here than I expected, but the added flexibility of not having to define a new class in order to get new behavior at the command line seems really useful.

This makes it so that if you name a policy, whatever, that isn't in the standard directory, you can specify a directory to find it in. It'll try to load whatever.jsonc.

coveralls commented 11 months ago

Pull Request Test Coverage Report for Build 6351257396


Changes Missing Coverage Covered Lines Changed/Added Lines %
dcicutils/license_utils.py 235 306 76.8%
<!-- Total: 249 320 77.81% -->
Totals Coverage Status
Change from base Build 6240767306: -0.07%
Covered Lines: 8473
Relevant Lines: 10906

💛 - Coveralls
netsettler commented 11 months ago

I made a last-minute change to remove exec (in the main library) and eval (in testing). Instead, the loader sets everything up and registers it and there are a number of assignments at the end of the file to look up those classes and put them into variables so that they can be used by other modules. The dynamic loader does not need to do this assignment, so that removes questions about polluting the programmatic namespace.

In the case of autoload, the depended-upon libraries are referenced by object, not by name, so there is no issue. The programmatic class names are just for imports by unit tests, so as long as they’re in place by the end of the module load, nothing cares about how they get there.

This passes on GA, so I'll merge it down to its main PR and then merge that.