Download lib/python3.12/site-packages/hydra/plugins/sweeper.py from parallel-reasoner/env-full: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/parallel-reasoner/env-full/resolve/7db01aa111f155a37446aa51b2e050c094ac72ab/lib/python3.12/site-packages/hydra/plugins/sweeper.py
- Command line
-
hf download hf://parallel-reasoner/env-full@7db01aa111f155a37446aa51b2e050c094ac72ab/lib/python3.12/site-packages/hydra/plugins/sweeper.py
-
curl -L -o sweeper.py https://huggingface.co/parallel-reasoner/env-full/resolve/7db01aa111f155a37446aa51b2e050c094ac72ab/lib/python3.12/site-packages/hydra/plugins/sweeper.py
2.11 kB
| # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved | |
| """ | |
| Sweeper plugin interface | |
| """ | |
| from abc import abstractmethod | |
| from typing import Any, List, Sequence, Optional | |
| from hydra.types import TaskFunction | |
| from omegaconf import DictConfig | |
| from .launcher import Launcher | |
| from .plugin import Plugin | |
| from hydra.types import HydraContext | |
| class Sweeper(Plugin): | |
| """ | |
| An abstract sweeper interface | |
| Sweeper takes the command line arguments, generates a and launches jobs | |
| (where each job typically takes a different command line arguments) | |
| """ | |
| hydra_context: Optional[HydraContext] | |
| config: Optional[DictConfig] | |
| launcher: Optional[Launcher] | |
| def setup( | |
| self, | |
| *, | |
| hydra_context: HydraContext, | |
| task_function: TaskFunction, | |
| config: DictConfig, | |
| ) -> None: | |
| raise NotImplementedError() | |
| def sweep(self, arguments: List[str]) -> Any: | |
| """ | |
| Execute a sweep | |
| :param arguments: list of strings describing what this sweeper should do. | |
| exact structure is determine by the concrete Sweeper class. | |
| :return: the return objects of all thy launched jobs. structure depends on the Sweeper | |
| implementation. | |
| """ | |
| ... | |
| def validate_batch_is_legal(self, batch: Sequence[Sequence[str]]) -> None: | |
| """ | |
| Ensures that the given batch can be composed. | |
| This repeat work the launcher will do, but as the launcher may be performing this in a different | |
| process/machine it's important to do it here as well to detect failures early. | |
| """ | |
| config_loader = ( | |
| self.hydra_context.config_loader | |
| if hasattr(self, "hydra_context") and self.hydra_context is not None | |
| else self.config_loader # type: ignore | |
| ) | |
| assert config_loader is not None | |
| assert self.config is not None | |
| for overrides in batch: | |
| config_loader.load_sweep_config( | |
| master_config=self.config, sweep_overrides=list(overrides) | |
| ) | |