-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Configuration check failed :: No action for destination key to check its value #10859
Comments
For us to debug this, it would be best if you can create a minimal script or repository that reproduces the problem. |
archs.py
boring.py
a.yaml
train:
error reported:
Here in the error the key |
@carmocca Hi, I gave the boring model, and the train command, and error. pls, check it |
I am facing the same issue in my project too. I have something like this:
And the error I'm getting is this:
|
I found the solution to my problem. I had to decorate my config class with
|
cc @mauvilsa as I think it's a bug upstream Repro without the CLI: from unittest import mock
from jsonargparse import ArgumentParser
class Arch:
def __init__(self, a: int = 1) -> None:
pass
class ArchB(Arch):
def __init__(self, a: int = 2, b: int = 3) -> None:
print(f"ArchB, {a=}, {b=}")
class ArchC(Arch):
def __init__(self, a: int = 4, c: int = 5) -> None:
print(f"ArchC, {a=}, {c=}")
parser = ArgumentParser()
parser_subcommands = parser.add_subcommands()
subparser = ArgumentParser()
subparser.add_argument("--arch", type=Arch)
parser_subcommands.add_subcommand("fit", subparser)
default = {"class_path": "__main__.ArchB"}
subparser.set_defaults({"arch": default})
value = {"class_path": "__main__.ArchC", "init_args": {"a": "10", "c": "11"}}
with mock.patch("sys.argv", ["any.py", "fit", "--arch", str(value)]):
args = parser.parse_args() # 'Configuration check failed :: No action for destination key "b" to check its value.' If you comment Version without subcommandsfrom unittest import mock
from jsonargparse import ArgumentParser
class Arch:
def __init__(self, a: int = 1) -> None:
pass
class ArchB(Arch):
def __init__(self, a: int = 2, b: int = 3) -> None:
print(f"ArchB, {a=}, {b=}")
class ArchC(Arch):
def __init__(self, a: int = 4, c: int = 5) -> None:
print(f"ArchC, {a=}, {c=}")
parser = ArgumentParser()
parser.add_argument("--arch", type=Arch)
default = {"class_path": "__main__.ArchB"}
parser.set_defaults({"arch": default})
value = {"class_path": "__main__.ArchC", "init_args": {"a": "10", "c": "11"}}
with mock.patch("sys.argv", ["any.py", "--arch", str(value)]):
args = parser.parse_args()
print(args) # Namespace(arch=Namespace(class_path='__main__.ArchC', init_args=Namespace(a=10, c=11))) |
Yes, looks like a bug upstream. Will look at it. |
And I find another problem similar to this one. specify the profiler's arguments not in BaseProfiler trainer:
profiler:
class_path: pytorch_lightning.profiler.PyTorchProfiler
init_args:
with_flops: true # PyTorchProfiler: **profiler_kwargs
... The error reported:
|
The cause for this is different and not a bug. This is explained in #8561 (comment). |
I just released jsonargparse v4.1.1 which fixes the bug. |
Great! ^^ |
🐛 Bug
Hi, I found a bug when the default class for CLI is not the same with the class specified in config file, an error will report for the keys belonging to the default class but not belonging to the specified class
This is the class specified in config file:
and its
__init__
:The default class specified in CLI:
and its
__init__
:The command and error:
The reported key
dropout
is not a key for the class in the config file, it's a key for the default class. That's not right.To Reproduce
Expected behavior
Environment
conda
,pip
, source):torch.__config__.show()
:Additional context
cc @carmocca @mauvilsa
The text was updated successfully, but these errors were encountered: