google / google/gin-config

Ordinary reference as value ?

Open
#61 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.2k
Forks
122
Avg merge
5d 10h
Merged PRs (30d)
2

Description

Now, gin config support `configurable reference`, `macro` , `basic type (str, bool, number)` or `nested of them` as value . It would be great if we can refer to local variable (module, class ,function)

```pthon
def testLocalVariableReference(self):
config_str = """
configurable2.non_kwarg = a
"""
config.parse_config(config_str)

a = 1
instance, _ = configurable2() # pylint: disable=no-value-for-parameter
self.assertEqual(instance, a)

a = 2
instance, _ = configurable2() # pylint: disable=no-value-for-parameter
self.assertEqual(instance, a)

def testUnregisteredFunction(self):
config_str = """
configurable2.non_kwarg = numpy.abs
"""
config.parse_config(config_str)
import numpy
instance, _ = configurable2() # pylint: disable=no-value-for-parameter
self.assertEqual(instance, numpy.abs)
```

without this , we make all function that may refer to to be configurable explicited by `gin.external_configurable` , it seems not reasonable .
see `gin.tf` and `gin.torch`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.