jsonargparse icon indicating copy to clipboard operation
jsonargparse copied to clipboard

BUG: `CLI` struggles to parse multiple configurations in a single `config.yaml`

Open nimonkaranurag opened this issue 1 month ago • 3 comments

🐛 Bug report

When you have multiple configurations:

setup_config:
  property_1: ...
  ...

run_config:
  property_1: ...
  ...

CLI fails with the following error if the configurations are implemented using pydantic.BaseModel:

usage: main.py [-h] [--config CONFIG] [--print_config[=flags]] [--retrieval_pipeline_config CONFIG]
               [--retrieval_pipeline_config.queries_path QUERIES_PATH] [--retrieval_pipeline_config.query QUERY]
               [--retrieval_pipeline_config.search_config CONFIG] [--retrieval_pipeline_config.search_config.top_k TOP_K]
               [--retrieval_pipeline_config.search_config.search_type {keyword,vector,hybrid}]
               [--retrieval_pipeline_config.search_config.normalization_constant NORMALIZATION_CONSTANT]
               [--retrieval_pipeline_config.output_path OUTPUT_PATH] [--retrieval_pipeline_config.batch_size BATCH_SIZE]
error: Validation failed: Group 'retriever_config' does not accept nested key 'embedding_provider_config.model_id'

As you can see, the retriever_config doesn't show any options. It isn't being parsed correctly.

To reproduce

  • create 2 data models for dummy configs using pydantic
  • use the Field property to assign a default_factory=regular dataclass

Expected behavior

Parse both configs, this works fine when they are implemented with regular data classes.

Environment

  • jsonargparse version: 4.43.0
  • Python version: 3.12
  • How jsonargparse was installed: PyPI
  • OS: Mac M1

nimonkaranurag avatar Dec 10 '25 10:12 nimonkaranurag

Thank you for reporting!

Could you please in the "To reproduce" section provide a complete code snippet and corresponding yaml config that causes the error shown.

mauvilsa avatar Dec 10 '25 14:12 mauvilsa

Ouch that might be tricky, it's confidential.

Although, I can empathise @mauvilsa - the issue is lacking in detail.

Do you want me to look into it myself?

I go on vacation tomorrow, will have some time since it's not holidays quite yet.

nimonkaranurag avatar Dec 10 '25 14:12 nimonkaranurag

You don't need to add confidential data. You wrote two bullet points. Just do that to create a dummy example. You are the one who understands the code, so it is best that you create the minimal reproduction example.

Do you want me to look into it myself?

No. Just the idea is that anyone can easily reproduce the issue. And the reproduction not depend on misinterpreting or incomplete instructions.

mauvilsa avatar Dec 10 '25 14:12 mauvilsa