]> Piment Noir Git Repositories - freqai-strategies.git/commit
refactor(quickadapter): route inline enum error messages through enum_error_message...
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 31 Jul 2026 13:07:07 +0000 (15:07 +0200)
committerGitHub <noreply@github.com>
Fri, 31 Jul 2026 13:07:07 +0000 (15:07 +0200)
commit64dc1e8a39ecb19af18d3b13b05d4cfa60ba6377
tree7873b8b39f7810aa378d1ff8d5dffab2b2596820
parent479078eaeba7090f545e1272bc12e865e279d794
refactor(quickadapter): route inline enum error messages through enum_error_message (#194)

* refactor(quickadapter): relocate enum_error_message to EnumErrors module

Extract the canonical enum validation error formatter into a new
dependency-free module (strategies/EnumErrors.py) and re-export it from
Utils. This lets LabelTransformer route through the same helper without
importing Utils (which would create an import cycle, since Utils imports
from LabelTransformer).

Behavior-preserving: the helper is moved verbatim; the public import path
'from Utils import enum_error_message' is preserved via re-export.

* refactor(quickadapter): route Utils enum errors through helper

Replace 5 inline 'Invalid X value ...: supported values are ...' error
constructions in Utils with enum_error_message calls (window type,
fill_bandwidth, fill_method, and two regressor sites). Byte-identical.

* refactor(quickadapter): route LabelTransformer enum errors through helper

Import enum_error_message from the dependency-free EnumErrors module
(LabelTransformer cannot import Utils without creating an import cycle)
and route the 3 inline enum error constructions (scaler family kind,
standardization, normalization). Byte-identical.

* refactor(quickadapter): route strategy enum errors through helper

Add enum_error_message to the existing 'from Utils import' block and
route the 4 inline enum error constructions in QuickAdapterV3
(trade_price_target_method, interpolation_direction, side, trading_mode).
Byte-identical.

* refactor(quickadapter): route regressor enum errors through helper

Route the 11 canonical inline enum error constructions plus 3 that keep
byte-identical output via explicit sequence wrapping:
- data_split_parameters.method, selection_method (x2), skimage threshold
  method, trial_selection_method, cluster_method, aggregation,
  label_method, optuna storage_backend, optuna sampler, namespace
- namespace single-value sites wrap (_OPTUNA_NAMESPACES.label,) so join
  yields the same string; optuna namespace-sampler wraps tuple(samplers)
  (frozenset -> Sequence[str]) preserving the existing join order.
Byte-identical.

* fix(quickadapter): unify divergent enum error wording via helper

Route the two enum error sites that did NOT include the word "value"
through enum_error_message, aligning them with the canonical format.

INTENTIONAL, observable message change (NOT byte-identical):
- QuickAdapterRegressorV3._validate_enum_value: 'Invalid {ctx} {value!r}:'
  -> 'Invalid {ctx} value {value!r}:'. The message is reused by the
  logger.warning at the same helper, so the change affects both the
  raised ValueError and the warning log across its 6 callers.
- Utils.get_ngboost_dist dist_name: 'Invalid dist_name {v!r}:' ->
  'Invalid dist_name value {v!r}:' (dict_keys wrapped in tuple() to
  satisfy Sequence[str]; join output unchanged).

No test asserts these strings (quickadapter has no test suite).

* style(quickadapter): harmonize EnumErrors import placement

Glue the first-party EnumErrors import directly to the preceding import
block in LabelTransformer, matching the convention already used in
Utils.py and QuickAdapterV3.py (no blank line separating first-party
from third-party imports). No behavior change.

* docs(quickadapter): scope EnumErrors docstring to the canonical form

The module owns the canonical 'Invalid <ctx> value <value>: supported
values are <options>' message; messages with custom prefix/infix/suffix
are built inline at their call sites. Avoids over-claiming a single
source of truth for every enum error string.
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/EnumErrors.py [new file with mode: 0644]
quickadapter/user_data/strategies/LabelTransformer.py
quickadapter/user_data/strategies/QuickAdapterV3.py
quickadapter/user_data/strategies/Utils.py