Skip to content

feat: support custom CLI args for Python config modules #507

@eric-tramel

Description

@eric-tramel

Summary

When using a Python config module (.py file) with data-designer create or data-designer preview, there is currently no way to pass custom arguments to the user's load_config_builder() function. This limits the flexibility of custom config scripts — users must hardcode values or manage their own env-var-based workarounds.

Proposed behavior

Allow users to pass extra arguments after a -- separator, which get forwarded to the Python module's load_config_builder() function:

data-designer create ./my_custom.py --num-records 32 -- --key value --key2 value2
data-designer preview ./my_custom.py -n 10 -- --model large --temperature 0.7

Everything after -- would be captured and passed to load_config_builder as a context object (e.g. a list[str] or a lightweight wrapper). The user's function signature would then optionally accept this:

# Before (still works, no args)
def load_config_builder() -> DataDesignerConfigBuilder:
    ...

# After (opt-in to receive CLI args)
def load_config_builder(cli_args: list[str] | None = None) -> DataDesignerConfigBuilder:
    builder = DataDesignerConfigBuilder()
    if cli_args:
        # User parses as they see fit (argparse, simple iteration, etc.)
        ...
    return builder

Changes required

  1. CLI commands (create, preview, validate): Accept and capture arguments after -- via Typer's context.args or Click's allow_extra_args mechanism.
  2. load_config_builder() in config_loader.py: Accept an optional cli_args: list[str] | None = None parameter and pass it through to _load_from_python_module.
  3. _load_from_python_module(): Inspect the user's load_config_builder signature. If it accepts a parameter (via inspect.signature), pass cli_args; otherwise call with no arguments for backwards compatibility.
  4. GenerationController._load_config(): Thread the extra args from the command through to load_config_builder().

Why

Custom Python config modules are a key extensibility surface. Users frequently want to parameterize their configs — e.g. switching model endpoints, adjusting generation parameters, or toggling column sets — without maintaining separate config files for each variant. Passthrough CLI args are the standard Unix pattern for this and would make the Python module path significantly more useful.

Backwards compatibility

  • YAML/JSON configs: unaffected (extra args after -- are simply ignored or produce a clear error).
  • Existing Python modules with def load_config_builder(): (no params): continue to work as-is via signature inspection.
  • Only Python modules that opt in by adding a cli_args parameter will receive the extra arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions