ingen-lib 2.0.0__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. {ingen_lib-2.0.0/ingen_lib.egg-info → ingen_lib-2.1.1}/PKG-INFO +1 -1
  2. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/formatters/common_formatters.py +35 -2
  3. ingen_lib-2.1.1/ingen/pre_processor/not_equals_filter.py +63 -0
  4. ingen_lib-2.1.1/ingen/pre_processor/outer_join.py +50 -0
  5. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/pre_processor.py +5 -1
  6. {ingen_lib-2.0.0 → ingen_lib-2.1.1/ingen_lib.egg-info}/PKG-INFO +1 -1
  7. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen_lib.egg-info/SOURCES.txt +2 -0
  8. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/setup.py +1 -1
  9. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/LICENSE +0 -0
  10. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/MANIFEST.in +0 -0
  11. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/README.md +0 -0
  12. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/__init__.py +0 -0
  13. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/__main__.py +0 -0
  14. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/__init__.py +0 -0
  15. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/api_source.py +0 -0
  16. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/data_source_type.py +0 -0
  17. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/dataframe_store.py +0 -0
  18. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/file_source.py +0 -0
  19. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/json_source.py +0 -0
  20. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/mysql_source.py +0 -0
  21. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/rawdata_source.py +0 -0
  22. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/source.py +0 -0
  23. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/data_source/source_factory.py +0 -0
  24. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/formatters/__init__.py +0 -0
  25. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/formatters/formatter.py +0 -0
  26. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/formatters/utils.py +0 -0
  27. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/generators/__init__.py +0 -0
  28. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/generators/base_interface_generator.py +0 -0
  29. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/generators/interface_generator.py +0 -0
  30. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/lib/__init__.py +0 -0
  31. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/lib/cryptor.py +0 -0
  32. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/logger.py +0 -0
  33. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/metadata/__init__.py +0 -0
  34. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/metadata/metadata.py +0 -0
  35. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/metadata/metadata_parser.py +0 -0
  36. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/post_processor/__init__.py +0 -0
  37. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/post_processor/common_post_processor.py +0 -0
  38. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/post_processor/post_processor.py +0 -0
  39. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/__init__.py +0 -0
  40. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/aggregator.py +0 -0
  41. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/aggregators.py +0 -0
  42. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/drop_duplicates.py +0 -0
  43. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/filter.py +0 -0
  44. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/json_array_expander.py +0 -0
  45. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/mask.py +0 -0
  46. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/melt.py +0 -0
  47. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/merger.py +0 -0
  48. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/process.py +0 -0
  49. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/pre_processor/union.py +0 -0
  50. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/__init__.py +0 -0
  51. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/api_reader.py +0 -0
  52. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/data_source.py +0 -0
  53. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/file_reader.py +0 -0
  54. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/json_reader.py +0 -0
  55. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/mysql_reader.py +0 -0
  56. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/rawdata_reader.py +0 -0
  57. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/reader/xml_file_reader.py +0 -0
  58. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/__init__.py +0 -0
  59. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_http/__init__.py +0 -0
  60. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_http/aiohttp_retry.py +0 -0
  61. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_http/http_request.py +0 -0
  62. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_http/http_util.py +0 -0
  63. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_http/success_criterias.py +0 -0
  64. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/app_secrets.py +0 -0
  65. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/interpolators/Interpolator.py +0 -0
  66. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/interpolators/__init__.py +0 -0
  67. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/interpolators/common_interpolators.py +0 -0
  68. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/json_df_convertors.py +0 -0
  69. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/path_parser.py +0 -0
  70. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/properties.py +0 -0
  71. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/run_configuration.py +0 -0
  72. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/sql_query_parser.py +0 -0
  73. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/timer.py +0 -0
  74. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/url_constructor.py +0 -0
  75. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/utils/utils.py +0 -0
  76. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/validation/__init__.py +0 -0
  77. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/validation/common_validations.py +0 -0
  78. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/validation/notification.py +0 -0
  79. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/validation/send_email.py +0 -0
  80. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/validation/validations.py +0 -0
  81. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/__init__.py +0 -0
  82. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/dataframe_writer.py +0 -0
  83. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_util.py +0 -0
  84. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/__init__.py +0 -0
  85. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/convertors/__init__.py +0 -0
  86. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/convertors/convertor_factory.py +0 -0
  87. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/convertors/df_to_multiple_json_convertor.py +0 -0
  88. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/convertors/df_to_single_json_convertor.py +0 -0
  89. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/destinations/__init__.py +0 -0
  90. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/destinations/api_destination.py +0 -0
  91. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/destinations/destination_factory.py +0 -0
  92. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/destinations/file_destination.py +0 -0
  93. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/json_writer/json_writer.py +0 -0
  94. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/old_json_writer.py +0 -0
  95. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/split_file_writer.py +0 -0
  96. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/util.py +0 -0
  97. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen/writer/writer.py +0 -0
  98. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen_lib.egg-info/dependency_links.txt +0 -0
  99. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen_lib.egg-info/requires.txt +0 -0
  100. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/ingen_lib.egg-info/top_level.txt +0 -0
  101. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/pyproject.toml +0 -0
  102. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/requirements.txt +0 -0
  103. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/setup.cfg +0 -0
  104. {ingen_lib-2.0.0 → ingen_lib-2.1.1}/test/test_interface_generator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingen-lib
3
- Version: 2.0.0
3
+ Version: 2.1.1
4
4
  Summary: A Python script suite that generates interface files based on the given interface metadata/config file
5
5
  Home-page: https://github.com/blackrock/interface-generator
6
6
  Maintainer: Swarna Dhakad, Piyush Ranjan, Jatin Varlyani, Pooja Katariya
@@ -422,13 +422,28 @@ def replace_value(dataframe, col_name, format_options, runtime_params):
422
422
  :param runtime_params: command line arguments
423
423
  :return: new dataframe with 'from_value' replaced in column 'col_name' with the 'to_value'
424
424
  """
425
+ # replace_missing: boolean, if True and from_value is None will replace NaN with to_value
426
+ replace_missing = format_options.get('replace_missing', False)
427
+ # boolean, if True will attempt to replace values inside list-type cells
428
+ search_list = format_options.get('search_list', False)
425
429
  if col_name not in dataframe.columns:
426
430
  raise KeyError(f"Column '{col_name}' not found.")
427
431
  for from_value, to_value in zip(format_options.get('from_value'), format_options.get('to_value')):
428
- dataframe[col_name] = dataframe[col_name].replace(
429
- {from_value: to_value})
432
+ if replace_missing and from_value is None:
433
+ # Replace all missing values (None, NaN) - useful for merge operations
434
+ dataframe[col_name] = dataframe[col_name].fillna(to_value)
435
+ else:
436
+ dataframe[col_name] = dataframe[col_name].replace(
437
+ {from_value: to_value})
438
+ if search_list:
439
+ dataframe[col_name] = dataframe[col_name].apply(lambda elem: replace_in_list(elem, from_value, to_value))
430
440
  return dataframe
431
441
 
442
+ def replace_in_list(row, from_value, to_value):
443
+ if not isinstance (row, list):
444
+ return row
445
+ return [to_value if elem == from_value else elem for elem in row]
446
+
432
447
 
433
448
  def extract_from_pattern(dataframe, col_name, format_options, runtime_params):
434
449
  """
@@ -535,6 +550,23 @@ def sub_string(dataframe, col_name, format_options, runtime_params):
535
550
  dataframe[col_name] = dataframe[col_name].astype(str).str[start:end]
536
551
  return dataframe
537
552
 
