Test Optional Dependencies#3892
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3892 +/- ##
===========================================
- Coverage 99.60% 99.60% -0.01%
===========================================
Files 259 259
Lines 21273 21268 -5
===========================================
- Hits 21189 21184 -5
Misses 84 84 ☔ View full report in Codecov by Sentry. |
agriyakhetarpal
left a comment
There was a problem hiding this comment.
Thanks, @lorenzofavaro – please do not mind the earlier, hasty review that I had put in. This looks good to me barring a few required changes. Some of them, such as those for refining CI can be considered for future PRs, not this one.
agriyakhetarpal
left a comment
There was a problem hiding this comment.
This looks great @lorenzofavaro, thank you! Approving from my end with one small comment. If no one has any additional comments, we can merge.
|
@all-contributors please add @lorenzofavaro for code, tests |
|
I've put up a pull request to add @lorenzofavaro! 🎉 |
* Remove anytree test * Make pandas required * Add test for optional dependencies * Add test pybamm import * Add test job * Remove comments * Rename job * Change exception type * Filter regex (dev&docs extra) * Clarify docstrings * Clarify error message * Remove test runner * Reformulate docstrings * Update changelog and documentation * Remove test module * Remove workflows * Refactor tests * Set package dynamically * Fix comment * Set conditional dependency --------- Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com> Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Description
This PR adds a test module for optional dependencies just for the core version of PyBaMM.
Important changes made:
test_import_optional_dependency(it's a required dependency, not an optional one).pandasa required dependency. It is actually installed along withxarray(currently a required dependency).To verify it:
importlib.metadata('pybamm'). Since the core version ofpybammalso installs it, the test to check that it does not contain optional dependencies would fail.TestDependencies.test_optional_dependenciesas implemented, does not use the functionimport_optional_dependency* and conceptually does not verify that a unit function is working correctly. It is checking that in the core version ofpybammwe are not installing more dependencies than we expect. Moreover, it does not have to be inside a module with filenametest_*because it would always be executed in any test session. Please, tell me what you think about this and if you suggest any alternatives.test_on_push.ymlworkflow that launch it with just the corepybamminstallation.*If I'm not wrong, we cannot use
import_optional_dependencybecause distribution packages extracted fromimportlib.metadatado not necessarily have a 1:1 mapping with import packages, as per documentation:Fixes #3865
Type of change
Key checklist:
$ pre-commit run(or$ nox -s pre-commit)$ python run-tests.py --all(or$ nox -s tests)$ python run-tests.py --doctest(or$ nox -s doctests)