Skip to content

Application

Module for Application class

Classes

Application

Application

Application for running command-line

Source code in decoimpact\business\application.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Application:
    """Application for running command-line"""

    def __init__(
        self,
        logger: ILogger,
        da_layer: IDataAccessLayer,
        model_builder: IModelBuilder,
    ):
        """Creates an application based on provided logger, data-access layer
        and model builder

        Args:
            logger (ILogger): Logger that takes care of logging
            da_layer (IDataAccessLayer): data-access layer for reading/writing
            model_builder (IModelBuilder): builder for creating a model based on
            IModelData
        """
        self._logger = logger
        self._da_layer = da_layer
        self._model_builder = model_builder

    def run(self, input_path: Path):
        """Runs application

        Args:
            input_path (Path): path to input file
        """

        model_data: IModelData = self._da_layer.read_input_file(input_path)
        model = self._model_builder.build_model(model_data)

        _ModelRunner.run_model(model, self._logger)

        if model.status == _ModelStatus.FINALIZED:
            self._da_layer.write_output_file(
                model.output_dataset, model_data.output_path
            )

__init__(logger: ILogger, da_layer: IDataAccessLayer, model_builder: IModelBuilder)

Creates an application based on provided logger, data-access layer and model builder

Parameters:

Name Type Description Default
logger ILogger

Logger that takes care of logging

required
da_layer IDataAccessLayer

data-access layer for reading/writing

required
model_builder IModelBuilder

builder for creating a model based on

required
Source code in decoimpact\business\application.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def __init__(
    self,
    logger: ILogger,
    da_layer: IDataAccessLayer,
    model_builder: IModelBuilder,
):
    """Creates an application based on provided logger, data-access layer
    and model builder

    Args:
        logger (ILogger): Logger that takes care of logging
        da_layer (IDataAccessLayer): data-access layer for reading/writing
        model_builder (IModelBuilder): builder for creating a model based on
        IModelData
    """
    self._logger = logger
    self._da_layer = da_layer
    self._model_builder = model_builder

run(input_path: Path)

Runs application

Parameters:

Name Type Description Default
input_path Path

path to input file

required
Source code in decoimpact\business\application.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def run(self, input_path: Path):
    """Runs application

    Args:
        input_path (Path): path to input file
    """

    model_data: IModelData = self._da_layer.read_input_file(input_path)
    model = self._model_builder.build_model(model_data)

    _ModelRunner.run_model(model, self._logger)

    if model.status == _ModelStatus.FINALIZED:
        self._da_layer.write_output_file(
            model.output_dataset, model_data.output_path
        )