From 7abca196973fc756fce47fcda3bb7e8259cec4a3 Mon Sep 17 00:00:00 2001 From: sambles Date: Thu, 9 Nov 2023 13:15:17 +0000 Subject: [PATCH] Release 3.0.8 (#75) * Set package to version 3.0.8 * Fix/forex case error (#70) * fix case to detect the correct column when doing a currency conversion * add list option to create currency conversion object * pep8 update * Fix publish * Update changelog --------- Co-authored-by: awsbuild Co-authored-by: Stephane Struzik <34556337+sstruzik@users.noreply.github.com> --- .github/workflows/publish.yml | 2 +- CHANGELOG.rst | 6 ++++++ ods_tools/__init__.py | 2 +- ods_tools/oed/forex.py | 20 ++++++++++++-------- tests/test_ods_package.py | 12 ++++++------ 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eb6f034b..559ba7cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -268,7 +268,7 @@ jobs: echo "run_status=${{ job.status }}" >> $GITHUB_OUTPUT slack: - uses: OasisLMF/OasisLMF/.github/workflows/notify.yml@master + uses: OasisLMF/OasisLMF/.github/workflows/notify.yml@main secrets: inherit needs: release with: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 82faf0d5..285fdd16 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ ODS_Tools Changelog =================== +`3.0.8`_ + --------- +* [#51](https://github.com/OasisLMF/ODS_Tools/pull/51) - Update CI for stable 3.0.x +* [#70](https://github.com/OasisLMF/ODS_Tools/pull/70) - Fix/forex case error +.. _`3.0.8`: https://github.com/OasisLMF/ODS_Tools/compare/3.0.7...3.0.8 + `3.0.7`_ --------- * [#42](https://github.com/OasisLMF/ODS_Tools/pull/43) - ods_tools check crashes on empty location file diff --git a/ods_tools/__init__.py b/ods_tools/__init__.py index 13ddfd43..3d5e5c67 100644 --- a/ods_tools/__init__.py +++ b/ods_tools/__init__.py @@ -1,4 +1,4 @@ -__version__ = '3.0.7' +__version__ = '3.0.8' import logging diff --git a/ods_tools/oed/forex.py b/ods_tools/oed/forex.py index 7fa2c7d6..48272e60 100644 --- a/ods_tools/oed/forex.py +++ b/ods_tools/oed/forex.py @@ -192,8 +192,10 @@ def get_path(name): elif currency_conversion.get("source_type") == 'parquet': return DictBasedCurrencyRates.from_parquet(get_path('file_path'), **currency_conversion.get("read_parameters", {})) - elif currency_conversion.get("source_type", '').lower() == 'dict': + elif currency_conversion.get("source_type", '').lower() == 'dict': # doesn't work in json as key must be single value return DictBasedCurrencyRates(currency_conversion['currency_rates']) + elif currency_conversion.get("source_type", '').lower() == 'list': # option to write directly the rate in the json file + return DictBasedCurrencyRates.from_list(currency_conversion['currency_rates']) else: raise OdsException( f"Unsupported currency_conversion source type : {currency_conversion.get('source_type')}") @@ -253,21 +255,23 @@ def convert_currency(oed_df, oed_type, reporting_currency, currency_rate, oed_sc oed_df.loc[orig_cur_rows, 'RateOfExchange'] *= rate for field, column in field_to_column.items(): field_type = ods_fields[field.lower()].get('Back End DB Field Name', '').lower() - if (field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded', - 'maxded'] - or field.endswith('tiv')): + + if ( + field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded', 'maxded'] + or field.lower().endswith('tiv') + or field in ['LayerLimit', 'LayerAttachment']): row_filter = orig_cur_rows elif field_type == 'ded': - column_type_name = field.replace('ded', 'dedtype') + column_type_name = field.replace('Ded', 'DedType') row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0) elif field_type == 'limit': - column_type_name = field.replace('limit', 'limittype') + column_type_name = field.replace('Limit', 'LimitType') row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0) elif field_type in ['payoutstart', 'payoutend', 'payoutlimit']: - column_type_name = 'payouttype' + column_type_name = 'PayoutType' row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0) elif field_type in ['triggerstart', 'triggerend']: - column_type_name = 'triggertype' + column_type_name = 'TriggerType' row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0) else: # not a currency unit column we go to the next one continue diff --git a/tests/test_ods_package.py b/tests/test_ods_package.py index 26f23c99..84aa6eb2 100644 --- a/tests/test_ods_package.py +++ b/tests/test_ods_package.py @@ -362,10 +362,10 @@ def test_relative_and_absolute_path(self): with tempfile.TemporaryDirectory() as tmp_dir: abs_dir = pathlib.Path(tmp_dir, "abs") abs_dir.mkdir() - with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10Currency.csv') as response,\ + with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10Currency.csv') as response, \ open(pathlib.Path(tmp_dir, 'SourceLocOEDPiWind10Currency.csv'), 'wb') as out_file: shutil.copyfileobj(response, out_file) - with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response,\ + with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response, \ open(pathlib.Path(abs_dir, 'SourceAccOEDPiWind.csv'), 'wb') as out_file: shutil.copyfileobj(response, out_file) @@ -402,7 +402,7 @@ def test_setting_schema_analysis__is_valid(self): abs_dir = pathlib.Path(tmp_dir, "abs") abs_dir.mkdir() - with urllib.request.urlopen(file_url) as response,\ + with urllib.request.urlopen(file_url) as response, \ open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file: shutil.copyfileobj(response, out_file) @@ -424,7 +424,7 @@ def test_setting_schema_analysis__is_invalid(self): abs_dir = pathlib.Path(tmp_dir, "abs") abs_dir.mkdir() - with urllib.request.urlopen(file_url) as response,\ + with urllib.request.urlopen(file_url) as response, \ open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file: shutil.copyfileobj(response, out_file) @@ -454,7 +454,7 @@ def test_setting_schema_model__is_valid(self): abs_dir = pathlib.Path(tmp_dir, "abs") abs_dir.mkdir() - with urllib.request.urlopen(file_url) as response,\ + with urllib.request.urlopen(file_url) as response, \ open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file: shutil.copyfileobj(response, out_file) @@ -476,7 +476,7 @@ def test_setting_schema_model__is_invalid(self): abs_dir = pathlib.Path(tmp_dir, "abs") abs_dir.mkdir() - with urllib.request.urlopen(file_url) as response,\ + with urllib.request.urlopen(file_url) as response, \ open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file: shutil.copyfileobj(response, out_file)