Add easy-to-use dependency checkers and module inspection - #92
Add easy-to-use dependency checkers and module inspection#92timbernat wants to merge 26 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR introduces a small mupt.mutils.imports utility subpackage to (a) check for optional dependencies without importing them and (b) inspect modules/packages and access package-shipped resources, along with tests and packaged test data to support these behaviors.
Changes:
- Added dependency-checking utilities (
module_installed,modules_installed,@requires_modules) and a custom missing-dependency exception. - Added module/package inspection helpers and package-resource path helpers.
- Added pytest coverage for new functionality and included
mupt.tests.dataas package data for resource-loading tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds setuptools package-data config so test resources under mupt.tests.data are included. |
| mupt/mutils/imports/init.py | Introduces the new mutils.imports subpackage namespace. |
| mupt/mutils/imports/dependencies.py | Implements dependency presence checks, decorator enforcement, and a custom exception. |
| mupt/mutils/imports/inspection.py | Implements module/package inspection helpers (and calling-module lookup). |
| mupt/mutils/imports/names.py | Adds helpers for generating module name/label components. |
| mupt/mutils/imports/resources.py | Implements helpers for locating resources within a package. |
| mupt/tests/mutils/imports/init.py | Adds tests package init for the new test suite. |
| mupt/tests/mutils/imports/test_dependencies.py | Adds tests for dependency checking and decorator behavior. |
| mupt/tests/mutils/imports/test_inspection.py | Adds tests for module/package inspection behavior. |
| mupt/tests/mutils/imports/test_resources.py | Adds tests for package resource fetching using packaged test data. |
| mupt/tests/data/init.py | Defines mupt.tests.data as an importable package for resource tests. |
| mupt/tests/data/sample.dat | Sample packaged resource file used by tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…string to 'ordinary' string
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@dwhswenson Poking for review when you have time; less urgent, but does streamline integration PRs going forward. For some reason, I don't see an option to run tests thru CI on this PR, and rerunning the Action hangs indefinitely. Any idea what's going on?
|

Description
Many places in current and planned MuPT code will require specialize and potentially expensive-to-import non-stdlib dependencies, e.g.:
openff-toolkitmbuildrdkitpolymerizeitGiven the modular nature of the library, it would be unreasonable to ship every external dependency from every subpackage as the base set of required dependencies for mupt. Instead, it is desirable to provide mechanisms for contributors to declare dependencies up-front and provide callers with more targeted warnings and installation instructions when missing dependencies are encountered.
Further, tools for inspecting the presence and contents of other libraries or other even subpackages of
muptwould be desirable for enhancing the developer experience. Use cases include loading pre-compiled data for unit testing or skipping tests (rather than failing them) if certain dependencies are missing,Todos
Notable points that this PR has either accomplished or will accomplish.
@requires-type decorator to pre-declare dependencies needed for function or class definitionsQuestions
Status