Help with "Design a Hierarchical Interface for an Application" Tutorial #407
Replies: 2 comments 8 replies
-
I was able to get the code to work without the need for the from hydra_zen import store, zen, builds, make_config
from game_library import inventory, Character
# Inventory config
starter_gear = builds(inventory, gold=10, weapon="stick", costume="tunic")
# Character config
CharConf = builds(Character, inventory=starter_gear, populate_full_signature=True)
player_store = store(group="player")
player_store(CharConf, name="base")
# Task function
def task_function(player: Character):
print(player)
with open("player_log.txt", "a") as f:
f.write("Game session log:\n")
f.write(f"Player: {player}\n")
return player
# Add top-level config to store
store(
make_config(
hydra_defaults=["_self_", {"player":"base"}],
player=None,
),
name="my_app",
)
if __name__ == "__main__":
store.add_to_hydra_store()
zen(task_function).hydra_main(config_name="my_app",
version_base="1.1",
config_path=".",
) Edit: Just noticed that the output |
Beta Was this translation helpful? Give feedback.
-
I'll take a look at this later today in more detail. But at first glance of your initial post I'm a bit confused, In the last comment, you have |
Beta Was this translation helpful? Give feedback.
-
Hey all,
Since there are multiple ways to do things, today I wanted to see if could alter the version of
my_app.py
from the "Design a Hierarchical Interface for an Application" tutorial. There are two alterations that I wanted to make but at the moment I have been unsuccessful with both.launch()
instead of using the CLI@store
decorator. I got nowhere real fast with this. I think this stems from not really knowing why the tutorials switched to using this decorator in the first place. In other words, what does using this decorator afford us that wasn't previously doable? I wanted write things without the decorator for a couple reasonsBut the decorator obfuscates this understanding; the decorator does some config work that I don't follow, and hence can't get around. From the error messages I have been seeing, I suspect that it has to do with how different things are given default values.
Not a top concern for me at the moment, but the tutorial introduces the use of
hydra_zen.make_custom_builds_fn()
without much explanation. The one thing I was able to successfully do was to usehydra_zen.builds()
instead.Revisiting using
launch()
: I was never able to run the code as stated in the tutorial. For one, the tutorial refers toConfig
which is never defined withinmy_app.py
. Here is my attempt to implementlaunch()
If I run this I get the following error message:
It looks to me that I have an issue regarding how to set default values. I tried a few version of the code (you can tell from some code that is commented out, for example), but no luck.
Thanks,
Francisco
Beta Was this translation helpful? Give feedback.
All reactions