mdolab / pygeo

pyGeo provides geometric design variables and constraints suitable for gradient-based optimization.
https://mdolab-pygeo.readthedocs-hosted.com/en/latest/?badge=latest
Apache License 2.0
124 stars 55 forks source link

DVGeometryCST import fails silently due to dependency not described in the docs #176

Closed bbrelje closed 1 year ago

bbrelje commented 1 year ago

Description

If a user does not have prefoil installed, importing DVGeometryCST at pygeo init will fail silently and produce a "ImportError: cannot import name 'DVGeometryCST' from 'pygeo'" error message when the module is actually used. This hides the underlying cause, which is that prefoil is not installed. The prefoil dependency is not described, as far as I can tell, anywhere in the docs or installation instructions.

Steps to reproduce issue

Install pygeo 1.12.2 on ubuntu-like system Try to use DVGeometryCST (e.g. from cmplxfoil)

Current behavior

Error message hides reason for import error

Expected behavior

Error message ought to describe the missing dependency Docs ought to describe prefoil depedency

Code versions

sseraj commented 1 year ago

I think @lamkina was planning on addressing a similar issue related to silent import errors

lamkina commented 1 year ago

Yes I have been working on a fix for this issue. Typically the import error is thrown properly with a descriptive message at the lowest level where it's used, but then as we propogate the import statements up through the layers it gets silenced. My plan is to pass specific error codes that tell downstream import statements when to throw/not throw certain errors.