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

Breaking change - Hydra 1.1 Upgrade : "Missing @Package directive" #529

Closed
JackUrb opened this issue Aug 26, 2021 · 2 comments
Closed

Breaking change - Hydra 1.1 Upgrade : "Missing @Package directive" #529

JackUrb opened this issue Aug 26, 2021 · 2 comments

Comments

@JackUrb
Copy link
Contributor

JackUrb commented Aug 26, 2021

Overview

After the 0.4.0 version, we expect usage of Hydra 1.1. This will break your user scripts, and requires an update. In short, you should move your config files to a hydra_configs subfolder of your project folder, and then update your script's @hydra.main to set config_path="hydra_configs". #494 demonstrates these changes for our existing scripts.

Remediation steps

For any script that is pulling in configuration from yaml files (like commonly done from a conf directory inside the same directory as the script) you'll need to make a containing hydra_configs directory (or whatever you may want to name it, though this is the name our warnings look for).

# Before
my_project_dir
> conf
>> my_conf.yaml
> my_cool_script.py

# After
my_project_dir
> hydra_configs
>> conf
>>> my_conf.yaml
> my_cool_script.py

You'll then want to update the @hydra.main decorator to include this location:

# Before
@hydra.main(config_name='scriptconfig')
def main(cfg: DictConfig) -> None:

# After
@hydra.main(config_path="hydra_configs", config_name='scriptconfig')
def main(cfg: DictConfig) -> None:

Details

Unfortunately there's no way for me to catch these errors in user scripts, I apologize for the disruption here. Hopefully this issue can centralize discussion! I believe without this change Hydra no longer looks for the hydra configuration scripts at the default package level if no config path is given, leading to some missing package directive. Please be sure to rerun setup.py for the project after pulling to be sure you have the most up-to-date version. Reach out here if 0.4.0 is causing you issues otherwise!

@kushalchawla
Copy link

kushalchawla commented Sep 17, 2021

Hey @JackUrb

Thanks for this. In addition to the above remediation steps, I also found this to be helpful as well. Particularly, there is an additional step of adding '_self_' to the defaults to suppress the warning. You might want to include that over here as well.

@JackUrb JackUrb unpinned this issue Jan 26, 2022
@JackUrb
Copy link
Contributor Author

JackUrb commented Jan 26, 2022

Closing as I imagine enough time has passed that people have already migrated.

@JackUrb JackUrb closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants