Skip to content

Commit

Permalink
Merge pull request #97 from OasisLMF/release/3.2.2
Browse files Browse the repository at this point in the history
Release 3.2.2
  • Loading branch information
sambles authored Mar 27, 2024
2 parents ea6fa84 + c3723ee commit 697976a
Show file tree
Hide file tree
Showing 52 changed files with 9,164 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
needs: [build-ods, build-odm]
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ coverage.xml

# excel
*.xlsx#

# venv
.venv/

# vscode
.vscode/
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
ODS_Tools Changelog
===================

`3.2.2`_
---------
* [#92](https://github.com/OasisLMF/ODS_Tools/pull/92) - Release 3.2.1
* [#93](https://github.com/OasisLMF/ODS_Tools/pull/93) - include peril group as valid when doing peril filtering
* [#94](https://github.com/OasisLMF/ODS_Tools/pull/94) - CI update - replace py3.7 with py3.11
* [#90](https://github.com/OasisLMF/ODS_Tools/pull/95) - Incorporate odtf in ods_tools
.. _`3.2.2`: https://github.com/OasisLMF/ODS_Tools/compare/3.2.1...3.2.2

* [#91](https://github.com/OasisLMF/ODS_Tools/pull/91) - Add ri_inuring_priorities field to analysis settings schema for outputs at intermediate inuring priorities
.. _`3.2.1`: https://github.com/OasisLMF/ODS_Tools/compare/3.2.0...3.2.1

Expand Down
2 changes: 1 addition & 1 deletion ods_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '3.2.1'
__version__ = '3.2.2'

import logging

Expand Down
36 changes: 31 additions & 5 deletions ods_tools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ModelSettingSchema,
AnalysisSettingSchema,
)
from ods_tools.odtf.controller import transform_format


def get_oed_exposure(config_json=None, oed_dir=None, **kwargs):
Expand Down Expand Up @@ -92,9 +93,27 @@ def convert(**kwargs):
oed_exposure.save(path=path, **kwargs)


def transform(**kwargs):
"""Wrapper function for transform command.
Transform location and account data to a new format (ex: AIR to OED)"""
path_to_config_file = kwargs['config_file']
try:
transform_result = transform_format(path_to_config_file)
if not kwargs.get('nocheck'):
for output_file in transform_result:
if output_file[1] == 'location' and os.path.isfile(output_file[0]):
check(location=output_file[0])
elif output_file[1] == 'account' and os.path.isfile(output_file[0]):
check(account=output_file[0])
except OdsException as e:
logger.error("Transformation failed:")
logger.error(e)


command_action = {
'check': check,
'convert': convert,
'transform': transform,
}


Expand Down Expand Up @@ -150,15 +169,22 @@ def add_exposure_data_args(command):
default=30, type=int)


transform_description = """
Transform data format to/from OED.
"""
transform_command = command_parser.add_parser('transform', description=transform_description,
formatter_class=argparse.RawTextHelpFormatter)
transform_command.add_argument('--config-file', help='Path to the config file', required=True)
transform_command.add_argument('-v', '--logging-level', help='logging level (debug:10, info:20, warning:30, error:40, critical:50)',
default=30, type=int)
transform_command.add_argument('--nocheck', help='if True, OED file will not be checked after transformation', default=False)


def main():
"""command line interface for ODS conversion between csv and parquet"""
kwargs = vars(main_parser.parse_args())
ch = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
logging_level = kwargs.pop('logging_level')
logger.setLevel(logging_level)
logging.basicConfig(level=logging_level, format='%(asctime)s - %(levelname)s - %(message)s')

command_action[kwargs.pop('command')](** kwargs)

Expand Down
6 changes: 6 additions & 0 deletions ods_tools/odtf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .config import Config


__all__ = [
"Config",
]
Loading

0 comments on commit 697976a

Please sign in to comment.