Replies: 2 comments 1 reply
-
We have some of this, see, e.g., https://github.com/watertap-org/watertap/blob/main/watertap/unit_models/__init__.py. from watertap.unit_models import ReverseOsmosis0D We should probably do something similar for the property models. The That said, I'm not sure how much we should put in the top-level. I think it's useful to have unit models and property packages in different places, for example. |
Beta Was this translation helpful? Give feedback.
-
I don't think I have enough experience with the WaterTAP API to have an informed opinion on the pros and cons of the ergonomics/DX aspects of this, but I thought I should mention that in WaterTAP, because of the IDAES API, there's a significant amount of import-time side effects. For many reasons, I personally think this is in abstract not ideal (e.g. I suspect is also the reason why the pytest collection phase takes several seconds), but practically speaking, getting rid of this would most likely be a huge undertaking across the entire IDAES ecosystem. So, the situation being what it is, pulling too many sub-packages into the top-level # in watertap/unit_models.py
from .reverse_osmosis import ReverseOsmosis0D
import watertap
for obj in [ReverseOsmosis0D]:
setattr(watertap, obj.__name__, obj)
del watertap but I'm not sure if (A) this would work reliably, and (B) the payoff would be worth the added magic-ness (for one, it would probably stump static analyzers such as pylint). |
Beta Was this translation helpful? Give feedback.
-
WaterTAP has long import statements for getting modules and functions from the package. For example, the statement for importing the ReverseOsmosis0D model is
I suspect this is a bad habit taken from IDAES which has import statements such as:
Is there a reason why relative imports can't be used in the watertap package to make these imports more concise? Such an implementation would allow a single statement to be used for importing watertap features as shown below.
Using a single import would eliminate the need for multiple imports.
Beta Was this translation helpful? Give feedback.
All reactions