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
As a developer want a clear and homogeneous import style in the library
document in CODING_RULES.md styles A. and B. are the prefered coding style for imports + remind import order
update the library to match these styles (cases 1. 2. 3. except optimizers.declearn that seems to be purposely written as a submodule)
See details below
We currently have a lack of homogeneity in the way we do imports from fedbiomed.
In the majority of cases we do:
A. when importing from a different module (including a submodule) use full path and "public" file names (not starting with _) to use the module's __init__.py eg
# a file not in the `logger` module
from fedbiomed.common.logger import logger
B. when importing from same module, use relative path and private file eg
# a file in fedbiomed.common.data
from ._torch_data_manager import TorchDataManager
Styles A. and B. look fine IMO, but we maybe lack a written trace in CODING_RULES.md
The thing is that we sometimes have different import styles:
using full path for import from same module eg
# a file in fedbiomed.researcher.federated_workflows
from fedbiomed.researcher.federated_workflows._federated_workflow \
import exp_exceptions, FederatedWorkflow
using public files for module files when we probably intend to use private file (aggregator, strategy) eg
# in strategy/__init__.py => config to import as strategy.Strategy
__all__ = [
"DefaultStrategy",
"Strategy",
]
# but file is named strategy/strategy.py to import as strategy.strategy.Strategy
... and we use sometimes as submodules, sometimes not.
specific case of fedbiomed.common.optimizers. Seems to be a mix of intended submodule (declearn.py) and un intended one (generic_optimizers.pyoptimizers.py)
Also regarding import orders we should always use:
1 - builtins
2 - third party
3 - from library source (from fedbiomed)
4 - and from module directory like from ._module
The text was updated successfully, but these errors were encountered:
mvesin
added
the
candidate
an individual developer submits a work request to the team (extension proposal, bug, other request)
label
Mar 26, 2024
As a developer want a clear and homogeneous import style in the library
CODING_RULES.md
styles A. and B. are the prefered coding style for imports + remind import orderoptimizers.declearn
that seems to be purposely written as a submodule)See details below
We currently have a lack of homogeneity in the way we do imports from fedbiomed.
In the majority of cases we do:
A. when importing from a different module (including a submodule) use full path and "public" file names (not starting with
_
) to use the module's__init__.py
egB. when importing from same module, use relative path and private file eg
Styles A. and B. look fine IMO, but we maybe lack a written trace in
CODING_RULES.md
The thing is that we sometimes have different import styles:
... and we use sometimes as submodules, sometimes not.
fedbiomed.common.optimizers
. Seems to be a mix of intended submodule (declearn.py
) and un intended one (generic_optimizers.py
optimizers.py
)Also regarding import orders we should always use:
1 - builtins
2 - third party
3 - from library source (
from fedbiomed
)4 - and from module directory like
from ._module
The text was updated successfully, but these errors were encountered: