From 8fd9dd848a1856c22948c0b18e4ce39a2dcbedc4 Mon Sep 17 00:00:00 2001 From: Aaron Weeden Date: Wed, 6 Dec 2023 12:06:39 -0500 Subject: [PATCH] Improve performance of validation of filters and raw fields. --- CHANGELOG.md | 1 + xdmod_data/__version__.py | 2 +- xdmod_data/_validator.py | 13 +++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85942c07..a567f20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # xdmod-data Changelog ## Main development branch +- Improve performance of validation of filters and raw fields ([\#18](https://github.com/ubccr/xdmod-data/pull/18)). - Update tests and testing instructions ([\#14](https://github.com/ubccr/xdmod-data/pull/14)). ## v1.0.0 (2023-07-21) diff --git a/xdmod_data/__version__.py b/xdmod_data/__version__.py index 55cd9ccf..10f5e82c 100644 --- a/xdmod_data/__version__.py +++ b/xdmod_data/__version__.py @@ -1,2 +1,2 @@ __title__ = 'xdmod-data' -__version__ = '1.0.0' +__version__ = '1.0.1-beta.1' diff --git a/xdmod_data/_validator.py b/xdmod_data/_validator.py index d329b14c..d80f399a 100644 --- a/xdmod_data/_validator.py +++ b/xdmod_data/_validator.py @@ -179,10 +179,14 @@ def __validate_filters(data_warehouse, descriptors, realm, filters): if isinstance(filter_values, str): filter_values = [filter_values] result[dimension_id] = [] + valid_filter_values = data_warehouse.get_filter_values( + realm, + dimension, + ) for filter_value in filter_values: new_filter_value = __find_value_in_df( 'Filter value', - data_warehouse.get_filter_values(realm, dimension), + valid_filter_values, filter_value, ) result[dimension_id].append(new_filter_value) @@ -214,12 +218,9 @@ def __find_str_in_sequence(value, sequence, label): def __validate_raw_fields(data_warehouse, realm, fields): try: results = [] + valid_raw_fields = data_warehouse.describe_raw_fields(realm) for field in fields: - new_field = __find_value_in_df( - 'Field', - data_warehouse.describe_raw_fields(realm), - field, - ) + new_field = __find_value_in_df('Field', valid_raw_fields, field) results.append(new_field) return results except TypeError: