Skip to content

Error when instantiating Logger with **kwargs only arguments via CLI (NeptuneLogger) #17976

Open
@verginer

Description

@verginer

I am running a model via the CLI interface and instantiating the Logger class using the class_path and init_args format. It works well when the parameters are explicitly defined in the __init__ method, but it does not work for parameters that are only provided as keyword arguments (kwargs). In the case of the NeptuneLogger, the neptune_run_kwargs parameters such as tags raise an error during the instantiation of the logger.

What version are you seeing the problem on?

v2.0

How to reproduce the bug

python train.py fit -c config/model.yaml

The model.yaml file looks like this:

trainer:
    logger:
        class_path: lightning.pytorch.loggers.NeptuneLogger
        init_args:
            project: "<project/name>"
            tags:
                - "mlp"
                - "fast-dev"

Error messages and logs

train_embedseq.py: error: Parser key "trainer.logger":
  Does not validate against any of the Union subtypes
  Subtypes: (<class 'lightning.pytorch.loggers.logger.Logger'>, typing.Iterable[lightning.pytorch.loggers.logger.Logger], <class 'bool'>, <class 'NoneType'>)
  Errors:
    - Problem with the given class_path 'lightning.pytorch.loggers.NeptuneLogger':
        'Configuration check failed :: No action for destination key "tags" to check its value.'
    - Expected a <class 'collections.abc.Iterable'>
    - Expected a <class 'bool'>
    - Expected a <class 'NoneType'>
  Given value type: <class 'jsonargparse.namespace.Namespace'>
  Given value: Namespace(class_path='lightning.pytorch.loggers.NeptuneLogger', init_args=Namespace(api_key=None, project='verginer/nlpatent', name=None, log_model_checkpoints=True, prefix='mlp', tags=['embed-seq']))

Environment

No response

More info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingver: 2.0.xwaiting on authorWaiting on user action, correction, or update

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions