You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the "old" way of importing applications being deprecated, we now should find a common solution for importing the python scripts
Previously we had to do:
from PEP8:
"Absolute imports are recommended, as they are usually more readable and tend to be better behaved ..."
"However, explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose"
I tried both ways already and suggest (up for discussion the following):
By default I would go for absolute imports, just as PEP8 suggests.
Since however Kratos has a relatively large/complex file structure I would also allow explicit relative imports, if the developer decides to use it, since it does shorten the paths quite a bit (e.g. here)
=> especially when there is a subfolder-structure inside python_scripts (which is now possible and already in use, see CoSimApp and HDF5App) since it can make the paths much shorter
What I would not allow is to use explicit relative imports across directories (e.g. importing from parent directory etc), bcs this becomes really unreadable then example
I also think that explicit relative imports are easy to read for imports from within an application (package).
Personally i am not against navigating back if an import from a parent directory of the same package is made.
However we will implement in #5262 what will be decided here to be Kratos style conform.
@armingeiser@philbucher i do not want to enter in stylistic questions,
nevertheless what i think is really important to achieve is that our importing mechanism becomes more pythonic, in the sense that it follows the standard python rules.
Right now this is not the case due to the manual edit of the python path we do under the hood.
This will be corrected soon and is the thing we must all beware
@KratosMultiphysics/technical-committee promotes the absolute import rather than the relative one due to its clarity and considering that we don't have many imports in each file, so the verbosity wouldn't be a problem.
With the "old" way of importing applications being deprecated, we now should find a common solution for importing the python scripts
Previously we had to do:
now we have several options:
However, what is also possible and where we had several discussions (e.g. here and here) are explicit relative imports:
from PEP8:
"Absolute imports are recommended, as they are usually more readable and tend to be better behaved ..."
"However, explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose"
I tried both ways already and suggest (up for discussion the following):
=> especially when there is a subfolder-structure inside
python_scripts
(which is now possible and already in use, see CoSimApp and HDF5App) since it can make the paths much shorterFYI @armingeiser @adityaghantasala
The text was updated successfully, but these errors were encountered: