-
Hi, I am working through the tutorials to get a better feel for hydra-zen, but I confused about how to use it with hydra compose instead of hydra.main. For example the code below is a trimmed down version of the tutorial Provide Swappable Configuration Groups with my attempts to get it working without success: from hydra_zen import store, make_custom_builds_fn, zen
from game_library import inventory, Character
builds = make_custom_builds_fn(populate_full_signature=True)
# Create inventory configs
InventoryConf = builds(inventory)
starter_gear = InventoryConf(gold=10, weapon="stick", costume="tunic")
advanced_gear = InventoryConf(gold=500, weapon="wand", costume="magic robe")
# Register inventory configs under group: player/inventory
inv_store = store(group="player/inventory")
inv_store(starter_gear, name="starter")
inv_store(advanced_gear, name="advanced")
# Create player-profile configs
CharConf = builds(Character, inventory=starter_gear)
brinda_conf = CharConf(name="brinda", level=47, inventory=InventoryConf(costume="cape", weapon="flute", gold=52))
# Register player-profile configs under group: player
player_store = store(group="player")
player_store(CharConf, name="base")
player_store(brinda_conf, name="brinda")
# We need to add the configs from our local store to Hydra's global config store
store.add_to_hydra_store()
# FIXME: following code not working...
from hydra import initialize, compose
with initialize(config_path=None):
cfg = compose(config_name="zen_store") # using store.name here, (guessing as unsuccessful) In the final few lines of the code following the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think you need to specify a name that you gave a specific config when putting it in the config store. Specifying "zen_store" doesn't make sense here, as that doesn't reference any particular config. |
Beta Was this translation helpful? Give feedback.
-
There is no config # ... same code above this line
store(
make_config(
hydra_defaults=[
"_self_",
{"player": "base"},
],
player=None,
),
name="config"
)
# We need to add the configs from our local store to Hydra's global config store
store.add_to_hydra_store()
from hydra import initialize, compose
with initialize(config_path=None, version_base="1.3"):
cfg = compose(config_name="config", overrides=["player=brinda"])
print(cfg) |
Beta Was this translation helpful? Give feedback.
There is no config
zen_store
. You need to create a config: