Skip to content
Snippets Groups Projects
Commit 5f47e92b authored by lukas leufen's avatar lukas leufen
Browse files

reordered docs on customisation

parent ba38f228
No related branches found
No related tags found
3 merge requests!146Develop,!145Resolve "new release v0.12.0",!138Resolve "Advanced Documentation"
Pipeline #45963 passed with warnings
...@@ -45,62 +45,6 @@ The output of running this default workflow will be structured like the followin ...@@ -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: PostProcessing finished after 00:01:37 (hh:mm:ss)
INFO: mlair finished after 00:04:05 (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 Custom Model
------------ ------------
...@@ -303,3 +247,60 @@ Custom Data Handler ...@@ -303,3 +247,60 @@ Custom Data Handler
method is modified (see previous bullet). method is modified (see previous bullet).
* (optionally) Overwrite the base class :py:`self.get_coordinates()` method to return coordinates as dictionary with * (optionally) Overwrite the base class :py:`self.get_coordinates()` method to return coordinates as dictionary with
keys *lon* and *lat*. 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
...@@ -13,7 +13,6 @@ Welcome to MLAir's documentation! ...@@ -13,7 +13,6 @@ Welcome to MLAir's documentation!
get-started get-started
customise customise
api
Indices and tables Indices and tables
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment