Is it a good practice to have the config dictionar...
# hamilton-help
h
Is it a good practice to have the config dictionary as a parameter to my function code? I was thinking to keep my functions not aware of the configuration
🙌 1
s
Great question. Depends on your design and how many config parameters there, and are they used by all functions etc. How often things are changing, etc. If functions just take in the parameters they need, you don't need a config object:
Copy code
def my_func_a(param1: str) -> ...:

def my_func_b(param2: int) -> ...:
then you could do:
Copy code
config_params: dict[str, Any] = function_to_load_config_parameters(...)

dr = driver.Builder().with_modules(...).build()

result = dr.execute(["output1", ...], inputs=config_params)
Now this means a little more work if parameters change (but should be easy search & replace), but it's clear what depends on what at all times. You could instead pass in the config_params object -- but that can hinder knowing what is used. And then there is a spectrum in between where you pass in the config object to one function, and then break it apart for downstream use...
👍 1
h
Thanks Stefan for this informative answer