diff --git a/docs/_source/customise.rst b/docs/_source/customise.rst index e4ea7f6ec596646e579be787635763d79d6b6946..24b9492fc3953431669510944d054847911d8ae6 100644 --- a/docs/_source/customise.rst +++ b/docs/_source/customise.rst @@ -45,62 +45,6 @@ The output of running this default workflow will be structured like the followin INFO: PostProcessing finished after 00:01:37 (hh:mm:ss) INFO: mlair finished after 00:04:05 (hh:mm:ss) -Customised Run Module and Workflow ----------------------------------- - -It is possible to create new custom run modules. A custom run module is required to inherit from the base class -:py:`RunEnvironment` and to hold the constructor method :py:`__init__()`. This method has to execute the module on call. -In the following example, this is done by using the :py:`_run()` method that is called by the initialiser. It is -possible to parse arguments to the custom run module as shown. - -.. code-block:: python - - import mlair - import logging - - class CustomStage(mlair.RunEnvironment): - """A custom MLAir stage for demonstration.""" - - def __init__(self, test_string): - super().__init__() # always call super init method - self._run(test_string) # call a class method - - def _run(self, test_string): - logging.info("Just running a custom stage.") - logging.info("test_string = " + test_string) - epochs = self.data_store.get("epochs") - logging.info("epochs = " + str(epochs)) - - -If a custom run module is defined, it is required to adjust the workflow. For this, you need to load the empty -:py:`Workflow` class and add each run module that is required. The order of adding modules defines the order of -execution if running the workflow. - -.. code-block:: python - - # create your custom MLAir workflow - CustomWorkflow = mlair.Workflow() - # provide stages without initialisation - CustomWorkflow.add(mlair.ExperimentSetup, epochs=128) - # add also keyword arguments for a specific stage - CustomWorkflow.add(CustomStage, test_string="Hello World") - # finally execute custom workflow in order of adding - CustomWorkflow.run() - -The output will look like: - -.. code-block:: - - INFO: mlair started - ... - INFO: ExperimentSetup finished after 00:00:12 (hh:mm:ss) - INFO: CustomStage started - INFO: Just running a custom stage. - INFO: test_string = Hello World - INFO: epochs = 128 - INFO: CustomStage finished after 00:00:01 (hh:mm:ss) - INFO: mlair finished after 00:00:13 (hh:mm:ss) - Custom Model ------------ @@ -303,3 +247,60 @@ Custom Data Handler method is modified (see previous bullet). * (optionally) Overwrite the base class :py:`self.get_coordinates()` method to return coordinates as dictionary with keys *lon* and *lat*. + + +Customised Run Module and Workflow +---------------------------------- + +It is possible to create new custom run modules. A custom run module is required to inherit from the base class +:py:`RunEnvironment` and to hold the constructor method :py:`__init__()`. This method has to execute the module on call. +In the following example, this is done by using the :py:`_run()` method that is called by the initialiser. It is +possible to parse arguments to the custom run module as shown. + +.. code-block:: python + + import mlair + import logging + + class CustomStage(mlair.RunEnvironment): + """A custom MLAir stage for demonstration.""" + + def __init__(self, test_string): + super().__init__() # always call super init method + self._run(test_string) # call a class method + + def _run(self, test_string): + logging.info("Just running a custom stage.") + logging.info("test_string = " + test_string) + epochs = self.data_store.get("epochs") + logging.info("epochs = " + str(epochs)) + + +If a custom run module is defined, it is required to adjust the workflow. For this, you need to load the empty +:py:`Workflow` class and add each run module that is required. The order of adding modules defines the order of +execution if running the workflow. + +.. code-block:: python + + # create your custom MLAir workflow + CustomWorkflow = mlair.Workflow() + # provide stages without initialisation + CustomWorkflow.add(mlair.ExperimentSetup, epochs=128) + # add also keyword arguments for a specific stage + CustomWorkflow.add(CustomStage, test_string="Hello World") + # finally execute custom workflow in order of adding + CustomWorkflow.run() + +The output will look like: + +.. code-block:: + + INFO: mlair started + ... + INFO: ExperimentSetup finished after 00:00:12 (hh:mm:ss) + INFO: CustomStage started + INFO: Just running a custom stage. + INFO: test_string = Hello World + INFO: epochs = 128 + INFO: CustomStage finished after 00:00:01 (hh:mm:ss) + INFO: mlair finished after 00:00:13 (hh:mm:ss) \ No newline at end of file diff --git a/docs/_source/index.rst b/docs/_source/index.rst index 89d7e5f73c00a04d29042719a39d931a461a3abb..a60643042eb750b6a21fa0f638797002be7675c4 100644 --- a/docs/_source/index.rst +++ b/docs/_source/index.rst @@ -13,7 +13,6 @@ Welcome to MLAir's documentation! get-started customise - api Indices and tables