Skip to content

Commit a738bcc

Browse files
authored
Merge pull request #25 from OasisLMF/add/transformdocs
Add documentation on the odtf tool
2 parents 5fac643 + da08aac commit a738bcc

File tree

4 files changed

+154
-1
lines changed

4 files changed

+154
-1
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ sphinx-jsonschema==1.19.1
2020
requests
2121
ods-tools
2222
sphinxcontrib-redoc
23+
lxml_html_clean

src/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ It allows regression of the models after updates to the Oasis Platform code, and
109109
sections/OasisLMF-package.rst
110110
sections/ODS-tools.rst
111111
sections/ODS.rst
112+
sections/ODTF.rst
112113
sections/OED.rst
113114
sections/ORD.rst
114115
sections/platform_1

src/sections/ODS-tools.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,25 @@ Example :
113113
ods_tools convert --location path_to_location_file --path output folder
114114
|
115115
116+
ODS Tools can also be used to transform location and account data from other formats to OED and vice versa,
117+
depenting on the mapping files provided. For more information on this, see here: :doc:`../sections/ODTF`.
118+
119+
Example :
120+
121+
|
122+
.. code-block:: python
123+
124+
ods_tools transform --config-file configuration.yaml
125+
|
126+
127+
116128
.. note::
117-
See ``ods_tools convert --help`` for more options.
129+
See ``ods_tools convert --help`` and ``ods_tools transform --help`` for more options.
118130
|
119131
120132

121133

134+
122135
.. _links_ODS_Tools:
123136

124137
Links for further information

src/sections/ODTF.rst

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
ODTF
2+
=========
3+
Data transformation tool in ODS-tools
4+
5+
On this page:
6+
-------------
7+
8+
* :ref:`intro_ODTF`
9+
* :ref:`inputs`
10+
* :ref:`use`
11+
* :ref:`validation`
12+
13+
----
14+
15+
.. _intro_ODTF:
16+
17+
Introduction
18+
************
19+
20+
21+
The `transform` command can be used to convert data from one format to another (e.g., from the AIR Cede format to OED). It will convert from a specific version of the source format to a specific version of the target format, for example from AIR Cede 10.0.0 to OED 3.0.2.
22+
23+
As of :doc:`../sections/ODS-tools` 3.2.3, we support conversions between AIR Cede and OED formats.
24+
25+
26+
----
27+
28+
.. _inputs:
29+
30+
Inputs
31+
************
32+
33+
34+
35+
For a transformation to run, the necessary input files should be present.
36+
The input files you will need to run a transformation are:
37+
38+
39+
40+
**Configuration file**
41+
42+
See, e.g., this `example configuration file <https://github.com/OasisLMF/ODS_Tools/blob/main/ods_tools/odtf/examples/example_config.yaml>`_:
43+
44+
|
45+
.. code-block:: yaml
46+
47+
transformations:
48+
loc: # Transformation name
49+
input_format:
50+
name: Cede_Location
51+
version: 10.0.0
52+
output_format:
53+
name: OED_Location
54+
version: 3.0.2
55+
runner:
56+
batch_size: 150000 # Number of rows to process in a single batch
57+
extractor:
58+
options:
59+
path: ./cede_location_1000.csv # Path to the input file
60+
quoting: minimal
61+
loader:
62+
options:
63+
path: ./oed_location_1000.csv # Path to the output file
64+
quoting: minimal
65+
|
66+
67+
The configuration file contains a list of transformations to run (currently loc for location and acc for account data).
68+
Each transformation includes name and version of the input and output formats, the (optional) batch size, and the paths to the input (extractor) and output (loader) files.
69+
70+
71+
72+
73+
**Input data**
74+
75+
The input data should be in the format that you want to transform from. For example, if you want to transform data from AIR Cede to OED, the input data should be in the AIR Cede format.
76+
File types supported:
77+
.csv
78+
79+
80+
81+
82+
**Mapping file**
83+
84+
A mapping file is a file in .yaml format that describes how to run a conversion between the source and target formats and vice versa.
85+
Multiple mapping files can be used together to define a mapping between a source and destination format that do not appear in the same mapping file. I.e., A mapping file for model A to B and and a mapping file for Model B to C, can be used to transform data directly from A to C.
86+
87+
Transformations can copy one field into another, substitute field values using a replace function, or include conditional transformation using a where clause. For columns that can contain multiple values (the LocPerils column in AIR Cede which could contain, for example "CF, CH, EQ"), the replace_multiple allows to input a separator used in the cell to split the values.
88+
Only the transformations involving columns present in the input file will be run.
89+
90+
91+
For example, see the `Cede-OED mapping file <https://github.com/OasisLMF/ODS_Tools/blob/main/ods_tools/odtf/data/mappings/mapping_loc_Cede-OED.yaml>`_
92+
93+
94+
95+
----
96+
97+
.. _use:
98+
99+
Usage
100+
************
101+
102+
103+
Command line usage..
104+
105+
ods_tools transform [-h] --config-file CONFIG_FILE [-v LOGGING_LEVEL] [--nocheck NOCHECK]
106+
107+
Transform data format to/from OED.
108+
109+
options:
110+
-h, --help show this help message and exit
111+
112+
--config-file CONFIG_FILE
113+
Path to the config file
114+
115+
-v LOGGING_LEVEL, --logging-level LOGGING_LEVEL
116+
logging level (debug:10, info:20, warning:30, error:40, critical:50)
117+
118+
--nocheck NOCHECK if True, OED file will not be checked after transformation
119+
120+
121+
----
122+
123+
.. _validation:
124+
125+
Validation
126+
************
127+
128+
129+
Validation is performed after a conversion to make sure that the output file is valid with respect to specific rules.
130+
A data validation file contains comparisons of various metrics in both the input file and output file.
131+
For example, the sum of Total Insured Value grouped by Occupancy Type and Currency. The fields and operations are defined by the user in the validation definition files.
132+
The validation definition file is in .yaml format.
133+
See, for example, this `example validation file <https://github.com/OasisLMF/ODS_Tools/blob/main/ods_tools/odtf/data/validators/validation_OED_Location_loc.yaml>`_.
134+
135+
136+
.. note::
137+
The ODTF and the transform command are adapted from the `Open Data Transformation Framework <https://oasislmf.github.io/OpenDataTransform/>`_.
138+
|

0 commit comments

Comments
 (0)