Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative recursive defaults take3 #1170

Merged
merged 91 commits into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
4664dfb
--info defaults to show defaults list information
omry Oct 31, 2020
36a53ba
testing loading of raw defaults list from configs
omry Nov 23, 2020
82a3ee7
remove package header manipulation in example config source
omry Nov 23, 2020
a198217
some basic basic defaults tree are passing
omry Nov 23, 2020
1f3c8ee
initial nested defaults test passed
omry Nov 24, 2020
e194f1b
added tests for get_config_path and get_group_path
omry Nov 24, 2020
b1713a7
append tests for defaults tree
omry Nov 24, 2020
4d794e4
simple group override tests for defaults tree
omry Nov 24, 2020
06e52f2
tree_to_list dfs implementation
omry Nov 25, 2020
7b245fa
Computing package in result defaults list
omry Nov 25, 2020
b064f25
testing defaults tree with pacakge override in defaults list
omry Nov 26, 2020
d8909d2
testing result list for default-list package override cases
omry Nov 26, 2020
fe0c9ba
Tests overriding group option with non default package
omry Nov 26, 2020
1b5bdca
test include_nested_config_item_global
omry Nov 27, 2020
38063b0
support key@ \(empty package\) in the overrides parser
omry Nov 27, 2020
cdfc3be
test include_nested_group_global_
omry Nov 27, 2020
70fda95
added test for _global_.foo package override
omry Nov 27, 2020
fde7195
reorg tests a bit
omry Nov 27, 2020
d771357
testing _name_ package override
omry Nov 27, 2020
6df6b99
Testing primary config with a package header
omry Nov 28, 2020
5458eca
testing include_nested_group_pkg_header_foo
omry Nov 28, 2020
12db5bd
testing include_nested_group_pkg_header_foo:override_first_level
omry Nov 28, 2020
4cbbe20
Test for include_nested_group_pkg_header_foo:override_first_level_wit…
omry Nov 28, 2020
0f3ddbc
fixed pacakge header to be absolute + tests
omry Nov 28, 2020
571cd7e
test with both config header and defaults list pkg override
omry Nov 28, 2020
9225beb
Marked override in defaults list - same level
omry Nov 29, 2020
7dfd9c5
Test for overriding nested config groups from parent
omry Nov 29, 2020
00be420
testing external override of overrides in defaults list
omry Nov 30, 2020
ea7c2e5
testing two_group_defaults_different_pkgs
omry Nov 30, 2020
f8c9934
Support for adding hydra/config node
omry Nov 30, 2020
1c83e4c
Handling legacy hydra overrides in defaults list
omry Nov 30, 2020
035e722
Lint passing
omry Dec 1, 2020
4786d60
Experinent use case tests
omry Dec 1, 2020
9c8057d
test_experiment_as_primary_config
omry Dec 1, 2020
4f6795f
Testing config extension use cases
omry Dec 1, 2020
bc69ee7
Testing for cases with MISSING ('???') default element
omry Dec 2, 2020
2d18fe0
Support for placeholder defaults list element
omry Dec 2, 2020
d82036b
Interpolation support
omry Dec 2, 2020
ba068d0
Override delete support (~group, ~group=choice)
omry Dec 3, 2020
ba97a50
lint
omry Dec 3, 2020
56bf0fb
updated all tests to pass
omry Dec 4, 2020
48bbab6
Error handling
omry Dec 4, 2020
a79e1c4
support for missing optional configs
omry Dec 9, 2020
6ef22dc
removed package rename support from overrides
omry Dec 9, 2020
7fdddeb
handling _group_ in package header
omry Dec 9, 2020
748694e
more consistent hanlding of _group_ packages
omry Dec 9, 2020
1135e31
overriding file with global header
omry Dec 9, 2020
a3e7fa2
Handling None primary config
omry Dec 9, 2020
6c670a8
handling defaults list with more than one config item (not config group)
omry Dec 9, 2020
1b500d0
fixed config loader tests
omry Dec 9, 2020
6c099a5
fixed some hydra tests
omry Dec 10, 2020
88e4e96
fixed another hydra test
omry Dec 10, 2020
757a771
fixed completion tests
omry Dec 10, 2020
9b2fbe6
fixed configuring hydra example tests
omry Dec 10, 2020
1e22ed8
handling missing config in defaults list
omry Dec 10, 2020
db74897
proper handling of case where defaults list has only overrides
omry Dec 10, 2020
a4dffca
implement --info defaults
omry Dec 11, 2020
06ffc25
proper handling of _group_ package header
omry Dec 11, 2020
4263a4e
updated todo
omry Dec 11, 2020
c70a55f
fixed core tests in nox
omry Dec 11, 2020
ddbc0f2
Fixed plugin tests, examples and docs to use override: true
omry Dec 11, 2020
0a53e12
Partial integration
omry Dec 9, 2020
b2a53a3
removed composition trace printout (redundant)
omry Dec 11, 2020
c493a0e
added --info defaults-tree
omry Dec 12, 2020
22f0c19
enforces that overrids are last in the defaults list
omry Dec 12, 2020
dcbadd4
Cleaning up previous defaults list implementation
omry Dec 12, 2020
dbe0fd8
fixed to not try to load MISSING defaults
omry Dec 13, 2020
87d86d0
cleaning up package handling in low level config sources - WIP
omry Dec 14, 2020
3dda8d9
removed is_primary_config from config loading apis
omry Dec 15, 2020
68ff784
Clean up pacakge specific logic from config repository
omry Dec 15, 2020
af9fcfb
fixed hydra version in standalone test apps
omry Dec 15, 2020
bd8746f
Fixed error message in invalid overrides in defaults list
omry Dec 15, 2020
b10772d
fixed handling of group with keyword names
omry Dec 15, 2020
7fd0895
Moved missing primary config error to defaults_list
omry Dec 15, 2020
14bdc29
minor configloaderimpl cleanup
omry Dec 15, 2020
372544f
Added primary flag to ResultDefault
omry Dec 15, 2020
a63a19d
added hydra.choices node
omry Dec 15, 2020
68f2682
change default _self_ to end of defaults
omry Dec 16, 2020
d0cb554
removed print # @package _global from --cfg output
omry Dec 24, 2020
775d372
disabled defaults list interpoaltion in non-primary configs
omry Dec 25, 2020
20e47cd
fixing error message for disallowed override in interpolated config
omry Dec 25, 2020
f92a075
fixed interpolation for Config items
omry Dec 28, 2020
29d3f23
Improve error message on validation error during composition
omry Dec 28, 2020
2b857b6
moved defaults list test data
omry Dec 29, 2020
299efb0
fixed error for invalid group override in nested config
omry Dec 29, 2020
f51390c
improve --info
omry Dec 29, 2020
98fb628
improve --hydra-help
omry Dec 29, 2020
b36ecb8
Documentation update
omry Dec 26, 2020
337ee1a
minor updates to error messages
omry Jan 1, 2021
f86a90e
news fragments updated
omry Jan 1, 2021
cbd055f
updated todos.
omry Dec 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea
/temp
outputs
multirun
dist
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults:
- db: mysql
- server: apache
- optional server_db: ${server}_${db}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: apache
workers: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @package server
workers: 5
13 changes: 13 additions & 0 deletions examples/advanced/defaults_list_interpolation/my_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf

import hydra


@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))


if __name__ == "__main__":
my_app()
4 changes: 4 additions & 0 deletions examples/advanced/nested_defaults_list/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults:
- server/apache

debug: false
5 changes: 5 additions & 0 deletions examples/advanced/nested_defaults_list/conf/config2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
defaults:
- server/apache
- override server/db: sqlite

debug: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults:
- db: mysql

name: apache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: sqlite
13 changes: 13 additions & 0 deletions examples/advanced/nested_defaults_list/my_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf

import hydra


@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))


if __name__ == "__main__":
my_app()
2 changes: 1 addition & 1 deletion examples/configure_hydra/custom_help/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defaults:
- db: mysql
- hydra/help: my_app_help
- override hydra/help: my_app_help
2 changes: 1 addition & 1 deletion examples/configure_hydra/logging/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
defaults:
- hydra/job_logging: custom
- override hydra/job_logging: custom
3 changes: 3 additions & 0 deletions examples/patterns/configuring_experiments/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defaults:
- db: mysql
- server: apache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: mysql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @package _global_
defaults:
- override /db: sqlite


server:
port: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @package _global_
defaults:
- override /server: nginx
- override /db: sqlite

server:
port: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: apache
port: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: nginx
port: 80
13 changes: 13 additions & 0 deletions examples/patterns/configuring_experiments/my_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf

import hydra


@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))


if __name__ == "__main__":
my_app()
2 changes: 2 additions & 0 deletions examples/patterns/extending_configs/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
defaults:
- db: ???
4 changes: 4 additions & 0 deletions examples/patterns/extending_configs/conf/db/base_mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
host: localhost
port: 3306
user: ???
password: ???
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defaults:
- /db_schema/base_mysql@_here_

user: omry
password: secret
port: 3307
encoding: utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defaults:
- base_mysql

user: omry
password: secret
port: 3307
encoding: utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
host: localhost
port: 3306
user: ???
password: ???
13 changes: 13 additions & 0 deletions examples/patterns/extending_configs/my_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from omegaconf import DictConfig, OmegaConf

import hydra


@hydra.main(config_path="conf", config_name="config")
def my_app(cfg: DictConfig) -> None:
print(OmegaConf.to_yaml(cfg))


if __name__ == "__main__":
my_app()
3 changes: 1 addition & 2 deletions examples/patterns/specializing_config/conf/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
defaults:
- dataset: imagenet
- model: alexnet
- dataset_model: ${dataset}_${model}
optional: true
- optional dataset_model: ${dataset}_${model}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from copy import copy
from typing import Any, Dict, List, Optional

from hydra.core.object_type import ObjectType
Expand Down Expand Up @@ -27,12 +26,8 @@ def __init__(self, provider: str, path: str):
"primary_config_with_non_global_package.yaml": {"primary": True},
"config_without_group.yaml": {"group": False},
"config_with_unicode.yaml": {"group": "数据库"},
"dataset/imagenet.yaml": {
"dataset": {"name": "imagenet", "path": "/datasets/imagenet"}
},
"dataset/cifar10.yaml": {
"dataset": {"name": "cifar10", "path": "/datasets/cifar10"}
},
"dataset/imagenet.yaml": {"name": "imagenet", "path": "/datasets/imagenet"},
"dataset/cifar10.yaml": {"name": "cifar10", "path": "/datasets/cifar10"},
"level1/level2/nested1.yaml": {"l1_l2_n1": True},
"level1/level2/nested2.yaml": {"l1_l2_n2": True},
"package_test/explicit.yaml": {"foo": "bar"},
Expand All @@ -47,7 +42,7 @@ def __init__(self, provider: str, path: str):
},
"configs_with_defaults_list/global_package.yaml": {
"defaults": [{"foo": "bar"}],
"configs_with_defaults_list": {"x": 10},
"x": 10,
},
"configs_with_defaults_list/group_package.yaml": {
"defaults": [{"foo": "bar"}],
Expand All @@ -60,37 +55,24 @@ def scheme() -> str:
return "example"

def load_config(
self,
config_path: str,
is_primary_config: bool,
package_override: Optional[str] = None,
self, config_path: str, package_override: Optional[str] = None
) -> ConfigResult:
normalized_config_path = self._normalize_file_name(config_path)
name = self._normalize_file_name(config_path)

if normalized_config_path not in self.configs:
if name not in self.configs:
raise ConfigLoadError("Config not found : " + config_path)
header = (
copy(self.headers[normalized_config_path])
if normalized_config_path in self.headers
else {}
)
if "package" not in header:
header["package"] = ""

self._update_package_in_header(
header=header,
normalized_config_path=normalized_config_path,
is_primary_config=is_primary_config,
package_override=package_override,
)
cfg = OmegaConf.create(self.configs[normalized_config_path])
defaults_list = self._extract_defaults_list(config_path=config_path, cfg=cfg)
res_header: Dict[str, Optional[str]] = {"package": None}
if name in self.headers:
header = self.headers[name]
res_header["package"] = header["package"] if "package" in header else None

cfg = OmegaConf.create(self.configs[name])
return ConfigResult(
config=self._embed_config(cfg, header["package"]),
config=cfg,
path=f"{self.scheme()}://{self.path}",
provider=self.provider,
header=header,
defaults_list=defaults_list,
header=res_header,
)

def available(self) -> bool:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defaults:
- hydra/launcher: example
- db: mysql
- override hydra/launcher: example
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ class TestExampleLauncher(LauncherTestSuite):

@pytest.mark.parametrize(
"task_launcher_cfg, extra_flags",
[
(
{
"defaults": [
{"hydra/launcher": "example"},
{"hydra/hydra_logging": "hydra_debug"},
{"hydra/job_logging": "disabled"},
],
},
["-m"],
)
],
[({}, ["-m", "hydra/launcher=example"])],
)
class TestExampleLauncherIntegration(IntegrationTestSuite):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
defaults:
- hydra/sweeper: example
- db: mysql
- override hydra/sweeper: example
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,13 @@ class TestExampleSweeperWithBatching(BatchedSweeperTestSuite):
"task_launcher_cfg, extra_flags",
[
(
{
"defaults": [
{
# CHANGE THIS TO YOUR SWEEPER CONFIG NAME
"hydra/sweeper": "example"
},
{"hydra/launcher": "basic"},
{"hydra/hydra_logging": "hydra_debug"},
{"hydra/job_logging": "disabled"},
],
"hydra": {},
},
["-m"],
{},
[
"-m",
# CHANGE THIS TO YOUR SWEEPER CONFIG NAME
"hydra/sweeper=example",
"hydra/launcher=basic",
],
)
],
)
Expand Down
Loading