-
-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
For example:
from jax.nn.initializers import Initializer, uniform
from jsonargparse import ArgumentParser
from dataclasses import dataclass
@dataclass
class Model:
name: str = "default"
init: Initializer = uniform(0.5)
parser = ArgumentParser()
parser.add_argument("--m", type=Model)
args = parser.parse_args(
[
"--m.name",
"abc",
"--m.init",
'{"class_path": "jax.nn.initializers.constant", "init_args": {"value": -7}}',
]
)error: Parser key "m.init":
Import path jax.nn.initializers.constant does not implement protocol Initializer
Here Initializer is just a Callable Protocol.
Based on the doc:
Callable is supported by either giving a dot import path to a callable object or by giving a dict with a class_path and optionally init_args entries. The specified class must either instantiate into a callable or be a subclass of the return type of the callable.
I think my case above belongs the latter one: by giving a dict with a class_path and optionally init_args entries. However, based on the error message it seems to be checking the class_path instead of the instantiated result.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working