AllCode - organise import structure using __init__.py files
Description
NOTE: We should think about doing towards the end, or at a point when we don't have active branches being worked on. It will have an impact across all the modules. Ideal scenario is we decide on the structure, make a single branch and change it, and then upload this to development. Future branches will then use this new structure.
Currently when importing packages it can become quite complex to import a certain class or function. This is due to the folder structure of neptoon
.
e.g.
from neptoon.configuration.configuration_input import ConfigurationManager
from neptoon.ancillary_data_collection.nmdb_data_collection import (
NMDBDataAttacher,
)
from neptoon.neutron_correction.neutron_correction import (
CorrectionBuilder,
CorrectionFactory,
CorrectionType,
CorrectionTheory,
CorrectNeutrons,
)
from neptoon.data_management.data_validation_tables import (
FormatCheck,
)
from neptoon.data_management.site_information import SiteInformation
from neptoon.quality_assesment.quality_assesment import (
QualityAssessmentFlagBuilder,
DataQualityAssessor,
)
I don't think we should change the folder structure to change this. A better method might look like:
from neptoon.configuration import ConfigurationManager
from neptoon.data_management import FormatCheck
from neptoon.quality_assessment import QualityAssessmentFlagBuilder
or maybe even:
from neptoon import ConfigurationManager
from neptoon import CRNSDataHub
We should decide on the structure, some we might want to flatten and some we might want to remain stacked.
Expected Behavior
Better import experience for a user
Current Behavior
Complicated import system for a user
Proposed Solution
We can expose packages using the __init__.py
files. For example to have expose ConfigurationManager
from neptoon.configuration
we can change the __init__.py
file in the neptoon/configuration
folder to:
from ..configuration.configuration_input import ConfigurationManager
This allows a user to import like this:
from neptoon.configuration import ConfigurationManager
Acceptance Criteria
-
Agreement on intuitive place for key packages -
Cleaner looking imports