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

Fixing import errors, adding isort, cleaned up regression tests, and added unit tests for new import procedure. #180

Merged
merged 6 commits into from
Feb 2, 2023

Conversation

lamkina
Copy link
Contributor

@lamkina lamkina commented Jan 31, 2023

Purpose

This PR adds the following features:

  1. Improved import handling: The imports in DVGeometryESP, DVGeometryVSP, DVGeometryMulti, and DVGeometryCST all have optional dependencies required to function properly. Previously, pyGeo suppressed the import errors leaving users confused as to why their code wasn't working with pyGeo. In this PR, the import suppression was replaced in favor of logic control in the import statements that will throw an error if the user tries to initialize any of the classes listed above. Using this new procedure, the correct errors will be thrown with descriptions when the user tries to use one of the classes, without suppression.
  2. Added iSort: All of the import statements have been cleaned using the iSort package. To properly format the imports with iSort, make a link from the .isort.cfg file here to the root of the the pyGeo repo. I added iSort the the azure pipeline yaml file as well.
  3. Unit Test Cleaning: As part of the changes to imports, I also fixed the inconsistencies with the regression tests and standardized how we handle imports in the tests.
  4. Additional Unit Tests: I added unit tests that test the new import handling logic in the four DVGeometry classes listed above. These tests do not require the optional dependencies because they use mock modules instead of the actual modules.

This PR will close issue #176

Expected time until merged

This is a quality of life PR, so not urgent. I would estimate a few weeks or less to merge.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

To test the new changes, run the new unit tests with either pyTest or testflo.

Checklist

  • I have run flake8 and black to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@lamkina lamkina requested review from hajdik and sseraj January 31, 2023 01:55
@lamkina lamkina requested a review from a team as a code owner January 31, 2023 01:55
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Merging #180 (1740ed3) into main (94909eb) will increase coverage by 0.12%.
The diff coverage is 95.95%.

@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
+ Coverage   64.61%   64.74%   +0.12%     
==========================================
  Files          47       47              
  Lines       11954    11941      -13     
==========================================
+ Hits         7724     7731       +7     
+ Misses       4230     4210      -20     
Impacted Files Coverage Δ
pygeo/constraints/circularityConstraint.py 79.71% <ø> (ø)
pygeo/constraints/colinearityConstraint.py 85.91% <ø> (ø)
pygeo/constraints/gearPostConstraint.py 16.36% <ø> (ø)
pygeo/constraints/locationConstraint.py 74.35% <ø> (ø)
pygeo/constraints/planarityConstraint.py 82.85% <ø> (ø)
pygeo/constraints/radiusConstraint.py 80.00% <ø> (ø)
pygeo/constraints/thicknessConstraint.py 82.50% <ø> (ø)
pygeo/geo_utils/bilinear_map.py 8.57% <ø> (ø)
pygeo/geo_utils/ffd_generation.py 83.89% <ø> (ø)
pygeo/geo_utils/file_io.py 37.83% <ø> (ø)
... and 35 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@sseraj sseraj left a comment

Choose a reason for hiding this comment

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

Nice work, but it needs some changes for the test skipping to work with DVGeoMulti. I also left some more minor comments, mostly on formatting.

pygeo/parameterization/DVGeoVSP.py Show resolved Hide resolved
pygeo/parameterization/DVGeoVSP.py Show resolved Hide resolved
tests/reg_tests/test_DVConstraints.py Outdated Show resolved Hide resolved
tests/unit_tests/test_import_gaurds.py Outdated Show resolved Hide resolved
tests/unit_tests/test_import_gaurds.py Outdated Show resolved Hide resolved
tests/unit_tests/test_import_gaurds.py Outdated Show resolved Hide resolved
tests/unit_tests/test_import_gaurds.py Outdated Show resolved Hide resolved
tests/reg_tests/test_DVConstraints.py Outdated Show resolved Hide resolved
tests/reg_tests/test_DVGeometryMulti.py Outdated Show resolved Hide resolved
Copy link
Contributor

@marcomangano marcomangano left a comment

Choose a reason for hiding this comment

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

I think the logic for skipping tests on DVcon is not correct, but everything else looks great

tests/unit_tests/test_import_gaurds.py Outdated Show resolved Hide resolved
tests/reg_tests/test_DVConstraints.py Outdated Show resolved Hide resolved

@ignore_warnings
def test__DVGeometryVSP_import_openvsp(self):
with patch.dict(sys.modules, {"openvsp": None}):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is neat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This took me a long time to figure out.

import warnings


def ignore_warnings(test_func):
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you can see my comment above, but this is because numpy is annoying for these tests.

@sseraj sseraj merged commit 1f6a7c3 into mdolab:main Feb 2, 2023
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.

DVGeometryCST import fails silently due to dependency not described in the docs
3 participants