Design of Step / builder and models_distribution
[temporary, I did accidentally Ctrl+Enter
when writing]
I want to keep a track of this thought about the design of Step
class for later discussion.
Context
Some variables like the tile list are passed to steps by classmethods like set_models_spatial_information
like at the beginning of build_steps
method:
Step.set_models_spatial_information(self.tiles, {})
# which does later
cls.tiles = tiles
Some other are passed directly as class variables like at the end of models_distribution
method:
i2_classification.py#L151-L152
Step.spatial_models_distribution_classify = regions_classif_distrib
But some other similar variables like the output_path
are passed to steps children classes' constructors through the path of the config file:
class SensorsPreprocess(iota2_step.Step):
def __init__(self, cfg, cfg_resources_file, workingDirectory=None):
self.output_path = rcf.read_config_file(self.cfg).getParam('chain', 'output_path')
The models_distribution
builder method does a job similar to the set_models_spatial_information
classmethod in the sense that it's putting stuff into the Step
class. It is duplicated for in the classification and obia builders and I might also need it for regression builder.
models_distribution
a Step
classmethod
Idea 1: make As I understand it and as it is now, models_distribution
should not be a builder method, but rather a Step
classmethod since it does not modify the builder but modifies the Step
class.
Idea 2: we should be more clear about limit between class and instance attributes
I know that some parameters are known since the chain start (like the ones in the config file) and therefore should only be read once (see #457). But currently, some are passed as Step
class arguments (like tiles) and other are passed through the config file path. The limit is not clear to me.