pipefy 0.0.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 (45) hide show
  1. pipefy-0.0.1/LICENSE +9 -0
  2. pipefy-0.0.1/PKG-INFO +223 -0
  3. pipefy-0.0.1/README.md +203 -0
  4. pipefy-0.0.1/pipefy/__init__.py +0 -0
  5. pipefy-0.0.1/pipefy/etl/__init__.py +0 -0
  6. pipefy-0.0.1/pipefy/etl/extract/__init__.py +0 -0
  7. pipefy-0.0.1/pipefy/etl/extract/http/__init__.py +9 -0
  8. pipefy-0.0.1/pipefy/etl/extract/http/http_extractor.py +254 -0
  9. pipefy-0.0.1/pipefy/etl/transform/__init__.py +0 -0
  10. pipefy-0.0.1/pipefy/etl/transform/csv/__init__.py +3 -0
  11. pipefy-0.0.1/pipefy/etl/transform/csv/reader.py +305 -0
  12. pipefy-0.0.1/pipefy/etl/transform/json/__init__.py +3 -0
  13. pipefy-0.0.1/pipefy/etl/transform/json/reader.py +118 -0
  14. pipefy-0.0.1/pipefy/etl/transform/unzip/__init__.py +3 -0
  15. pipefy-0.0.1/pipefy/etl/transform/unzip/base.py +132 -0
  16. pipefy-0.0.1/pipefy/exceptions/__init__.py +31 -0
  17. pipefy-0.0.1/pipefy/exceptions/base.py +55 -0
  18. pipefy-0.0.1/pipefy/exceptions/csv_processor.py +24 -0
  19. pipefy-0.0.1/pipefy/exceptions/download_processor.py +21 -0
  20. pipefy-0.0.1/pipefy/exceptions/file_system.py +78 -0
  21. pipefy-0.0.1/pipefy/exceptions/unzip_processor.py +24 -0
  22. pipefy-0.0.1/pipefy/factories/__init__.py +9 -0
  23. pipefy-0.0.1/pipefy/factories/exceptions_factory.py +69 -0
  24. pipefy-0.0.1/pipefy/factories/file_system_factory.py +36 -0
  25. pipefy-0.0.1/pipefy/log/__init__.py +6 -0
  26. pipefy-0.0.1/pipefy/log/logger.py +19 -0
  27. pipefy-0.0.1/pipefy/operations/__init__.py +17 -0
  28. pipefy-0.0.1/pipefy/operations/operations.py +300 -0
  29. pipefy-0.0.1/pipefy/operations/pipeline.py +49 -0
  30. pipefy-0.0.1/pipefy/processors/__init__.py +57 -0
  31. pipefy-0.0.1/pipefy/processors/abc.py +71 -0
  32. pipefy-0.0.1/pipefy/processors/base.py +350 -0
  33. pipefy-0.0.1/pipefy/processors/chain_processors/__init__.py +9 -0
  34. pipefy-0.0.1/pipefy/processors/chain_processors/base.py +175 -0
  35. pipefy-0.0.1/pipefy/processors/file_system/__init__.py +13 -0
  36. pipefy-0.0.1/pipefy/processors/file_system/base.py +298 -0
  37. pipefy-0.0.1/pipefy/processors/file_system/file_system_types.py +6 -0
  38. pipefy-0.0.1/pipefy/processors/meta.py +115 -0
  39. pipefy-0.0.1/pipefy/processors/mixins.py +0 -0
  40. pipefy-0.0.1/pipefy/processors/processor_types.py +6 -0
  41. pipefy-0.0.1/pipefy/processors/retry_processor.py +164 -0
  42. pipefy-0.0.1/pipefy/processors/splitter_processor.py +54 -0
  43. pipefy-0.0.1/pipefy/utils/__init__.py +11 -0
  44. pipefy-0.0.1/pipefy/utils/common.py +97 -0
  45. pipefy-0.0.1/pyproject.toml +101 -0
