-
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example compose callback and test
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
tests/test_apps/app_with_callbacks/app_with_log_compose_callback/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved |
14 changes: 14 additions & 0 deletions
14
tests/test_apps/app_with_callbacks/app_with_log_compose_callback/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
age: 7 | ||
name: James Bond | ||
|
||
hydra: | ||
job: | ||
name: test | ||
callbacks: | ||
log_compose: | ||
_target_: hydra.experimental.callbacks.LogComposeCallback | ||
|
||
defaults: | ||
- config_schema | ||
- _self_ | ||
- group: a |
1 change: 1 addition & 0 deletions
1
tests/test_apps/app_with_callbacks/app_with_log_compose_callback/group/a.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name: a |
32 changes: 32 additions & 0 deletions
32
tests/test_apps/app_with_callbacks/app_with_log_compose_callback/my_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved | ||
from dataclasses import dataclass | ||
from typing import Dict | ||
|
||
from omegaconf import MISSING | ||
|
||
import hydra | ||
from hydra.core.config_store import ConfigStore | ||
from hydra.core.hydra_config import HydraConfig | ||
|
||
|
||
@dataclass | ||
class Config: | ||
age: int = MISSING | ||
name: str = MISSING | ||
group: Dict[str, str] = MISSING | ||
|
||
|
||
ConfigStore.instance().store(name="config_schema", node=Config) | ||
ConfigStore.instance().store(name="config_schema", node=Config, group="test") | ||
|
||
|
||
@hydra.main(version_base=None, config_path=".", config_name="config") | ||
def my_app(cfg: Config) -> None: | ||
print( | ||
f"job_name: {HydraConfig().get().job.name}, " | ||
f"name: {cfg.name}, age: {cfg.age}, group: {cfg.group['name']}" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
my_app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters