Cron workflow
CronWorkflow
CronWorkflow allows a user to run a Workflow on a recurring basis.
Note
Hera’s CronWorkflow is a subclass of Workflow which means certain fields are renamed
for compatibility, see cron_suspend and cron_status which are different from the Argo
spec. See CronWorkflowSpec for more details.
Source code in src/hera/workflows/cron_workflow.py
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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
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 CronWorkflow on the Argo cluster.
Source code in src/hera/workflows/cron_workflow.py
async_get
Attempts to get a cron workflow based on the parameters of this template e.g. name + namespace.
Source code in src/hera/workflows/cron_workflow.py
async_lint
Lints the CronWorkflow using the Argo cluster.
Source code in src/hera/workflows/cron_workflow.py
async_update
Attempts to perform a workflow template update based on the parameters of this template.
Note that 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/cron_workflow.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 CronWorkflow and its components into an Argo schema CronWorkflow object.
Source code in src/hera/workflows/cron_workflow.py
create
Creates the CronWorkflow on the Argo cluster.
Source code in src/hera/workflows/cron_workflow.py
from_dict
from_dict(model_dict: Dict) -> ModelMapperMixin
Create a CronWorkflow from a CronWorkflow contained in a dict.
Examples:
>>> my_cron_workflow = CronWorkflow(name="my-cron-wf")
>>> my_cron_workflow == CronWorkflow.from_dict(my_cron_workflow.to_dict())
True
Source code in src/hera/workflows/cron_workflow.py
from_file
Create a CronWorkflow from a CronWorkflow contained in a YAML file.
Examples:
Source code in src/hera/workflows/cron_workflow.py
from_yaml
from_yaml(yaml_str: str) -> ModelMapperMixin
Create a CronWorkflow from a CronWorkflow contained in a YAML string.
Examples:
Source code in src/hera/workflows/cron_workflow.py
get
Attempts to get a cron workflow based on the parameters of this template e.g. name + namespace.
Source code in src/hera/workflows/cron_workflow.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/cron_workflow.py
lint
Lints the CronWorkflow using the Argo cluster.
Source code in src/hera/workflows/cron_workflow.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 workflow template update based on the parameters of this template.
Note that 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/cron_workflow.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.