pyaerocom icon indicating copy to clipboard operation
pyaerocom copied to clipboard

Arguments given in VarWebScaleAndColormap may not be going through pydantic

Open lewisblake opened this issue 1 year ago • 2 comments

Describe the bug

There are two __init__ methods in this class. Only the second one is being used. This means that the pydantic checking is not being used. One way to test this is to try and give VarWebScaleAndColormap arguments which are not scale and colmap

  • Pyaerocom version: 0.21.dev0
  • Computing platform: All
  • Configuration file (if applicable): NA
  • Error message (if applicable): NA

Relevant PR: #1256

lewisblake avatar Jul 30 '24 12:07 lewisblake

They aren't being passed correctly. Pydantic should've yelled at me:

from pyaerocom.aeroval.glob_defaults import VarWebScaleAndColormap
test = VarWebScaleAndColormap({"blah": {"blah": ["a", "b", "c"], "blub": ["d", "e", "f"]}})

lewisblake avatar Jul 30 '24 13:07 lewisblake

@heikoklein just want to put this on your radar

lewisblake avatar Oct 07 '24 12:10 lewisblake

The first argument to VarWebScaleAndColormap is an optional string/filename, not a dict. Unfortunately, the config-parser does not raise a FileNotFoundError when something strange is given. I will fix that and add more tests.

What you wanted to do is to add a dict directly by kwargs, i.e. add two asterisks:

VarWebScaleAndColormap(**{"blah": {"blah": ["a", "b", "c"], "blub": ["d", "e", "f"]}})

heikoklein avatar Nov 08 '24 13:11 heikoklein