prefect.deployments.runner
¶
Objects for creating and configuring deployments for flows using serve
functionality.
Example
import time
from prefect import flow, serve
@flow
def slow_flow(sleep: int = 60):
"Sleepy flow - sleeps the provided amount of time (in seconds)."
time.sleep(sleep)
@flow
def fast_flow():
"Fastest flow this side of the Mississippi."
return
if __name__ == "__main__":
# to_deployment creates RunnerDeployment instances
slow_deploy = slow_flow.to_deployment(name="sleeper", interval=45)
fast_deploy = fast_flow.to_deployment(name="fast")
serve(slow_deploy, fast_deploy)
RunnerDeployment
¶
Bases: BaseModel
A Prefect RunnerDeployment definition, used for specifying and building deployments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
A name for the deployment (required). |
required | |
version |
An optional version for the deployment; defaults to the flow's version |
required | |
description |
An optional description of the deployment; defaults to the flow's description |
required | |
tags |
An optional list of tags to associate with this deployment; note that tags
are used only for organizational purposes. For delegating work to agents,
see |
required | |
schedule |
A schedule to run this deployment on, once registered |
required | |
is_schedule_active |
Whether or not the schedule is active |
required | |
parameters |
A dictionary of parameter values to pass to runs created from this deployment |
required | |
path |
The path to the working directory for the workflow, relative to remote storage or, if stored on a local filesystem, an absolute path |
required | |
entrypoint |
The path to the entrypoint for the workflow, always relative to the
|
required | |
parameter_openapi_schema |
The parameter schema of the flow, including defaults. |
required | |
enforce_parameter_schema |
Whether or not the Prefect API should enforce the parameter schema for this deployment. |
required |
Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/deployments/runner.py
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 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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
apply
async
¶
Registers this deployment with the API and returns the deployment's ID.
Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/deployments/runner.py
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 |
|
from_entrypoint
classmethod
¶
Configure a deployment for a given flow located at a given entrypoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entrypoint |
str
|
The path to a file containing a flow and the name of the flow function in
the format |
required |
name |
str
|
A name for the deployment |
required |
interval |
Optional[Union[int, float, timedelta]]
|
An interval on which to execute the current flow. Accepts either a number or a timedelta object. If a number is given, it will be interpreted as seconds. |
None
|
cron |
Optional[str]
|
A cron schedule of when to execute runs of this flow. |
None
|
rrule |
Optional[str]
|
An rrule schedule of when to execute runs of this flow. |
None
|
schedule |
Optional[SCHEDULE_TYPES]
|
A schedule object of when to execute runs of this flow. Used for advanced scheduling options like timezone. |
None
|
triggers |
Optional[List[DeploymentTrigger]]
|
A list of triggers that should kick of a run of this flow. |
None
|
parameters |
Optional[dict]
|
A dictionary of default parameter values to pass to runs of this flow. |
None
|
description |
Optional[str]
|
A description for the created deployment. Defaults to the flow's description if not provided. |
None
|
tags |
Optional[List[str]]
|
A list of tags to associate with the created deployment for organizational purposes. |
None
|
version |
Optional[str]
|
A version for the created deployment. Defaults to the flow's version. |
None
|
enforce_parameter_schema |
bool
|
Whether or not the Prefect API should enforce the parameter schema for this deployment. |
False
|
Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/deployments/runner.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
from_flow
classmethod
¶
Configure a deployment for a given flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
Flow
|
A flow function to deploy |
required |
name |
str
|
A name for the deployment |
required |
interval |
Optional[Union[int, float, timedelta]]
|
An interval on which to execute the current flow. Accepts either a number or a timedelta object. If a number is given, it will be interpreted as seconds. |
None
|
cron |
Optional[str]
|
A cron schedule of when to execute runs of this flow. |
None
|
rrule |
Optional[str]
|
An rrule schedule of when to execute runs of this flow. |
None
|
schedule |
Optional[SCHEDULE_TYPES]
|
A schedule object of when to execute runs of this flow. Used for advanced scheduling options like timezone. |
None
|
triggers |
Optional[List[DeploymentTrigger]]
|
A list of triggers that should kick of a run of this flow. |
None
|
parameters |
Optional[dict]
|
A dictionary of default parameter values to pass to runs of this flow. |
None
|
description |
Optional[str]
|
A description for the created deployment. Defaults to the flow's description if not provided. |
None
|
tags |
Optional[List[str]]
|
A list of tags to associate with the created deployment for organizational purposes. |
None
|
version |
Optional[str]
|
A version for the created deployment. Defaults to the flow's version. |
None
|
enforce_parameter_schema |
bool
|
Whether or not the Prefect API should enforce the parameter schema for this deployment. |
False
|
Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/deployments/runner.py
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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
validate_automation_names
¶
Ensure that each trigger has a name for its automation if none is provided.
Source code in /home/runner/work/docs/docs/prefect_source/src/prefect/deployments/runner.py
122 123 124 125 126 127 128 129 |
|