gin-config
gin-config copied to clipboard
Import module with alias
A project I am working on has many modules and significant module depth. I would like to configure parameters in a number of functions and classes throughout the project using a gin file located in the root directory.
For a function foo
located in module a.b.c.d
I would like to set a number of function arguments. For module names longer than single letters, it seems a bit overwhelming to write the whole module path for each argument. Instead, I would like to import the module using an alias.
# Found in gin file
import a.b.c.d as m
m.foo.x = 4
m.foo.y = 2
Doing so gives me this error
^
SyntaxError: Expected newline.
I assume that this failure is because the parser does not currently support module aliases.
Yeah currently gin files doesn't support model aliases, since the import is just used to make sure the configurables are defined.
But Gin allows to use shorter names if there is no conflicts, examples:
import a.b.c.d
foo.x = 4
foo.y = 2
# Or
d.foo.x = 4
d.foo.y = 2