errors Module

The errors module defines custom exceptions and error-handling utilities.

exception ucs.core.errors.BaseError(*args)[source]

Bases: Exception

Base class for all project-specific errors.

exit_code = 1
handle()[source]

Prints the error message and exits with the specified code.

message = 'An error occurred.'
exception ucs.core.errors.CheckpointDirectoryError(*args)[source]

Bases: BaseError

Raised when the checkpoint directory is invalid or missing.

exit_code = 3
message = 'Checkpoint directory not found or invalid: {}.'
exception ucs.core.errors.CheckpointNotFoundError(*args)[source]

Bases: BaseError

Raised when no checkpoint files are found.

exit_code = 2
message = 'No checkpoint files found in directory: {}.'
exception ucs.core.errors.ConfigId2LabelError(*args)[source]

Bases: BaseError

Raised when the ‘id2label’ mapping is missing from the configuration or dataset.

exit_code = 5
message = "'id2label' mapping is missing in config. Please provide it to ensure correct label mapping."
exception ucs.core.errors.LossIgnoreIndexError(*args)[source]

Bases: BaseError

Exception raised if weights size is not equal to num class.

exit_code = 9
message = "'ignore_index' {} is out of bounds for 'num_classes' {}."
exception ucs.core.errors.LossWeightsSizeError(*args)[source]

Bases: BaseError

Exception raised if weights size is not equal to num class.

exit_code = 8
message = "'weights' size {}. != num_classes {}."
exception ucs.core.errors.LossWeightsTypeError(*args)[source]

Bases: BaseError

Exception raised if ‘weights’ got wrong type.

exit_code = 7
message = "'weights' need to be type tuple|np.ndarray|list|tensor got {}."
exception ucs.core.errors.MultipleCheckpointsError(*args)[source]

Bases: BaseError

Raised when multiple checkpoint files are found.

exit_code = 4
message = 'Multiple checkpoint files found in directory: {}. Expected exactly one.'
exception ucs.core.errors.NormalizeError(*args)[source]

Bases: BaseError

Exception raised if normalize is not from valid options.

exit_code = 6
message = "'normalize' must be 'max' | 'balance' | 'sum' got {}"