pipefy-0.0.1/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 [Daniel Naumowich]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pipefy-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.1
2
+ Name: pipefy
3
+ Version: 0.0.1
4
+ Summary:
5
+ Author: Daniel Naumowich
6
+ Author-email: cskteam4@gmail.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: chardet (>=5.2.0,<6.0.0)
14
+ Requires-Dist: httpx (>=0.27.0,<0.28.0)
15
+ Requires-Dist: loguru (>=0.7.2,<0.8.0)
16
+ Requires-Dist: pandas (>=2.2.2,<3.0.0)
17
+ Requires-Dist: pytest (>=8.2.2,<9.0.0)
18
+ Requires-Dist: setuptools (>=75.6.0,<76.0.0)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # ETL Pipeline Library
22
+
23
+ ## Description
24
+
25
+ This library is designed for building **ETL pipelines** (Extract, Transform, Load). It provides a set of processors to perform various data operations, such as extracting, transforming, and loading data into the desired format. Each processor in the library is a standalone unit that can be linked together in a chain to perform complex operations.
26
+
27
+ Processors support working with various data formats (CSV, JSON, ZIP, and others), allow flexible data processing configurations, handle exceptions, and interact with file systems to read and write data.
28
+
29
+ ## Key Features
30
+
31
+ - **Clean architecture with processor chains**: Each processor performs a specific task and can pass data to the next processor in the chain.
32
+ - **Support for various data formats**: The library includes processors for working with CSV, JSON, ZIP, and other formats.
33
+ - **Flexibility and configuration**: Support for various configuration options, such as custom converters for numbers, error handling methods, and working with large files.
34
+ - **Automation**: Option to automatically delete the source files after processing.
35
+ - **Error handling mechanisms**: The library provides support for ignoring or handling different exceptions at various stages of data processing.
36
+
37
+ ## Main Components
38
+
39
+ ### 1. **BaseProcessor**
40
+ The base class for all processors. It supports the chain of responsibility, allows configuring subprocessors for parallel or sequential processing, and manages exceptions.
41
+
42
+ ### 2. **ChainAnyProcessor**
43
+ A processor that attempts to process data through a series of sub-processors in sequence.
44
+
45
+ - **Behavior**:
46
+ - Each sub-processor tries to handle the data.
47
+ - The first successful sub-processor is moved to the front of the chain for prioritization in future attempts.
48
+ - If all sub-processors fail, an error is logged.
49
+ - **Use Case**: Useful when there are multiple processors capable of handling the same type of data, but with varying likelihoods of success.
50
+
51
+ ### 3. **ChainAllProcessor**
52
+ A processor that runs multiple sub-processors in parallel, either using threads or processes.
53
+
54
+ - **Behavior**:
55
+ - Executes all sub-processors simultaneously.
56
+ - Yields results from sub-processors as soon as they become available.
57
+ - Logs any exceptions that occur during processing.
58
+ - **Use Case**: Ideal for parallelizing independent operations, such as processing different parts of a dataset.
59
+
60
+ ### 4. **HttpDataExtractProcessor**
61
+ A processor for extracting data via HTTP GET requests, with the option to save the retrieved data to a file.
62
+
63
+ ### 5. **HttpxStreamDownloadProcessor**
64
+ A processor for streaming large file downloads via HTTP, with the ability to process data in parallel.
65
+
66
+ ### 6. **CsvParser**
67
+ A processor for parsing CSV files using the `pandas` library. It supports numerous options, including handling delimiters, skipping empty lines, and processing data in chunks.
68
+
69
+ ### 7. **JsonParser**
70
+ A processor for parsing JSON data from strings or files into Python dictionaries. It supports configuring how numbers, constants (e.g., NaN), and JSON objects are handled with custom functions.
71
+
72
+ ### 8. **BaseUnzipProcessor**
73
+ A processor for extracting files from `.zip` archives. It supports extracting data into files, managing chunk sizes, and deleting the original archive after processing.
74
+
75
+ ### 9. **RetryProcessor**
76
+
77
+ A processor designed to handle transient errors by retrying operations based on a customizable retry policy.
78
+
79
+ - **Key Features**:
80
+ - **Configurable Retry Logic**: Supports setting a maximum number of retries and delays between attempts (fixed or exponential backoff).
81
+ - **White-listed Exceptions**: Retries only specific exceptions defined by the user.
82
+ - **Logging and Metrics**: Logs every retry attempt and provides details about failures.
83
+ - **Fallback Handling**: Allows defining a fallback action if all retry attempts fail.
84
+ - **Use Case**: Ideal for handling temporary issues like network timeouts, database connection errors, or transient API failures.
85
+
86
+ ## Example Usage
87
+
88
+ ### Example ETL Pipeline(Flow 1)
89
+
90
+ ```python
91
+ from processors.http import HttpDataExtractProcessor
92
+ from processors.csv_parser import CsvParser
93
+ from processors.json_parser import JsonParser
94
+ from processors.unzip import BaseUnzipProcessor
95
+ from processors.file_system import AbstractFileSystemManager
96
+
97
+ # Create file system manager
98
+ file_system_manager = AbstractFileSystemManager()
99
+
100
+ # Create processors
101
+ http_processor = HttpDataExtractProcessor(file_system_manager)
102
+ csv_parser = CsvParser(file_system_manager)
103
+ json_parser = JsonParser(file_system_manager)
104
+ unzip_processor = BaseUnzipProcessor(file_system_manager)
105
+
106
+ # Create processor chain
107
+ http_processor.set_next(csv_parser).set_next(json_parser).set_next(unzip_processor)
108
+
109
+ # Run the pipeline
110
+ input_data = "https://example.com/data.zip"
111
+ for output in http_processor.process(input_data):
112
+ print(output)
113
+ ```
114
+
115
+ ### Example ETL Pipeline(Flow 2: Using Operator Overloads)
116
+
117
+ ```python
118
+ from processors.http import HttpDataExtractProcessor
119
+ from processors.csv_parser import CsvParser
120
+ from processors.json_parser import JsonParser
121
+ from processors.unzip import BaseUnzipProcessor
122
+ from processors.file_system import AbstractFileSystemManager
123
+
124
+ # Create file system manager
125
+ file_system_manager = AbstractFileSystemManager()
126
+
127
+ # Create processors
128
+ http_processor = HttpDataExtractProcessor(file_system_manager)
129
+ csv_parser = CsvParser(file_system_manager)
130
+ json_parser = JsonParser(file_system_manager)
131
+ unzip_processor = BaseUnzipProcessor(file_system_manager)
132
+
133
+ # Create processor chain using `>>`
134
+ pipeline = http_processor >> csv_parser >> json_parser >> unzip_processor
135
+
136
+ # Run the pipeline
137
+ input_data = "https://example.com/data.zip"
138
+ for output in pipeline.process(input_data):
139
+ print(output)
140
+ ```
141
+
142
+ ### Example ETL Pipeline(Flow 3: Combining Parallel and Sequential Processing)
143
+
144
+ ```python
145
+ from operations import Op, OpAll, OpAny, PipelineConverter
146
+ from processors.file_system import FileModeEnum
147
+
148
+ def main():
149
+ # Define the pipeline with parallel processing for parsing and unzipping
150
+ pipeline = [
151
+ Op(
152
+ BaseOpEnum.downloading,
153
+ kwargs={
154
+ "file_system_manager": {...},
155
+ "retry_args": {
156
+ "max_retries": 3,
157
+ "delay": 1,
158
+ "delay_step": 1,
159
+ "retry_with_white_exc": True,
160
+ },
161
+ }
162
+ ),
163
+ Op(
164
+ BaseOpEnum.upzip,
165
+ kwargs={
166
+ "file_system_manager": {...}
167
+ }
168
+ ),
169
+ OpAny(
170
+ operations = [
171
+ Op(
172
+ BaseOpEnum.json_parsing,
173
+ kwargs={
174
+ "file_system_manager": {...}
175
+ }
176
+ ),
177
+ Op(
178
+ BaseOpEnum.csv_parsing,
179
+ kwargs={
180
+ "file_system_manager": {...},
181
+ "white_exceptions": [
182
+ TypeError,
183
+ BaseExceptionsEnum.csv_parsing_error,
184
+ BaseExceptionsEnum.file_system_exception,
185
+ ],
186
+ }
187
+ ),
188
+ ],
189
+ kwargs = {...}
190
+ ),
191
+ Op(
192
+ "app.processor.CustomProcessor",
193
+ kwargs = {...}
194
+ ),
195
+ ]
196
+
197
+ # Convert the high-level pipeline definition into a processor chain
198
+ processor = PipelineConverter(pipeline=pipeline).convert()
199
+
200
+ # Execute the pipeline
201
+ input_data = "https://example.com/data.zip"
202
+ for output in processor.process(input_data):
203
+ print(output)
204
+
205
+ if __name__ == "__main__":
206
+ main()
207
+ ```
208
+
209
+ ## Extensibility
210
+ The library is developer-friendly, making it easy to extend and integrate custom processors. Adding a new processor involves subclassing BaseProcessor and implementing its process method. This design ensures seamless integration with existing pipelines.
211
+
212
+ ## Example Usage
213
+
214
+ ```python
215
+ from processors.base import BaseProcessor
216
+
217
+ class CustomProcessor(BaseProcessor):
218
+ def process(self, input_data):
219
+ # Custom data processing logic
220
+ yield transformed_data
221
+ ```
222
+
223
+ This library is designed to handle a wide range of ETL requirements, making it a reliable choice for both simple and complex workflows. Whether you’re dealing with small-scale data extraction or managing high-throughput pipelines, the library’s flexibility, extensibility, and robust error handling provide a solid foundation for your ETL needs.
pipefy-0.0.1/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # ETL Pipeline Library
2
+
3
+ ## Description
4
+
5
+ This library is designed for building **ETL pipelines** (Extract, Transform, Load). It provides a set of processors to perform various data operations, such as extracting, transforming, and loading data into the desired format. Each processor in the library is a standalone unit that can be linked together in a chain to perform complex operations.
6
+
7
+ Processors support working with various data formats (CSV, JSON, ZIP, and others), allow flexible data processing configurations, handle exceptions, and interact with file systems to read and write data.
8
+
9
+ ## Key Features
10
+
11
+ - **Clean architecture with processor chains**: Each processor performs a specific task and can pass data to the next processor in the chain.
12
+ - **Support for various data formats**: The library includes processors for working with CSV, JSON, ZIP, and other formats.
13
+ - **Flexibility and configuration**: Support for various configuration options, such as custom converters for numbers, error handling methods, and working with large files.
14
+ - **Automation**: Option to automatically delete the source files after processing.
15
+ - **Error handling mechanisms**: The library provides support for ignoring or handling different exceptions at various stages of data processing.
16
+
17
+ ## Main Components
18
+
19
+ ### 1. **BaseProcessor**
20
+ The base class for all processors. It supports the chain of responsibility, allows configuring subprocessors for parallel or sequential processing, and manages exceptions.
21
+
22
+ ### 2. **ChainAnyProcessor**
23
+ A processor that attempts to process data through a series of sub-processors in sequence.
24
+
25
+ - **Behavior**:
26
+ - Each sub-processor tries to handle the data.
27
+ - The first successful sub-processor is moved to the front of the chain for prioritization in future attempts.
28
+ - If all sub-processors fail, an error is logged.
29
+ - **Use Case**: Useful when there are multiple processors capable of handling the same type of data, but with varying likelihoods of success.
30
+
31
+ ### 3. **ChainAllProcessor**
32
+ A processor that runs multiple sub-processors in parallel, either using threads or processes.
33
+
34
+ - **Behavior**:
35
+ - Executes all sub-processors simultaneously.
36
+ - Yields results from sub-processors as soon as they become available.
37
+ - Logs any exceptions that occur during processing.
38
+ - **Use Case**: Ideal for parallelizing independent operations, such as processing different parts of a dataset.
39
+
40
+ ### 4. **HttpDataExtractProcessor**
41
+ A processor for extracting data via HTTP GET requests, with the option to save the retrieved data to a file.
42
+
43
+ ### 5. **HttpxStreamDownloadProcessor**
44
+ A processor for streaming large file downloads via HTTP, with the ability to process data in parallel.
45
+
46
+ ### 6. **CsvParser**
47
+ A processor for parsing CSV files using the `pandas` library. It supports numerous options, including handling delimiters, skipping empty lines, and processing data in chunks.
48
+
49
+ ### 7. **JsonParser**
50
+ A processor for parsing JSON data from strings or files into Python dictionaries. It supports configuring how numbers, constants (e.g., NaN), and JSON objects are handled with custom functions.
51
+
52
+ ### 8. **BaseUnzipProcessor**
53
+ A processor for extracting files from `.zip` archives. It supports extracting data into files, managing chunk sizes, and deleting the original archive after processing.
54
+
55
+ ### 9. **RetryProcessor**
56
+
57
+ A processor designed to handle transient errors by retrying operations based on a customizable retry policy.
58
+
59
+ - **Key Features**:
60
+ - **Configurable Retry Logic**: Supports setting a maximum number of retries and delays between attempts (fixed or exponential backoff).
61
+ - **White-listed Exceptions**: Retries only specific exceptions defined by the user.
62
+ - **Logging and Metrics**: Logs every retry attempt and provides details about failures.
63
+ - **Fallback Handling**: Allows defining a fallback action if all retry attempts fail.
64
+ - **Use Case**: Ideal for handling temporary issues like network timeouts, database connection errors, or transient API failures.
65
+
66
+ ## Example Usage
67
+
68
+ ### Example ETL Pipeline(Flow 1)
69
+
70
+ ```python
71
+ from processors.http import HttpDataExtractProcessor
72
+ from processors.csv_parser import CsvParser
73
+ from processors.json_parser import JsonParser
74
+ from processors.unzip import BaseUnzipProcessor
75
+ from processors.file_system import AbstractFileSystemManager
76
+
77
+ # Create file system manager
78
+ file_system_manager = AbstractFileSystemManager()
79
+
80
+ # Create processors
81
+ http_processor = HttpDataExtractProcessor(file_system_manager)
82
+ csv_parser = CsvParser(file_system_manager)
83
+ json_parser = JsonParser(file_system_manager)
84
+ unzip_processor = BaseUnzipProcessor(file_system_manager)
85
+
86
+ # Create processor chain
87
+ http_processor.set_next(csv_parser).set_next(json_parser).set_next(unzip_processor)
88
+
89
+ # Run the pipeline
90
+ input_data = "https://example.com/data.zip"
91
+ for output in http_processor.process(input_data):
92
+ print(output)
93
+ ```
94
+
95
+ ### Example ETL Pipeline(Flow 2: Using Operator Overloads)
96
+
97
+ ```python
98
+ from processors.http import HttpDataExtractProcessor
99
+ from processors.csv_parser import CsvParser
100
+ from processors.json_parser import JsonParser
101
+ from processors.unzip import BaseUnzipProcessor
102
+ from processors.file_system import AbstractFileSystemManager
103
+
104
+ # Create file system manager
105
+ file_system_manager = AbstractFileSystemManager()
106
+
107
+ # Create processors
108
+ http_processor = HttpDataExtractProcessor(file_system_manager)
109
+ csv_parser = CsvParser(file_system_manager)
110
+ json_parser = JsonParser(file_system_manager)
111
+ unzip_processor = BaseUnzipProcessor(file_system_manager)
112
+
113
+ # Create processor chain using `>>`
114
+ pipeline = http_processor >> csv_parser >> json_parser >> unzip_processor
115
+
116
+ # Run the pipeline
117
+ input_data = "https://example.com/data.zip"
118
+ for output in pipeline.process(input_data):
119
+ print(output)
120
+ ```
121
+
122
+ ### Example ETL Pipeline(Flow 3: Combining Parallel and Sequential Processing)
123
+
124
+ ```python
125
+ from operations import Op, OpAll, OpAny, PipelineConverter
126
+ from processors.file_system import FileModeEnum
127
+
128
+ def main():
129
+ # Define the pipeline with parallel processing for parsing and unzipping
130
+ pipeline = [
131
+ Op(
132
+ BaseOpEnum.downloading,
133
+ kwargs={
134
+ "file_system_manager": {...},
135
+ "retry_args": {
136
+ "max_retries": 3,
137
+ "delay": 1,
138
+ "delay_step": 1,
139
+ "retry_with_white_exc": True,
140
+ },
141
+ }
142
+ ),
143
+ Op(
144
+ BaseOpEnum.upzip,
145
+ kwargs={
146
+ "file_system_manager": {...}
147
+ }
148
+ ),
149
+ OpAny(
150
+ operations = [
151
+ Op(
152
+ BaseOpEnum.json_parsing,
153
+ kwargs={
154
+ "file_system_manager": {...}
155
+ }
156
+ ),
157
+ Op(
158
+ BaseOpEnum.csv_parsing,
159
+ kwargs={
160
+ "file_system_manager": {...},
161
+ "white_exceptions": [
162
+ TypeError,
163
+ BaseExceptionsEnum.csv_parsing_error,
164
+ BaseExceptionsEnum.file_system_exception,
165
+ ],
166
+ }
167
+ ),
168
+ ],
169
+ kwargs = {...}
170
+ ),
171
+ Op(
172
+ "app.processor.CustomProcessor",
173
+ kwargs = {...}
174
+ ),
175
+ ]
176
+
177
+ # Convert the high-level pipeline definition into a processor chain
178
+ processor = PipelineConverter(pipeline=pipeline).convert()
179
+
180
+ # Execute the pipeline
181
+ input_data = "https://example.com/data.zip"
182
+ for output in processor.process(input_data):
183
+ print(output)
184
+
185
+ if __name__ == "__main__":
186
+ main()
187
+ ```
188
+
189
+ ## Extensibility
190
+ The library is developer-friendly, making it easy to extend and integrate custom processors. Adding a new processor involves subclassing BaseProcessor and implementing its process method. This design ensures seamless integration with existing pipelines.
191
+
192
+ ## Example Usage
193
+
194
+ ```python
195
+ from processors.base import BaseProcessor
196
+
197
+ class CustomProcessor(BaseProcessor):
198
+ def process(self, input_data):
199
+ # Custom data processing logic
200
+ yield transformed_data
201
+ ```
202
+
203
+ This library is designed to handle a wide range of ETL requirements, making it a reliable choice for both simple and complex workflows. Whether you’re dealing with small-scale data extraction or managing high-throughput pipelines, the library’s flexibility, extensibility, and robust error handling provide a solid foundation for your ETL needs.
File without changes
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ from pipefy.etl.extract.http.http_extractor import (
2
+ HttpDataExtractProcessor,
3
+ HttpxStreamDownloadProcessor,
4
+ )
5
+
6
+ __all__ = (
7
+ "HttpDataExtractProcessor",
8
+ "HttpxStreamDownloadProcessor",
9
+ )