Skip to content

ods_tools 5.0.1 crashes on OED v3.0.0 to 3.0.3 #236

@carlfischerjba

Description

@carlfischerjba

Error when using OedExposure to load an OED file with check_oed=True and OED 3.0.0, 3.0.1, 3.0.2 or 3.0.3.

Works fine with check_oed=False or with versions of OED 3.0.4 or greater.

In [1]: from ods_tools.oed import OedExposure

In [2]: exposure_file_path='.../data/curve_generator/inputs/exposures.csv'

In [3]: OedExposure(location=exposure_file_path, check_oed=True)
oed check:  80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                | 8/10 [00:00<00:00, 340.30it/s]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 OedExposure(location=exposure_file_path, check_oed=True)

File ~/venvs/.../lib/python3.12/site-packages/ods_tools/oed/exposure.py:175, in OedExposure.__init__(self, location, account, ri_info, ri_scope, oed_schema_info, additional_fields, currency_conversion, reporting_currency, class_of_business, check_oed, use_field, validation_config, working_dir, location_numbers, account_numbers, portfolio_numbers, base_df_engine, exposure_df_engine, backend_dtype, **kwargs)
    172     self.working_dir = working_dir
    174 if check_oed:
--> 175     self.check()

File ~/venvs/.../lib/python3.12/site-packages/ods_tools/oed/exposure.py:531, in OedExposure.check(self, validation_config)
    529     validation_config = self.validation_config
    530 validator = Validator(self)
--> 531 return validator(validation_config)

File ~/venvs/.../lib/python3.12/site-packages/ods_tools/oed/validator.py:78, in Validator.__call__(self, validation_config)
     76     continue
     77 if hasattr(check_fct, '__call__'):
---> 78     invalid_data_group.setdefault(check['on_error'], []).extend(check_fct())
     79 else:
     80     raise OdsException('Unknown check name ' + str(check['name']))

File ~/venvs/.../lib/python3.12/site-packages/ods_tools/oed/validator.py:318, in Validator.check_conditional_requirement(self)
    316 invalid_data = []
    317 for oed_source in self.exposure.get_oed_sources():
--> 318     cr_field = self.exposure.oed_schema.schema['cr_field'].get(oed_source.oed_type)
    319     if not cr_field:
    320         continue

AttributeError: 'list' object has no attribute 'get'

In [5]: import ods_tools

In [6]: ods_tools.__version__
Out[6]: '5.0.1'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions