smdogroup / tacs

Finite-element library for analysis and adjoint-based gradient evaluation
Apache License 2.0
108 stars 75 forks source link

Request: Add ESP/CAPS version check to caps2tacs tests #233

Closed A-CGray closed 1 year ago

A-CGray commented 1 year ago

We're having issues updating the version of TACS used in our docker images because we currently use ESP120, which seems to be incompatible with caps2tacs:

Information: Dynamic Loader Error for tacsAIM.so
              tacsAIM.so: cannot open shared object file: No such file or directory
 EGADS Info: 0 Objects, 0 Reference in Use (of 0) at Close!
./tests/integration_tests/test_caps_thick_derivatives.py:TestCaps2TacsSizing.test_thickness_derivatives  ... FAIL (00:00:0.03, 252 MB)
Traceback (most recent call last):
  File "/home/***/repos/tacs/./tests/integration_tests/test_caps_thick_derivatives.py", line 31, in test_thickness_derivatives
    tacs_model = caps2tacs.TacsModel.build(
  File "/home/***/repos/tacs/tacs/caps2tacs/tacs_model.py", line 66, in build
    tacs_aim = TacsAim(caps_problem, comm)
  File "/home/***/repos/tacs/tacs/caps2tacs/tacs_aim.py", line 34, in __init__
    self._build_aim(caps_problem)
  File "/home/***/repos/tacs/tacs/caps2tacs/proc_decorator.py", line 12, in wrapped_method
    return method(self, *args, **kwargs)
  File "/home/***/repos/tacs/tacs/caps2tacs/tacs_aim.py", line 57, in _build_aim
    self._aim = caps_problem.analysis.create(aim="tacsAIM", name="tacs")
  File "/home/***/packages/ESP120/EngSketchPad/pyESP/pyCAPS/problem.py", line 2779, in create
    analysisObj = self._problemObj.makeAnalysis(aim,
  File "/home/***/packages/ESP120/EngSketchPad/pyESP/pyCAPS/caps.py", line 1705, in makeAnalysis
    _raiseStatus(stat, msg=msg, errors=capsErrs(nErr, errs))
  File "/home/***/packages/ESP120/EngSketchPad/pyESP/pyCAPS/caps.py", line 758, in _raiseStatus
    raise CAPSError(status, msg=msg, errors=errors)
pyCAPS.caps.CAPSError: EGADS_NULLOBJ: Failed to make AIM 'tacsAIM' with name 'tacs':

Would it be possible to add a check, either to the caps2tacs tests or to the module itself, so that the caps2tacs tests will be skipped not only if CAPS is not installed, but also if the CAPS version is incompatible with caps2tacs?

sean-engelstad commented 1 year ago

I'll see what I can do, they don't have ESP/CAPS setup as a python package with setup.py. I may involve Marshall Galbraith in this

A-CGray commented 1 year ago

I guess another way to test if the correct version of CAPS is available would just be to try creating a tacsAIM inside a try-except statement

sean-engelstad commented 1 year ago

Yeah that sounds like a good solution

timryanb commented 1 year ago

I'm not sure how much overhead creating a tacsAIM is, but a better solution would probably be to use a hasattrcheck for the module so that things don't get needlessly evaluated on every import

sean-engelstad commented 1 year ago

@A-CGray is it just the unittests that are causing a problem? Or the python package. @timryanb because if it's just the two caps unittests, I don't think this is much overhead

A-CGray commented 1 year ago

@A-CGray is it just the unittests that are causing a problem? Or the python package. @timryanb because if it's just the two caps unittests, I don't think this is much overhead

Our issues are just due to the unit tests. It'd be nice if the check was cheap enough to do whenever you try and import caps2tacs, but if that's going to be much more challenging to implement then just checking in the unit tests will be fine.

timryanb commented 1 year ago

@sean-engelstad having this overhead in the caps unit test should be fine for now. But Marshall is going to have to add a way to programmatically inspect the version number of CAPS (if the capability doesn't exist). It's a requirement for integrating it with other tools that depend on it

sean-engelstad commented 1 year ago

Actually @A-CGray, you should be able to use caps2tacs with ESP 1.20, but the derivative accuracy won't be as good for structural shape variables since Marshall and I improved the tacsAIM since then. ESP 1.20 is a prebuilt, but not all of the AIM modules are compiled, including the tacsAIM. Your error indicates that you are missing the 'tacsAIM.so' file and need to run make in the directory EngSketchPad/src/CAPS/aim/tacs. This will create the tacsAIM.so file in the EngSketchPad/lib directory.

I could create a try-catch block for creating the tacsAIM and then indicate to the user that they have not built ESP/CAPS and the tacsAIM properly. However, I would prefer for ESP/CAPS to throw the error.

A-CGray commented 1 year ago

ok, we actually managed to update our docker images to ESP122 with a lot less trouble than we were expecting, so this is not an issue any more. Thanks for your efforts anyway