Steps
Creating Steps
Creating custom steps for unique tasks
The core set of Steps provided by Patched are designed to cover a wide range of common tasks in software development. However, there are always unique tasks that require custom steps. Patched allows you to create custom steps to automate these tasks.
Dashboard
Only available to Pro and Enterprise users
1
Navigate
In the patchflow builder’s Steps sidebar, click the
Add Step
icon next to the search box.2
Describe
Describe the Step you wish to create in plain text, and provide the input and output schema.
3
Review
Review the generated code for the step and modify it as needed.
4
Validate
Validate the step by providing a sample input and clicking the
Validate
button.5
Save
Once the step is validated, click the
Save
button. The step will now be available in the Steps sidebar for use in patchflows.CLI
1
Fork
Fork the patchwork template repository to your machine.
2
Directory
Create a new folder for the step in the
patchwork/steps
directory with StepName
.3
Step File
Create a file named
StepName.py
in the newly created directory. Any additional files required for the step should be placed in the same folder.4
Code
Implement the step logic in the StepName.py
file. The step should inherit from the Step
class provided by Patched. The StepName
class is expected to have two methods:
- init: The constructor of the class. It should accept an inputs dictionary as an argument. This dictionary contains the input data for the step. Checking of the presence and validity of the input data should be done here.
- run: The main method of the class. This method should contain the logic of the step and return a dictionary with the results.
5
Initialize
Update patchwork/steps/init.py to include the new step in the list of available steps.
Below is an example of a custom step that takes two inputs and returns an output. For more details, view the Patchwork CLI documentation.
Example
Path: patchwork/steps/RunExample/RunExample.py
from patchwork.step import Step
class RunExample(Step):
required_keys = ['input1', 'input2']
def __init__(self, inputs):
super().__init__(inputs)
for key in self.required_keys:
if key not in inputs:
raise ValueError(f"Missing required input: {key}")
self.input1 = inputs['input1']
self.input2 = inputs['input2']
def run(self) -> dict:
return {
'output1': "example output",
}
Path: patchwork/steps/__init__.py
from .RunExample.RunExample import RunExample
__all__ = [
...
'RunExample',
]