classmethod BaseModel.from_dict(input_dict, raise_on_extra=False)[source]

Construct a dataclass from the given dict, matching keys with the class fields. A KeyError is raised for any missing values. If raise_on_extra is True, an errors is raised if keys of the dict are also not fields of the dataclass. For pandas.Timedelta model fields, it is assumed input_dict contains a number representing minutes. For datetime.time model fields, input_dict values are assumed to be strings in the %H:%M format. If a modeling_parameters field is present, the modeling_parameters key from input_dict is automatically parsed into the appropriate PVModelingParameters subclass based on tracking_type.

  • input_dict (dict) – The dict to process into dataclass fields
  • raise_on_extra (boolean, default False) – If True, raise an exception on extra keys in input_dict that are not dataclass fields.

model (subclass of BaseModel) – Instance of the desired model.

  • KeyError – For missing required fields or if raise_on_extra is True and input_dict contains extra keys.
  • ValueError – If a pandas.Timedelta, pandas.Timestamp, datetime.time, or modeling_parameters field cannot be parsed from the input_dict