From b36d49596a0da950384c750da17ad690adf7779e Mon Sep 17 00:00:00 2001 From: Tai An Date: Sat, 25 Apr 2026 00:16:37 -0700 Subject: [PATCH] fix(cli): resolve subpackage register paths before deduplication On RHEL/CentOS-derived distros lib64 is a symlink to lib, so both paths appear in submodule_search_locations. The previous set() compared raw strings and treated the symlink siblings as distinct entries, causing each register module to be imported twice and raising 'argparse.ArgumentError: conflicting subparser' at optimum-cli startup. Resolving each path with Path.resolve() before building the set lets symlinked locations collapse to a single canonical entry, so the registration loop runs once per real directory. Fixes #2417 --- optimum/commands/optimum_cli.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/optimum/commands/optimum_cli.py b/optimum/commands/optimum_cli.py index 74ee549f8e..1c12a52243 100644 --- a/optimum/commands/optimum_cli.py +++ b/optimum/commands/optimum_cli.py @@ -121,8 +121,16 @@ def load_optimum_namespace_cli_commands() -> ( # Find all registration files and load the commands to register commands_to_register = [] - for register_path in set(commands_register_spec.submodule_search_locations): - register_path = Path(register_path) + # Resolve each path before deduplicating so that symlinked locations collapse to a + # single entry. On RHEL/CentOS-derived distros lib64 is a symlink to lib, so both + # paths appear in submodule_search_locations; plain set() compares strings and + # would treat them as distinct, importing the same register module twice and + # raising "argparse.ArgumentError: conflicting subparser" at CLI startup. + register_paths = { + Path(register_path).resolve() + for register_path in commands_register_spec.submodule_search_locations + } + for register_path in register_paths: if not register_path.is_dir(): # skip non-directory paths continue