๐Defining of A Config Function
A hypster config
function is the heart of this framework. It requires of 3 main components:
1
2
3
Body
@config
def my_config(hp: HP):
from package import Class
var = hp.select(["a", "b", "c"], default="a")
num = hp.number(10)
text = hp.text("Hey!")
instance = Class(var=var, num=num, text=text)
Hypster comes with the following HP calls:
hp.select()
andhp.multi_select()
for categorical choiceshp.int()
andhp.multi_int()
for integer valueshp.number()
andhp.multi_number()
for numeric valueshp.text()
andhp.multi_text()
for string valueshp.bool()
andhp.multi_bool()
for boolean values
Please note:
All imports must be defined inside the body of the function. This enables the portability of hypster's configuration object.
Saving & Loading Config Functions
Save configurations to reuse them across projects:
# Save directly from config function
my_config.save("configs/my_config.py") # Creates directories if needed
# Save using hypster.save
from hypster import save
save(my_config, "configs/nested/my_config.py")
Loading Configurations
Load saved configurations in two ways:
# Method 1: Direct loading
from hypster import load
my_config = load("configs/my_config.py")
# Method 2: Load for nesting
@config
def parent_config(hp: HP):
nested_config = hp.nest("configs/my_config.py")
Last updated
Was this helpful?