[minor, fix] Allow passing class interface as custom pipeline argument (#2973)

Signed-off-by: knlnguyen1802 <knlnguyen1802@gmail.com>
Signed-off-by: Samit <285365963@qq.com>
Co-authored-by: Samit <285365963@qq.com>
This commit is contained in:
knlnguyen1802andSamit authored and GitHub committed 2026-05-29 23:39:38 +08:00
1 parent 9fdb3bcb89
commit 5377108438
4 files changed
+46 -11

No files matched your search

+20 -3
View File
@@ -183,7 +183,17 @@ def _filter_dict_like_object(obj: dict | Any) -> dict:
result = {}
filtered_keys = []
for k, v in obj.items():
if _is_callable_value(v):
# Preserve class objects by converting to a fully qualified name string
# so callers that resolve via import path (e.g. custom_pipeline_args.pipeline_class)
# still work after OmegaConf round-trip.
if isinstance(v, type):
module = getattr(v, "__module__", None)
qualname = getattr(v, "__qualname__", getattr(v, "__name__", None))
if module and qualname and module != "builtins":
result[k] = f"{module}.{qualname}"
else:
result[k] = qualname
elif _is_callable_value(v):
filtered_keys.append(str(k))
else:
result[k] = _convert_dataclasses_to_dict(v)
@@ -240,6 +250,13 @@ def _convert_dataclasses_to_dict(obj: Any) -> Any:
# Note: This must come AFTER Counter check since Counter is a dict subclass
if isinstance(obj, dict):
return _filter_dict_like_object(obj)
# Preserve class objects by converting to a fully qualified name string.
if isinstance(obj, type):
module = getattr(obj, "__module__", None)
qualname = getattr(obj, "__qualname__", getattr(obj, "__name__", None))
if module and qualname and module != "builtins":
return f"{module}.{qualname}"
return qualname
# Handle callable objects (functions, methods, etc.) - skip them
# Note: This comes after dict/list checks to avoid misclassifying dict-like objects
if callable(obj):
@@ -617,7 +634,7 @@ def load_and_resolve_stage_configs(
if not stage_configs:
if default_stage_cfg_factory is not None:
default_stage_cfg = default_stage_cfg_factory()
stage_configs = create_config(default_stage_cfg)
stage_configs = create_config(_convert_dataclasses_to_dict(default_stage_cfg))
else:
stage_configs = []
elif stage_configs_path is None:
@@ -630,7 +647,7 @@ def load_and_resolve_stage_configs(
if not stage_configs:
if default_stage_cfg_factory is not None:
default_stage_cfg = default_stage_cfg_factory()
stage_configs = create_config(default_stage_cfg)
stage_configs = create_config(_convert_dataclasses_to_dict(default_stage_cfg))
else:
stage_configs = []
else: