job_base
SingleGenerationTypeVar
module-attribute
ComposedParameterSetTypeVar
module-attribute
ComposedParameterSetTypeVar = TypeVar(
"ComposedParameterSetTypeVar",
bound=CompositeParametersBase,
)
JOB_EXECUTION_MODE
Bases: StrEnum
How the job should be executed in a chain context.
Source code in horde_sdk/worker/job_base.py
HordeWorkerJobConfig
Bases: BaseModel
Configuration for a HordeWorkerJob.
Source code in horde_sdk/worker/job_base.py
max_consecutive_failed_job_submits
class-attribute
instance-attribute
max_consecutive_failed_job_submits: int = Field(
default=DEFAULT_MAX_CONSECUTIVE_FAILED_JOB_SUBMITS,
ge=1,
le=UNREASONABLE_MAX_CONSECUTIVE_FAILED_JOB_SUBMITS,
)
max_generation_failures
class-attribute
instance-attribute
max_generation_failures: int = Field(
default=DEFAULT_MAX_GENERATION_FAILURES,
ge=0,
le=UNREASONABLE_MAX_GENERATION_FAILURES,
)
job_submit_retry_delay
class-attribute
instance-attribute
state_error_limits
class-attribute
instance-attribute
generation_strict_transition_mode
class-attribute
instance-attribute
generation_strict_transition_mode: bool = Field(
default=DEFAULT_GENERATION_STRICT_TRANSITION_MODE
)
upload_timeout
class-attribute
instance-attribute
max_retries
class-attribute
instance-attribute
retry_delay
class-attribute
instance-attribute
result_image_format
class-attribute
instance-attribute
result_image_quality
class-attribute
instance-attribute
HordeWorkerJob
Bases: ABC
Base class for all worker jobs.
Jobs wrap an underlying generation parameter set with meta-information about the job, including information sent along from the dispatch source. This includes the remote job ID, the time the job was received, and any other higher-level information that is useful for the worker to know in order to process the job.
Source code in horde_sdk/worker/job_base.py
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 | |
generation_cls
property
The (python) type created by the job.
generation_parameters_cls
property
The (python) type of the generation parameters.
job_config
property
Return the configuration associated with this job.
dispatch_job_id
property
Return the identifier provided by the dispatch source, if any.
time_received
property
The time the job response was either received or constructed (in epoch time).
Note: This generally will be the time the job was popped from the server. However, manually constructed api responses or jobs that are not popped from a queue may imbue this property with a different meaning.
You can manually set this value with the time_received parameter in the constructor.
time_since_received
property
The time since the job was popped from the queue in seconds, or None if not yet received.
time_submitted
property
The time the job was submitted to the API in epoch time or None if not submitted.
time_spent_generating
class-attribute
instance-attribute
The time spent generating the job in seconds.
time_to_download_aux_models
class-attribute
instance-attribute
The time spent downloading user-specified auxiliary models specific to the job (i.e., LoRas) in seconds.
faulted_reason
property
The reason the job was faulted or None if not faulted.
faulted_at
property
The time the job was faulted in epoch time or None if not faulted.
should_censor_nsfw
property
Whether or not the user has requested that NSFW content be censored.
is_job_finalized
property
Return true if the generation in the job is finalized.
Note: This means the generation has been submitted as either successful or failed, or has been abandoned. Accordingly, there is nothing more to do with the job.
job_completed_successfully
property
Return true if the generation in the job completed successfully.
__init__
__init__(
generation: SingleGenerationTypeVar,
generation_cls: type[SingleGenerationTypeVar],
job_id: ID_TYPES | None = None,
*,
dispatch_job_id: ID_TYPES | None = None,
dispatch_result_ids: Sequence[ID_TYPES] | None = None,
job_config: HordeWorkerJobConfig | None = None,
time_received: float | None = None,
preserve_generation_id: bool = False
) -> None
Initialize the job.
Parameters:
-
generation(SingleGenerationType) –The generation to use for the job.
-
generation_cls(type[SingleGenerationType]) –The class to use for the generations in the job.
-
job_id(ID_TYPES | None, default:None) –The unique identifier for the job. If
None, a new UUID will be generated. -
dispatch_job_id(ID_TYPES | None, default:None) –Identifier supplied by the dispatch source. Defaults to None when the job has not been announced remotely.
-
dispatch_result_ids(Sequence[ID_TYPES] | None, default:None) –Result identifiers supplied by dispatch for the attached generation, if available. Defaults to None.
-
job_config(HordeWorkerJobConfig, default:None) –The configuration for the job. If
None, the default configuration will be used. Defaults to None. -
time_received(float | None, default:None) –The time the job was received. If
None, the time the response model was constructed will be used. Defaults to None. -
preserve_generation_id(bool, default:False) –When True, retain the generation's existing identifier instead of rebinding it to the job identifier. Defaults to False.
Source code in horde_sdk/worker/job_base.py
set_dispatch_job_id
Bind the job to the identifier supplied by dispatch.
job_worker_type
abstractmethod
classmethod
set_job_faulted
set_job_faulted(
faulted_reason: WORKER_ERRORS,
failure_exception: Exception | None = None,
) -> None
Mark the entire job as faulted.
Note: This will mark all generations in the job as faulted.