consts
base_generate_progress_transitions
module-attribute
base_generate_progress_transitions: dict[
GENERATION_PROGRESS, list[GENERATION_PROGRESS]
] = {
NOT_STARTED: [
PRELOADING,
GENERATING,
PENDING_POST_PROCESSING,
POST_PROCESSING,
ERROR,
],
PRELOADING: [PRELOADING_COMPLETE, ERROR],
PRELOADING_COMPLETE: [
GENERATING,
PENDING_POST_PROCESSING,
POST_PROCESSING,
ERROR,
],
GENERATING: [
PENDING_POST_PROCESSING,
POST_PROCESSING,
PENDING_SAFETY_CHECK,
SAFETY_CHECKING,
ERROR,
],
PENDING_POST_PROCESSING: [POST_PROCESSING, ERROR],
POST_PROCESSING: [
PENDING_SAFETY_CHECK,
SAFETY_CHECKING,
ERROR,
],
PENDING_SAFETY_CHECK: [SAFETY_CHECKING, ERROR],
SAFETY_CHECKING: [PENDING_SUBMIT, ERROR],
PENDING_SUBMIT: [SUBMITTING, ERROR],
SUBMITTING: [SUBMIT_COMPLETE, ERROR],
SUBMIT_COMPLETE: [COMPLETE],
COMPLETE: [],
ABORTED: [REPORTED_FAILED, ERROR],
REPORTED_FAILED: [],
ERROR: [ABORTED],
USER_REQUESTED_ABORT: [USER_ABORT_COMPLETE],
USER_ABORT_COMPLETE: [],
ABANDONED: [],
}
A map of the typical transitions between generation states.
black_box_generate_progress_transitions
module-attribute
black_box_generate_progress_transitions: dict[
GENERATION_PROGRESS, list[GENERATION_PROGRESS]
] = {
NOT_STARTED: [GENERATING, ERROR],
GENERATING: [
PENDING_SUBMIT,
PENDING_SAFETY_CHECK,
COMPLETE,
ERROR,
],
PENDING_SAFETY_CHECK: [SAFETY_CHECKING, ERROR],
SAFETY_CHECKING: [PENDING_SUBMIT, COMPLETE, ERROR],
PENDING_SUBMIT: [SUBMITTING, ERROR],
SUBMITTING: [SUBMIT_COMPLETE, COMPLETE, ERROR],
SUBMIT_COMPLETE: [COMPLETE],
COMPLETE: [],
ABORTED: [REPORTED_FAILED, ERROR],
REPORTED_FAILED: [],
ERROR: [ABORTED],
USER_REQUESTED_ABORT: [USER_ABORT_COMPLETE, ABANDONED],
USER_ABORT_COMPLETE: [],
ABANDONED: [],
}
base_generate_progress_no_submit_transitions
module-attribute
base_generate_progress_no_submit_transitions = (
generate_transitions(
base_generate_progress_transitions, skip_submit=True
)
)
default_image_generate_progress_transitions
module-attribute
default_image_generate_progress_transitions = (
generate_transitions(base_generate_progress_transitions)
)
default_image_generate_progress_no_submit_transitions
module-attribute
default_image_generate_progress_no_submit_transitions = (
generate_transitions(
base_generate_progress_transitions, skip_submit=True
)
)
default_alchemy_generate_progress_transitions
module-attribute
default_alchemy_generate_progress_transitions = (
generate_transitions(
base_generate_progress_transitions,
can_skip_safety_checks=True,
)
)
default_alchemy_generate_progress_no_submit_transitions
module-attribute
default_alchemy_generate_progress_no_submit_transitions = (
generate_transitions(
base_generate_progress_transitions,
skip_submit=True,
can_skip_safety_checks=True,
)
)
default_text_generate_progress_transitions
module-attribute
default_text_generate_progress_transitions = (
generate_transitions(
base_generate_progress_transitions,
can_skip_safety_checks=True,
)
)
default_text_generate_progress_no_submit_transitions
module-attribute
default_text_generate_progress_no_submit_transitions = (
generate_transitions(
base_generate_progress_transitions,
skip_submit=True,
can_skip_safety_checks=True,
)
)
finalized_generation_states
module-attribute
WORKER_ERRORS
Bases: StrEnum
The reason a job faulted.
Source code in horde_sdk/worker/consts.py
UNHANDLED_EXCEPTION
class-attribute
instance-attribute
An error not otherwise specified occurred.
UNHANDLED_EXCEPTION_FROM_BACKEND
class-attribute
instance-attribute
An error was caught originating from within the backend.
SYSTEM_OUT_OF_MEMORY
class-attribute
instance-attribute
The system ran out of memory.
GPU_OUT_OF_MEMORY
class-attribute
instance-attribute
The GPU ran out of memory.
NETWORK_ISSUE
class-attribute
instance-attribute
There was a network issue, such as a timeout or a connection error.
GENERATION_PROGRESS
Bases: StrEnum
The state of a generation.
Source code in horde_sdk/worker/consts.py
ERROR
class-attribute
instance-attribute
An error occurred during generation. The most recent step will be retried up to a certain number of times.
PRELOADING
class-attribute
instance-attribute
The generation is preloading any models to RAM/VRAM. Preloading is skipped if the models are already loaded.
PRELOADING_COMPLETE
class-attribute
instance-attribute
The generation has completed preloading.
GENERATING
class-attribute
instance-attribute
The generation is in progress. This will also preload if that step did not yet occur.
GENERATION_COMPLETE
class-attribute
instance-attribute
The generation has completed generating the data, but may still need post-processing or safety checks.
PENDING_POST_PROCESSING
class-attribute
instance-attribute
The generation has completed and is pending post-processing.
POST_PROCESSING
class-attribute
instance-attribute
The generation is post-processing the generated data.
POST_PROCESSING_COMPLETE
class-attribute
instance-attribute
The generation has completed post-processing and is pending safety check.
PENDING_SAFETY_CHECK
class-attribute
instance-attribute
The generation was created and is pending safety check.
SAFETY_CHECKING
class-attribute
instance-attribute
The generation is being safety checked.
SAFETY_CHECK_COMPLETE
class-attribute
instance-attribute
The generation has completed safety check and is pending submission.
PENDING_SUBMIT
class-attribute
instance-attribute
The generation has completed safety check and is pending submission.
SUBMITTING
class-attribute
instance-attribute
The generation is pending submission.
SUBMIT_COMPLETE
class-attribute
instance-attribute
The generation has been successfully submitted.
COMPLETE
class-attribute
instance-attribute
The generation is completely finished and no further steps are required.
ABORTED
class-attribute
instance-attribute
The generation has failed because one or more steps failed too many times. An attempt to notify the API will be made.
REPORTED_FAILED
class-attribute
instance-attribute
The generation has been reported as failed to the API.
USER_REQUESTED_ABORT
class-attribute
instance-attribute
The generation was aborted by the submitting user's request.
USER_ABORT_COMPLETE
class-attribute
instance-attribute
The generation was aborted (by user's request) and the API has been notified accordingly.
ABANDONED
class-attribute
instance-attribute
The generation failed and the API could not be notified. It has simply been discarded.
Note that this can lead to a worker being put into maintenance mode if too many generations are abandoned within a certain time frame.
is_state_complete
staticmethod
Check if the generation is complete.
Source code in horde_sdk/worker/consts.py
is_state_failing
staticmethod
Check if the generation is failing.
Source code in horde_sdk/worker/consts.py
is_state_pending
staticmethod
Check if the generation is pending.
Source code in horde_sdk/worker/consts.py
JobState
Bases: StrEnum
The state of a job.
Source code in horde_sdk/worker/consts.py
QUEUED
class-attribute
instance-attribute
The job has been received and is waiting to be processed.
PREPARING
class-attribute
instance-attribute
The job is being prepared for processing.
GENERATING
class-attribute
instance-attribute
The job is in the process of generating.
PENDING_SAFETY_CHECK
class-attribute
instance-attribute
The job was generated and is pending safety check.
PENDING_SUBMIT
class-attribute
instance-attribute
The job is pending submission.
WAITING_ON_NETWORK
class-attribute
instance-attribute
The job is waiting on network IO.
SUCCESSFULLY_COMPLETED
class-attribute
instance-attribute
The job finished successfully.
HordeWorkerConfigDefaults
Default values for HordeWorkerJobConfig.
Source code in horde_sdk/worker/consts.py
DEFAULT_MAX_CONSECUTIVE_FAILED_JOB_SUBMITS
class-attribute
instance-attribute
The default maximum number of consecutive times a job can fail to submit to the API before it is marked as faulted. This is used to prevent a job from being retried indefinitely and to prevent a job from being submitted well after it would have likely have been marked stale by the API.
Jobs which are faulted are abandoned and no further attempts are made to submit any generations in the job nor to notify the API that the job failed.
DEFAULT_JOB_SUBMIT_RETRY_DELAY
class-attribute
instance-attribute
The default delay in seconds between retries to submit a job to the API after submit issues.
UNREASONABLE_MAX_CONSECUTIVE_FAILED_JOB_SUBMITS
class-attribute
instance-attribute
The highest number of consecutive failed job submits allowed in any configuration.
This is used internally to the sdk as a final safeguard to prevent mistakes in configuration.
DEFAULT_MAX_GENERATION_FAILURES
class-attribute
instance-attribute
The default maximum number of times a generation can fail before it is abandoned.
Note: Generations which fail are reported to the API as failed, but the job itself is not
necessarily faulted. If notifying the API of a failed generation fails the number of times specified by
max_consecutive_failed_job_submits, then the job is marked as faulted and is abandoned.
UNREASONABLE_MAX_GENERATION_FAILURES
class-attribute
instance-attribute
The highest number of generation failures allowed in any configuration.
This is used internally to the sdk as a final safeguard to prevent mistakes in configuration.
DEFAULT_STATE_ERROR_LIMITS
class-attribute
DEFAULT_STATE_ERROR_LIMITS: dict[
GENERATION_PROGRESS, int
] = {
PRELOADING: 3,
GENERATING: 3,
POST_PROCESSING: 3,
SAFETY_CHECKING: 3,
SUBMITTING: 10,
USER_REQUESTED_ABORT: 10,
}
DEFAULT_RESULT_IMAGE_FORMAT
class-attribute
instance-attribute
DEFAULT_RESULT_IMAGE_QUALITY
class-attribute
instance-attribute
DEFAULT_RESULT_IMAGE_PIL_METHOD
class-attribute
instance-attribute
REQUESTED_BACKEND_CONSTRAINTS
Bases: StrEnum
What constraints on backends to use were requested by the user/server.
Source code in horde_sdk/worker/consts.py
SPECIFIED
class-attribute
instance-attribute
Only the specified backend is acceptable.
DEFAULT_IMAGE
class-attribute
instance-attribute
Only the default image backend is acceptable.
DEFAULT_TEXT
class-attribute
instance-attribute
Only the default text backend is acceptable.
DEFAULT_AUDIO
class-attribute
instance-attribute
Only the default audio backend is acceptable.
DEFAULT_VIDEO
class-attribute
instance-attribute
Only the default video backend is acceptable.
DEFAULT_ALCHEMY
class-attribute
instance-attribute
Only the default alchemy backend is acceptable.
NO_CUSTOM
class-attribute
instance-attribute
Only official backends are acceptable.
REQUESTED_SOURCE_IMAGE_FALLBACK_CHOICE
Bases: StrEnum
The choice for what to do when a requested source image couldn't be parsed or is otherwise unusable.
Source code in horde_sdk/worker/consts.py
TXT2IMG_FALLBACK
class-attribute
instance-attribute
Use txt2img instead if the source image is unusable.
ABANDON
class-attribute
instance-attribute
Abandon the generation if the source image is unusable.
USE_WHITE_IMAGE
class-attribute
instance-attribute
Use a white image if the source image is unusable.
USE_BLACK_IMAGE
class-attribute
instance-attribute
Use a black image if the source image is unusable.
CHAIN_EDGE_KIND
Bases: StrEnum
The known chain edges.
Source code in horde_sdk/worker/consts.py
RESULTING_IMAGE_AS_SOURCE
class-attribute
instance-attribute
The resulting image of the previous generation is used as the source for the next generation.
RESULTING_TEXT_AS_PROMPT
class-attribute
instance-attribute
The resulting text of the previous generation is used as the prompt for the next generation.
RESULTING_IMAGE_AS_MASK
class-attribute
instance-attribute
The resulting image of the previous generation is used as the mask for the next generation.
RESULTING_IMAGE_AS_CONTROL_MAP
class-attribute
instance-attribute
The resulting image of the previous generation is used as the control map for the next generation.
IMAGE_TO_ALCHEMY_UPSCALE
class-attribute
instance-attribute
The resulting image from image generation is used as the source for alchemy upscaling.
IMAGE_TO_ALCHEMY_FACEFIX
class-attribute
instance-attribute
The resulting image from image generation is used as the source for alchemy face fixing.
ALCHEMY_TO_ALCHEMY
class-attribute
instance-attribute
The resulting image from one alchemy operation is used as the source for another alchemy operation.
generate_transitions
generate_transitions(
base_transitions: dict[
GENERATION_PROGRESS, list[GENERATION_PROGRESS]
],
skip_submit: bool = False,
can_skip_safety_checks: bool = False,
supports_safety_only: bool = False,
) -> dict[GENERATION_PROGRESS, list[GENERATION_PROGRESS]]
Generate transitions with optional modifications.
Parameters:
-
base_transitions(dict[GENERATION_PROGRESS, list[GENERATION_PROGRESS]]) –The base transitions to modify.
-
skip_submit(bool, default:False) –Whether to skip submit transitions. Defaults to False.
-
can_skip_safety_checks(bool, default:False) –Whether to skip safety check transitions can be skipped. Defaults to False.
-
supports_safety_only(bool, default:False) –Whether to allow transition directly to safety check without going through generation or post-processing. Defaults to False.
Source code in horde_sdk/worker/consts.py
validate_generation_progress_transitions
validate_generation_progress_transitions(
progress_transitions: Mapping[
GENERATION_PROGRESS, Iterable[GENERATION_PROGRESS]
],
) -> bool
Validate the generation progress transitions.
Parameters:
-
progress_transitions(Mapping[GENERATION_PROGRESS, Iterable[GENERATION_PROGRESS]]) –The transitions to validate
Returns:
-
bool(bool) –True if the transitions are valid, False otherwise.