Exceptions and warnings¶
Errors and warnings raised by skforecast_ai. All of them are importable from the package root, for example from skforecast_ai import LLMCallError.
Every error derives from SkforecastAIError, which carries a code from a closed set, the argument at fault in field (None when the error is not tied to one) and an optional remedy in hint, which is not part of str(exc). A program can react to code and field without parsing the message. The errors for invalid inputs also derive from the built-in exception raised before 0.4.0 (ValueError, TypeError or FileNotFoundError), so existing except clauses keep catching them with the same message.
| Name | Raised or warned by | When |
|---|---|---|
SkforecastAIError |
every method | Base class of the errors below. Catch it to handle any error of skforecast-ai. |
InvalidInputError |
every method | An argument, or the plan, profile or CV passed in, is not valid. A ValueError. |
InvalidInputTypeError |
every method | An argument has a type that is not accepted, such as a bool test_size or a compare() candidate config that is not a dict, or a CVResult is unpacked as a tuple. A TypeError, and also an InvalidInputError and therefore a ValueError. |
DataContentError |
forecast(), backtest(), compare() and the CLI |
Every argument is valid and the content of the data, or of the future exogenous variables, cannot be used for what was asked: a missing value of the target that a prediction or a metric reads, final rows without a target value, or future exogenous variables whose columns, dates or values do not fit the data and the plan. An InvalidInputError and therefore a ValueError, with the same code and field. |
DataNotFoundError |
every method that takes data, and the CLI |
The CSV path does not exist or the URL cannot be read, or a JSON or CSV input of the CLI does not exist. A FileNotFoundError. |
LLMRequiredError |
ask(), refine_plan() and create_cv() with a prompt |
The method needs an LLM and none was configured at init time. |
LLMCallError |
ask() |
The call to the LLM fails. There is no deterministic answer to fall back on, so the provider error is raised (chained as original_error) instead of returned as text. |
ForecastExecutionError |
forecast(), backtest() |
The generated script does not compile or fails while running. The script and the full traceback are available as generated_code and execution_traceback, and the line and the statement that failed as failed_line and failed_statement. |
AllCandidatesFailedError |
compare() |
Every candidate configuration fails, so there is no leaderboard to return. The per-candidate reasons are in failures. |
CandidateFailedWarning |
compare() |
One candidate fails; the comparison continues with the rest and the failure is recorded in ComparisonResult.failures. |
MissingBackendWarning |
compare() without candidates |
The backend of the default foundation model (chronos-forecasting for Chronos-2) is not installed, so ForecasterFoundation is left out of the comparison instead of failing. Install it with pip install skforecast-ai[foundation]. |
DataSentToLLMWarning |
ask() |
A result with values of its own (predictions, metrics) is sent to the LLM while send_data_to_llm=False. Pass send_data_to_llm=True to acknowledge it. |
PlanEditsDiscardedWarning |
refine_plan() |
The plan holds values edited by hand (a key of forecaster_kwargs, the preprocessing steps) that the refined plan does not keep. The warning names them and its text is kept in the warnings of the refined plan. The ones refine_plan() takes as overrides (forecaster, lags, metric...) can be passed again; the others cannot be kept. |
UnrecommendedForecasterWarning |
plan() |
The requested forecaster is supported but was not among the profile's candidates for this dataset (for example, Auto-ARIMA on high-frequency data). |
refine_plan() and create_cv() do not raise when the LLM fails: they emit a UserWarning and return their deterministic result, which is valid on its own.
The warnings that skforecast emits while forecast(), backtest() and compare() run the generated script (for example MissingValuesWarning) are shown when the script ends, after its printed output is discarded. Your warning filters apply as usual: warnings.simplefilter('ignore', category=...) hides them, and an error filter makes the script fail.
Error codes¶
code |
Raised as | When |
|---|---|---|
invalid_argument |
InvalidInputError, InvalidInputTypeError, DataContentError |
An argument or a received object is not valid. |
insufficient_data |
InvalidInputError |
The data is too short for what was asked: fewer than two folds for the cross-validation, lags and window features longer than the data allows, a target column without any value, or a series of ForecasterRecursiveMultiSeries without values or shorter than its lags and window features. |
data_not_found |
DataNotFoundError |
A file to read (the CSV path or URL, or an input of the CLI) cannot be found. |
data_unreadable |
DataNotFoundError, InvalidInputError |
An input exists but cannot be parsed: a CSV file that pandas cannot read (empty, binary, not UTF-8, or rows with more fields than the header), a URL whose content is not a CSV (DataNotFoundError, as before), or the JSON of --from-plan or --from-profile in the CLI. |
missing_dependency |
InvalidInputError |
The package of the chosen estimator, or the backend package of the foundation model, is not installed. Checked before forecast() and backtest() run the script. |
execution_failed |
ForecastExecutionError |
The generated script fails. |
all_candidates_failed |
AllCandidatesFailedError |
Every candidate of compare() fails. |
llm_required |
LLMRequiredError |
The method needs an LLM and none is configured. |
llm_call_failed |
LLMCallError |
The call to the LLM fails. |
internal_error |
Not raised by skforecast-ai: ErrorInfo uses it for any exception that skforecast-ai did not raise itself (it is also the default code of a bare SkforecastAIError). |
Some errors carry a remedy in hint that does not depend on Python, for a program or an agent that passes paths (the CLI prints it as a tip): for example how to write the dates, or what a CSV file that cannot be read must look like. Messages that suggest a pandas call keep it, and hint gives the remedy without it.
ErrorInfo.from_exception(), in skforecast_ai.schemas, turns an exception into plain data (code, message, field, hint) for a reader outside Python: it never holds a traceback or generated code, takes the field of a pydantic ValidationError from the location of its first error, and describes any other exception by its type and the first line of its message.
skforecast_ai.exceptions ¶
Classes:
| Name | Description |
|---|---|
SkforecastAIError |
Base class of the errors raised by skforecast-ai. |
InvalidInputError |
Raised when an argument, or the plan, profile or CV passed in, is not |
InvalidInputTypeError |
Raised when an argument has a type that is not accepted. |
DataContentError |
Raised when the content of the data, or of the future exogenous |
DataNotFoundError |
Raised when a file to read cannot be found: the data (a CSV path or |
LLMRequiredError |
Raised when a method that requires an LLM is called without one. |
LLMCallError |
Raised by |
ForecastExecutionError |
Raised when the generated forecasting code fails to compile or fails |
AllCandidatesFailedError |
Raised by |
CandidateFailedWarning |
Warned by |
DataSentToLLMWarning |
Warned when data values are sent to the LLM against |
MissingBackendWarning |
Warned by |
PlanEditsDiscardedWarning |
Warned by |
UnrecommendedForecasterWarning |
Warned by |
Attributes:
| Name | Type | Description |
|---|---|---|
ErrorCode |
Closed set of codes carried by |
|
ERROR_CODES |
tuple[str, ...]
|
|
Attributes¶
ErrorCode
module-attribute
¶
ErrorCode = Literal[
"invalid_argument",
"insufficient_data",
"data_not_found",
"data_unreadable",
"missing_dependency",
"execution_failed",
"all_candidates_failed",
"llm_required",
"llm_call_failed",
"internal_error",
]
Closed set of codes carried by SkforecastAIError.code.
Classes¶
SkforecastAIError ¶
SkforecastAIError(
message="", *, code=None, field=None, hint=None
)
Bases: Exception
Base class of the errors raised by skforecast-ai.
Every error carries a stable code from a closed set and, when one
argument is at fault, its name in field, so a program (an agent, the
CLI) can react to the kind of error without parsing the message. The
message is the text of the exception; hint is an optional remedy kept
out of it, so str(exc) is the message alone.
Each subclass also derives from the built-in exception that was raised
before the hierarchy existed (ValueError, TypeError,
FileNotFoundError), so existing except clauses keep catching it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Error message, returned by |
''
|
code
|
str
|
One of |
None
|
field
|
str
|
Name of the argument (or the field of a plan, profile or CV) at fault. None when the error is not tied to a single argument. |
None
|
hint
|
str
|
Optional remedy, not part of |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
One of |
field |
(str, None)
|
Name of the argument at fault. |
hint |
(str, None)
|
Optional remedy. |
Source code in skforecast_ai/exceptions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
InvalidInputError ¶
InvalidInputError(
message="", *, code=None, field=None, hint=None
)
Bases: SkforecastAIError, ValueError
Raised when an argument, or the plan, profile or CV passed in, is not valid.
A subclass of ValueError, the class raised for these errors before
skforecast-ai had its own hierarchy. The default code is
'invalid_argument'; errors caused by too little data use
'insufficient_data', and a missing optional package
'missing_dependency'.
Attributes:
| Name | Type | Description |
|---|---|---|
default_code |
ErrorCode
|
|
Source code in skforecast_ai/exceptions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
InvalidInputTypeError ¶
InvalidInputTypeError(
message="", *, code=None, field=None, hint=None
)
Bases: InvalidInputError, TypeError
Raised when an argument has a type that is not accepted.
A subclass of TypeError, the class raised for these errors before
skforecast-ai had its own hierarchy, and of InvalidInputError, so
catching InvalidInputError covers every invalid input.
Source code in skforecast_ai/exceptions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
DataContentError ¶
DataContentError(
message="", *, code=None, field=None, hint=None
)
Bases: InvalidInputError
Raised when the content of the data, or of the future exogenous variables, cannot be used for what was asked, although every argument is valid: a missing value of the target that a prediction or a metric reads, final rows without a target value, or future exogenous variables whose columns, dates or values do not fit the data and the plan.
A subclass of InvalidInputError, with its code and its field
('data', 'exog' or 'test_size'), so catching InvalidInputError
or ValueError still covers it. Catch it to tell a problem of the
values, which is solved in the data, from an argument to correct.
Source code in skforecast_ai/exceptions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
DataNotFoundError ¶
DataNotFoundError(
message="", *, code=None, field=None, hint=None
)
Bases: SkforecastAIError, FileNotFoundError
Raised when a file to read cannot be found: the data (a CSV path or URL), or a JSON or CSV input of the CLI.
A subclass of FileNotFoundError, the class raised for these errors
before skforecast-ai had its own hierarchy. The code is
'data_not_found'.
Attributes:
| Name | Type | Description |
|---|---|---|
default_code |
ErrorCode
|
|
Source code in skforecast_ai/exceptions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
LLMRequiredError ¶
LLMRequiredError(method_name)
Bases: SkforecastAIError
Raised when a method that requires an LLM is called without one.
The code is 'llm_required'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method_name
|
str
|
Name of the method that requires an LLM. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
default_code |
ErrorCode
|
|
Source code in skforecast_ai/exceptions.py
188 189 190 191 192 | |
LLMCallError ¶
LLMCallError(llm, original_error)
Bases: SkforecastAIError
Raised by ask() when the call to the LLM fails.
ask() has no deterministic answer to fall back on, so a failed call
(network, authentication, provider error, or a local model that is
not reachable) is reported as an error instead of a result whose
explanation is not an answer. The original exception is chained and
kept as an attribute. The code is 'llm_call_failed'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm
|
str
|
LLM provider string in format |
required |
original_error
|
Exception
|
The exception raised by the provider or the agent. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
llm |
str
|
LLM provider string in format |
original_error |
Exception
|
The exception raised by the provider or the agent. |
Source code in skforecast_ai/exceptions.py
222 223 224 225 226 227 228 229 230 231 232 | |
ForecastExecutionError ¶
ForecastExecutionError(
original_error,
generated_code,
execution_traceback,
failed_line=None,
failed_statement=None,
)
Bases: SkforecastAIError
Raised when the generated forecasting code fails to compile or fails during exec().
The short message surfaces the original error. The full generated
code and traceback are available as attributes for debugging, together
with the line and the statement of the generated code that failed. The
code is 'execution_failed'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_error
|
Exception
|
The exception raised while compiling or executing the code. |
required |
generated_code
|
str
|
The generated Python code that was executed. |
required |
execution_traceback
|
str
|
The full formatted traceback from execution. |
required |
failed_line
|
int
|
Line of |
None
|
failed_statement
|
str
|
Source of the statement of |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
original_error |
Exception
|
The exception raised while compiling or executing the code. |
generated_code |
str
|
The generated Python code that was executed. |
execution_traceback |
str
|
The full formatted traceback from execution. |
failed_line |
(int, None)
|
Line of |
failed_statement |
(str, None)
|
Source of the statement of |
Source code in skforecast_ai/exceptions.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
Attributes¶
AllCandidatesFailedError ¶
AllCandidatesFailedError(failures)
Bases: SkforecastAIError
Raised by compare() when every candidate configuration fails.
A comparison with zero successful candidates has no leaderboard and
no winner, so it is reported as a failure instead of returning a
winner-less result. The code is 'all_candidates_failed'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
failures
|
dict
|
Mapping of candidate name to the |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
failures |
dict
|
Mapping of candidate name to its |
Source code in skforecast_ai/exceptions.py
325 326 327 328 329 330 331 332 333 | |
CandidateFailedWarning ¶
Bases: UserWarning
Warned by compare() when an individual candidate fails.
The comparison continues with the remaining candidates; the failure
is recorded in the 'error' column of the results table and a
CandidateFailure is kept in ComparisonResult.failures.
DataSentToLLMWarning ¶
Bases: UserWarning
Warned when data values are sent to the LLM against send_data_to_llm.
ask(context=...) always sends the predicted values a result carries,
because a question about a result cannot be answered from summary
statistics alone. That override is silent otherwise, so a user who set
send_data_to_llm=False for privacy reasons would still ship values
off the machine without being told. A result that carries no such
values (for example a CodeGenerationResult) does not trigger it.
The input data is not sent: a result holds only the model's output, never the data it was fitted on.
MissingBackendWarning ¶
Bases: UserWarning
Warned by compare() when a foundation model candidate is left out.
compare() without candidates includes ForecasterFoundation, whose
default model needs a backend package (for Chronos-2,
chronos-forecasting) that skforecast-ai does not install by default.
When that package is missing, the candidate is dropped instead of
failing on every call, and this warning says which package to install.
The comparison explanation records it as well.
PlanEditsDiscardedWarning ¶
Bases: UserWarning
Warned by refine_plan() when edits made to the plan are discarded.
refine_plan() builds the refined plan with plan(), from the
decisions it carries over (the overrides of RefinePlanOverrides and
the fields in ForecastPlan.overridden_fields). A value changed by
hand in the plan (in forecaster_kwargs, the metric, the
preprocessing steps...) that plan() would not build is therefore
lost. The warning names those fields; its text is also kept in the
warnings of the refined plan.
UnrecommendedForecasterWarning ¶
Bases: UserWarning
Warned by plan() when the requested forecaster is not recommended.
The forecaster is supported and is used as requested, but it was left
out of ForecastingProfile.forecaster_candidates for this dataset,
typically because it is expected to be very slow or to perform poorly
(for example, Auto-ARIMA on high-frequency data).
skforecast_ai.schemas.errors.ErrorInfo ¶
Bases: BaseModel
Plain-data description of an error, for a reader outside Python.
Built with ErrorInfo.from_exception(). It never holds a traceback or
generated code: only a stable code, the message, the argument at fault
and an optional remedy.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
One of |
message |
str
|
Error message. For an internal error, the exception type and the first line of its message, at most 200 characters. |
field |
(str, None)
|
Name of the argument (or the field of a plan, profile or CV) at fault, when the error is tied to one. |
hint |
(str, None)
|
Optional remedy. |
Methods:
| Name | Description |
|---|---|
from_exception |
Describe an exception raised by a skforecast-ai call. |
Attributes¶
model_config
class-attribute
instance-attribute
¶
model_config = ConfigDict(frozen=True, extra='forbid')
Methods:¶
from_exception
classmethod
¶
from_exception(exc)
Describe an exception raised by a skforecast-ai call.
- A
SkforecastAIErrorkeeps its code, message, field and hint. The message of anAllCandidatesFailedErrorleaves out how to inspectexc.failures, which only exists in Python. - A pydantic
ValidationError(a plan or a profile that does not validate) is'invalid_argument'. When the validator raised aSkforecastAIError, its code, message and hint are used. The field is the location of the first error, or the field of that error when the location is empty (a check on the whole model). When there are several errors, the message says how many are not shown. - Any other exception is
'internal_error', described by its type and the first line of its message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
Exception
|
Exception to describe. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
info |
ErrorInfo
|
Plain-data description of |
Source code in skforecast_ai/schemas/errors.py
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 | |