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

[Feature Request] Mixing _global_ / _here_ / _package_ #1913

Open
YannDubs opened this issue Dec 3, 2021 · 3 comments
Open

[Feature Request] Mixing _global_ / _here_ / _package_ #1913

YannDubs opened this issue Dec 3, 2021 · 3 comments
Labels
enhancement Enhanvement request exploratory wishlist Low priority feature requests

Comments

@YannDubs
Copy link
Contributor

YannDubs commented Dec 3, 2021

🚀 Feature Request

Allow the use of packages inise of the yaml. E.g.

# this is local
is_local: True

_global_: # Special keyword that says that it's global
  outside:
    is_global: True

or equivalently

# @package _global_

# this is local
_here_: # Special keyword that says that it's local
  is_local: True

# this is global because it's the default package
outside:
  is_global: True

Motivation

I often reuse a lot of my configs for different parts of the programs to avoid duplicating code, so I often use something like X@Y: Z but currently I don't really know how to deal with cases where Z has to make global and local changes. Because if I use # @package _global_ then I can't change locally Y but if I use the default package I can't change global configs.

I think it would be nice to have a way of mixing _here_ and _global_ in a single config. Another way of achieving this would be to be able to use multiple packages in one yaml e.g.,

# @package _here_
is_local: True

# @package _global_

outside:
  is_global: True

Although that seems less natural.

My current workarounds to split the yaml into the global and the local ones, but that's less readable and you end up with a lot of different configs.

@YannDubs YannDubs added the enhancement Enhanvement request label Dec 3, 2021
@Jasha10
Copy link
Collaborator

Jasha10 commented Dec 4, 2021

Hi @YannDubs,

Thanks for sharing this idea.

Introducing a new keyword to Hydra's config composition would be a big step, so we'd have to consider carefully whether it's the right direction for Hydra long-term. I'm also concerned that the implementation would be challenging.

I'll put this on the wishlist for now.

@dhruvdcoder
Copy link

I often end up with lots of small configs and nested folders. This feature would be very helpful in improving the readability and maintainability.

@max-sixty
Copy link

Old issue, but FWIW, I would have found this much easier to understand by using an actual value in the YAML for the equivalent of # @package foo.bar.

Giving YAmL comments semantic meaning isn't what I would have expected and isn't consistent with the rest of Hydra — there's plenty of prior art for "special" keys in Hydra, such as _self_ etc. So the original suggestion of something like:

_global_: # Special keyword that says that it's global
  outside:

...mades a lot of sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhanvement request exploratory wishlist Low priority feature requests
Projects
None yet
Development

No branches or pull requests

4 participants