Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
Created September 24, 2023 06:17
Show Gist options
  • Save OhadRubin/4bd4dedbab23d79c84b4b76d257929c7 to your computer and use it in GitHub Desktop.
Save OhadRubin/4bd4dedbab23d79c84b4b76d257929c7 to your computer and use it in GitHub Desktop.
A simple example of using gin with absl
import fire
import gin
from absl import flags
from absl import app
flags.DEFINE_multi_string(
'gin_file', None, 'List of paths to the config files.')
flags.DEFINE_multi_string(
'gin_param', None, 'Newline separated list of Gin parameter bindings.')
FLAGS = flags.FLAGS
@gin.configurable
def double(number, const=2):
return const * number
def main(argv) -> None:
gin.parse_config_files_and_bindings(FLAGS.gin_file, FLAGS.gin_param)
print(double(2))
if __name__ == "__main__":
app.run(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment