Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordinary reference as value ? #61

Open
witwolf opened this issue Mar 29, 2020 · 0 comments
Open

Ordinary reference as value ? #61

witwolf opened this issue Mar 29, 2020 · 0 comments

Comments

@witwolf
Copy link

witwolf commented Mar 29, 2020

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)

  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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant