Calmcode - gin: required settings

Required Settings

1 2 3 4 5

You can configure gin to force a setting. This is useful when you'd like a setting to be required. The files below show you how to set this up.

config.gin

simulate.n_samples = 200

simulate.py

import gin
import random

@gin.configurable
def simulate(n_samples=gin.REQUIRED)
    return sum(random.random() for i in range(n_samples))

if __name__ == "__main__":
    gin.parse_config_file("config.gin")
    print(simulate())