553
+ def decode_bytes_formatter(dataframe, col_name, format_options, runtime_params):
554
+ 'Decode bytes in a column using the provided encoding.'
555
+ encoding = format_options.get('encoding', 'utf-8')
556
+ strip_whitespace = format_options.get('strip_whitespace', True)
557
+ if col_name not in dataframe.columns:
558
+ raise KeyError (f"Column '{col_name}' not found.")
559
+ def decode(value):
560
+ if isinstance(value, bytes):
561
+ decoded = value.decode(encoding, errors='replace')
562
+ else:
563
+ decoded = value
564
+ if strip_whitespace and isinstance(decoded, str):
565
+ return decoded.strip()
566
+ return decoded
567
+ dataframe[col_name] = dataframe[col_name].map(decode)
568
+ return dataframe
569
+
538
570
 
539
571
  def float_precision(dataframe, col_name, format_options, runtime_params):
540
572
  """
@@ -671,6 +703,7 @@ formatter_map = {
671
703
  'conditional_replace_formatter': conditional_replace_formatter,
672
704
  'bus_day': business_day_formatter,
673
705
  'split_col': split_column_formatter,
706
+ 'decode_bytes': decode_bytes_formatter,
674
707
  'float_precision': float_precision,
675
708
  'extract_from_pattern': extract_from_pattern,
676
709
  'index_counter': index_counter,
@@ -0,0 +1,63 @@
1
+ import pandas as pd
2
+
3
+ from ingen.pre_processor.process import Process
4
+
5
+ class NotEqualsFilter(Process):
6
+
7
+ """
8
+ Filter pre_processor that excludes roes where column values match specified values.
9
+ This is the inverse of the standard 'filter' preprocessor.
10
+
11
+ Usage in YAML:
12
+ pre_processing:
13
+ - type: not_equals_filter
14
+ source: <source>
15
+ cols:
16
+ - col: <column_name>
17
+ val: ["value_to_exclude]
18
+
19
+ This will keep all rows where <column_name> is NOT in ["value_to_exclude]
20
+ """
21
+ def execute(self, config, sources_data, data):
22
+ source = config.get('source')
23
+ cols = config.get('cols', [])
24
+
25
+ #Get source data or use current data
26
+ if source and source in sources_data:
27
+ df = sources_data.get(source)
28
+ else:
29
+ df = data
30
+
31
+ if df is None or df.empty:
32
+ return pd.DataFrame()
33
+
34
+ return self.not_equals_filter(df, cols)
35
+
36
+ def not_equals_filter(self, data, cols):
37
+ """
38
+ Filter out rows where column values match any of the specified values
39
+
40
+ Args:
41
+ data: pandas Dataframe
42
+ cols: list of dicts with 'col' (column name) and 'val' (list of values to exclude)
43
+
44
+ Returns:
45
+ Dataframe with rows excluded where column matches any specified values
46
+ """
47
+ if not cols:
48
+ return data
49
+
50
+ mask = pd.Series([True] * len(data), index=data.index)
51
+
52
+ for col_config in cols:
53
+ col_name = col_config.get('col')
54
+ values_to_exclude = col_config.get('val', [])
55
+
56
+ if col_name not in data.columns:
57
+ continue
58
+
59
+ # Exclude rows where column value is in the exclusion list
60
+ # Using ~isin() to get NOT IN behavior
61
+ mask &= ~data[col_name].isin(values_to_exclude)
62
+
63
+ return data[mask].reset_index(drop=True)
@@ -0,0 +1,50 @@
1
+ import pandas as pd
2
+ from ingen.pre_processor.process import Process
3
+
4
+
5
+ class OuterJoin(Process):
6
+ """
7
+ Pre-processor that performs a full outer join between two data sources.
8
+
9
+ Usage in YAML:
10
+ pre_processing:
11
+ - type: outer_join
12
+ source: «right_source_id> left_key: ‹left_column_name> right_key: <right_column_name>
13
+ Columns from left source get '_x' suffix if duplicated.
14
+ Columns from right source get '-y' suffix if duplicated.
15
+
16
+ """
17
+
18
+ def execute(self, config, sources_data, data):
19
+ """
20
+ Method responsible for calling the appropriate function to execute the outer join process.
21
+ :param config: configuration to use for outer join
22
+ :param sources_data: dictionary of data fetched from sources
23
+ :param data: pre-processed data till now
24
+ :return: A Pandas dataframe which is the result of the outer join process
25
+ """
26
+ left_dataframe = data
27
+ right_dataframe = sources_data.get(config.get('source'))
28
+ left_key = config.get('left_key')
29
+ right_key = config.get('right_key')
30
+
31
+ if left_key is not None and left_key not in left_dataframe.columns:
32
+ raise KeyError(f"Column '{left_key}' not present in left dataframe")
33
+ if right_key is not None and right_key not in right_dataframe.columns:
34
+ raise KeyError(f"Column '{right_key}' not present in right dataframe")
35
+
36
+ return self.outer_merge(left_dataframe, right_dataframe, left_key, right_key)
37
+
38
+ def outer_merge(self, left_df, right_df, left_key, right_key):
39
+ """Perform a full outer join on the two dataframes.
40
+
41
+ :param: left_df: The left dataframe
42
+ :param: right_df: The right dataframe
43
+ :param: left_key: column name to join on in left dataframe
44
+ :param: right_key: column name to join on in right dataframe
45
+ :return: outer joined dataframe with NaN values converted to empty strings
46
+ """
47
+ result = pd.merge(left_df, right_df, how='outer', left_on=left_key, right_on=right_key)
48
+ # Convert NaN to empty strings so column_condition formatters can compare with ""
49
+ result = result.fillna('')
50
+ return result
@@ -12,6 +12,8 @@ from ingen.pre_processor.mask import Mask
12
12
  from ingen.pre_processor.melt import Melt
13
13
  from ingen.pre_processor.merger import Merger
14
14
  from ingen.pre_processor.union import Union
15
+ from ingen.pre_processor.not_equals_filter import NotEqualsFilter
16
+ from ingen.pre_processor.outer_join import OuterJoin
15
17
 
16
18
  log = logging.getLogger()
17
19
 
@@ -25,7 +27,9 @@ class PreProcessor:
25
27
  "melt": Melt,
26
28
  "drop_duplicates": DropDuplicates,
27
29
  "filter": Filter,
28
- "json_array_expander": JsonArrayExpander
30
+ "json_array_expander": JsonArrayExpander,
31
+ "not_equals_filter": NotEqualsFilter,
32
+ "outer_join": OuterJoin,
29
33
  }
30
34
 
31
35
  def __init__(self, pre_processes, source_data):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingen-lib
3
- Version: 2.0.0
3
+ Version: 2.1.1
4
4
  Summary: A Python script suite that generates interface files based on the given interface metadata/config file
5
5
  Home-page: https://github.com/blackrock/interface-generator
6
6
  Maintainer: Swarna Dhakad, Piyush Ranjan, Jatin Varlyani, Pooja Katariya
@@ -41,6 +41,8 @@ ingen/pre_processor/json_array_expander.py
41
41
  ingen/pre_processor/mask.py
42
42
  ingen/pre_processor/melt.py
43
43
  ingen/pre_processor/merger.py
44
+ ingen/pre_processor/not_equals_filter.py
45
+ ingen/pre_processor/outer_join.py
44
46
  ingen/pre_processor/pre_processor.py
45
47
  ingen/pre_processor/process.py
46
48
  ingen/pre_processor/union.py
@@ -11,7 +11,7 @@ MAIN_PKG = 'ingen'
11
11
  VERSION_PY_FILE = os.path.join(MAIN_PKG, 'version.py')
12
12
 
13
13
  setup(name=PKG_NAME,
14
- version='v2.0.0',
14
+ version='v2.1.1',
15
15
  packages=setuptools.find_packages(include=['ingen', 'ingen.*']),
16
16
  package_data={},
17
17
  description='A Python script suite that generates interface files based on the given interface metadata/config '
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes