Skip to content

[Feature Request] Get swept list without hydra.main #3103

@clouds56

Description

@clouds56

🚀 Feature Request

Motivation

Is your feature request related to a problem? Please describe.

I'd like to manually get config from hydra, go without hydra.main

def get_config(args: list[str] | None = None) -> Config:
  import hydra
  from typing import cast
  if args is None:
    args = ["+llm=small", "+optim=adamw", "llm.batch_size=32"]
  with hydra.initialize(config_path=None, version_base='1.3'):
    cfg = hydra.compose(
      config_name=None,
      overrides=args
    )
  return cast(Config, cfg)

This works well but doesn't support multi-run. It would fail on get_config(["+llm=small,large", "+optim=adamw"])

Pitch

Describe the solution you'd like

have a hydra.compose_multi that have RunMode.MULTI_RUN, and returns a list[DictConfig]

Describe alternatives you've considered

manually parse and call sweeper.

  with hydra.initialize(config_path=None, version_base='1.3'):
    gh = GlobalHydra.instance()
    assert gh.hydra is not None
    parser = OverridesParser.create(config_loader=gh.hydra.config_loader)
    overrides = parser.parse_overrides(args)
    split_overrides = BasicSweeper.split_arguments(overrides, None)
    configs = [
      hydra.compose(
        config_name=None,
        overrides=o
      ) for o in split_overrides
    ]

Are you willing to open a pull request? (See CONTRIBUTING)
yes.

Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions