Write a Step
One of the main features of the workflows-manager is the ability to create new workflows by reusing the existing steps.
To create a new step you need to create a new Python file in your project. The file should contain a class that inherits
from the Step class.
The Step class is a base class for all steps. It provides a simple interface to
define the step behavior. The class contains two methods: perform and
configure_logger. The
perform method is the main method that should contain the step logic, it
must be implemented in the child class. The configure_logger
method is used to configure the logger for the step.
You will need the following imports to create a new step:
Here is an example of a simple step that prints a message to the console:
- Register the step with the name
console-output. - Create a new class
ConsoleOutputthat inherits from theStepclass. - Implement the
performmethod that receives a string with message and then prints it to the console. - Print the message to the console.
Configure the logger for the step¶
The configure_logger method is used to configure the logger for
the step. By default, the step is configured to use the parent logger from the workflows-manager. You can override this
method to configure the logger for the step.
Here is an example of a step that configures the logger to print the message to the console:
- Create a new logger with the name
log-messageand configure it. - Use the logger to print the message to the console.