-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Could a subclass type hint be a config file when using CLI? #57
Comments
Could you please add information about how you are creating the parser. Would be even better if it is a small code snippet that can be easily run. Right now I am not sure if this can be easily implemented. Though in general I think this is not a good idea. The # main.yaml
input: input/keyboard.yaml # keyboard.yaml
class_path: src.input.KeyBoard
init_args:
arg1: val1
... Or maybe what you want is have a configurable class (not a subclass), so |
Thanks for your replying. I create a small case like #main.py
from jsonargparse import CLI
class B:
def __init__(self, meta_info: dict):
self.meta_info = meta_info
class A:
def __init__(self, b: B = None, a_lot_of_params: dict=None):
self.b = b
self.a_lot_of_params = a_lot_of_params
def hello(self):
print('I am ok')
if __name__ == "__main__":
CLI(A) #cfg.yaml
b: b.yaml
a_lot_of_params:
a: 1
b: 2 #b.yaml
class_path: __main__.B
init_args:
meta_info:
something: true
others: 1 By running
|
If you change line signatures.py#L295 to |
init_args
be a config file?
Got it. Thank you very much! |
OK. I find that in a more complicated situation, it still fails.
And the error is
|
With the code snippet above I am unable to reproduce that error message. Furthermore, class components given to |
… CLI #57. - With fail_untyped=True use type from default value instead of Any. - Added ruyaml optional unit tests.
I am not sure what you are trying to achieve. If you want to be able to run |
Sorry for the late reply. I am on a deadline and unable to deal with it now. I think I can close the issue and process it after my deadline. Thank you very much. |
I want to load a config file with the structure like:
But it would not parse the file specified in
init_args
as aDict
. I also try to write it asand it still does not work. Is there any way to implement such function?
The text was updated successfully, but these errors were encountered: