fast-aircraft-design / FAST-OAD

FAST-OAD: An open source framework for rapid Overall Aircraft Design
GNU General Public License v3.0
53 stars 26 forks source link

Relevance of global import in submodules #410

Closed esnguyenvan closed 1 year ago

esnguyenvan commented 2 years ago

For example in the component compute VT :

import openmdao.api as om

import fastoad.api as oad
from fastoad.models.geometry.geom_components.vt.components import ComputeVTChords
from fastoad.models.geometry.geom_components.vt.components import ComputeVTClalpha
from fastoad.models.geometry.geom_components.vt.components import ComputeVTDistance
from fastoad.models.geometry.geom_components.vt.components import ComputeVTMAC
from fastoad.models.geometry.geom_components.vt.components import ComputeVTSweep
from fastoad.module_management.service_registry import RegisterSubmodel
from ...constants import SERVICE_FUSELAGE_CNBETA, SERVICE_VERTICAL_TAIL_GEOMETRY

What are the reasons for using global imports while the lower modules ComputeVTChords, etc... are readily available through a relative import?

I imagine a case where someone would like to register a new VT module. Personally, I would start by copying the whole 'vt' folder and register it as a new submodule. I would then modify the lower modules ComputeVTChords, etc... and finally I will have to change from global imports to relative imports for the changes to actually take place. This last step may a be source of confusion if ones expects from a custom module to strictly use the submodules it contains.

christophe-david commented 2 years ago

Agreed. Relative imports are the right thing to do here.

Same applies for wing and horizontal tail.

esnguyenvan commented 2 years ago

I can do the modifications at the same time than takeoff enhancements, which I'm currently working on

christophe-david commented 2 years ago

Actually, I realize that incoming changes in code organisation should make this change unavoidable anyway, so don't bother too much with that.

christophe-david commented 1 year ago

Models have been moved to FAST-OAD_CS25 repo, and imports have been modified BTW.