Workflow template
WorkflowTemplate
WorkflowTemplates are definitions of Workflows that live in your namespace in your cluster.
This allows you to create a library of frequently-used templates and reuse them by referencing them from your Workflows.
Source code in src/hera/workflows/workflow_template.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
workflows_service
workflows_service: Optional[
Union[WorkflowsService, AsyncWorkflowsService]
] = None
ModelMapper
Source code in src/hera/workflows/_meta_mixins.py
build_model
build_model(
hera_class: Type[ModelMapperMixin],
hera_obj: ModelMapperMixin,
model: TWorkflow,
) -> TWorkflow
Source code in src/hera/workflows/_meta_mixins.py
async_create
Creates the WorkflowTemplate on the Argo cluster.
Source code in src/hera/workflows/workflow_template.py
async_get
Attempts to get a workflow template based on the parameters of this template e.g. name + namespace.
Source code in src/hera/workflows/workflow_template.py
async_lint
Lints the WorkflowTemplate using the Argo cluster.
Source code in src/hera/workflows/workflow_template.py
async_update
Attempts to perform a template update based on the parameters of this template.
This creates the template if it does not exist. In addition, this performs
a get prior to updating to get the resource version to update in the first place. If you know the template
does not exist ahead of time, it is more efficient to use create() directly to avoid one round trip.
Source code in src/hera/workflows/workflow_template.py
async_wait
async_wait(poll_interval: int = 5) -> TWorkflow
Waits for the Workflow to complete execution.
Parameters
poll_interval: int = 5 The interval in seconds to poll the workflow status.
Source code in src/hera/workflows/workflow.py
build
Builds the WorkflowTemplate and its components into an Argo schema WorkflowTemplate object.
Source code in src/hera/workflows/workflow_template.py
create
Creates the WorkflowTemplate on the Argo cluster.
Source code in src/hera/workflows/workflow_template.py
create_as_workflow
create_as_workflow(
generate_name: Optional[str] = None,
wait: bool = False,
poll_interval: int = 5,
) -> TWorkflow
Run this WorkflowTemplate instantly as a Workflow.
If generate_name is given, the workflow created uses generate_name as a prefix, as per the usual for hera.workflows.Workflow.generate_name. If not given, the WorkflowTemplate’s name will be used, truncated to 57 chars and appended with a hyphen.
Note: this function does not require the WorkflowTemplate to already exist on the cluster
Source code in src/hera/workflows/workflow_template.py
from_dict
from_dict(model_dict: Dict) -> ModelMapperMixin
Create a WorkflowTemplate from a WorkflowTemplate contained in a dict.
Examples:
>>> my_workflow_template = WorkflowTemplate(name="my-wft")
>>> my_workflow_template == WorkflowTemplate.from_dict(my_workflow_template.to_dict())
True
Source code in src/hera/workflows/workflow_template.py
from_file
Create a WorkflowTemplate from a WorkflowTemplate contained in a YAML file.
Examples:
Source code in src/hera/workflows/workflow_template.py
from_yaml
from_yaml(yaml_str: str) -> ModelMapperMixin
Create a WorkflowTemplate from a WorkflowTemplate contained in a YAML string.
Examples:
Source code in src/hera/workflows/workflow_template.py
get
Attempts to get a workflow template based on the parameters of this template e.g. name + namespace.
Source code in src/hera/workflows/workflow_template.py
get_parameter
Attempts to find and return a Parameter of the specified name.
Source code in src/hera/workflows/workflow.py
get_workflow_link
get_workflow_link() -> str
Returns the workflow link for the workflow.
Source code in src/hera/workflows/workflow.py
lint
Lints the WorkflowTemplate using the Argo cluster.
Source code in src/hera/workflows/workflow_template.py
to_dict
to_dict() -> Any
Builds the Workflow as an Argo schema Workflow object and returns it as a dictionary.
to_file
Writes the Workflow as an Argo schema Workflow object to a YAML file and returns the path to the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_directory
|
Union[Path, str]
|
The directory to write the file to. Defaults to the current working directory. |
'.'
|
name
|
str
|
The name of the file to write without the file extension. Defaults to the Workflow’s name or a generated name. |
''
|
*args
|
Additional arguments to pass to |
()
|
|
**kwargs
|
Additional keyword arguments to pass to |
{}
|
Source code in src/hera/workflows/workflow.py
to_yaml
to_yaml(*args, **kwargs) -> str
Builds the Workflow as an Argo schema Workflow object and returns it as yaml string.
Source code in src/hera/workflows/workflow.py
update
Attempts to perform a template update based on the parameters of this template.
This creates the template if it does not exist. In addition, this performs
a get prior to updating to get the resource version to update in the first place. If you know the template
does not exist ahead of time, it is more efficient to use create() directly to avoid one round trip.
Source code in src/hera/workflows/workflow_template.py
wait
wait(poll_interval: int = 5) -> TWorkflow
Waits for the Workflow to complete execution.
Parameters
poll_interval: int = 5 The interval in seconds to poll the workflow status.