echr-extractor 0.0.1.dev1__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 (36) hide show
  1. echr_extractor-0.0.1.dev1/.flake8 +10 -0
  2. echr_extractor-0.0.1.dev1/.github/workflows/ci.yml +163 -0
  3. echr_extractor-0.0.1.dev1/.gitignore +139 -0
  4. echr_extractor-0.0.1.dev1/CHANGELOG.md +71 -0
  5. echr_extractor-0.0.1.dev1/IMPROVEMENTS.md +216 -0
  6. echr_extractor-0.0.1.dev1/LICENSE +201 -0
  7. echr_extractor-0.0.1.dev1/MANIFEST.in +7 -0
  8. echr_extractor-0.0.1.dev1/Makefile +42 -0
  9. echr_extractor-0.0.1.dev1/PKG-INFO +189 -0
  10. echr_extractor-0.0.1.dev1/README.md +144 -0
  11. echr_extractor-0.0.1.dev1/RELEASE.md +166 -0
  12. echr_extractor-0.0.1.dev1/examples/examples.py +58 -0
  13. echr_extractor-0.0.1.dev1/pyproject.toml +114 -0
  14. echr_extractor-0.0.1.dev1/requirements.txt +5 -0
  15. echr_extractor-0.0.1.dev1/sample.py +14 -0
  16. echr_extractor-0.0.1.dev1/scripts/release.py +127 -0
  17. echr_extractor-0.0.1.dev1/setup.cfg +4 -0
  18. echr_extractor-0.0.1.dev1/src/echr_extractor/ECHR_html_downloader.py +82 -0
  19. echr_extractor-0.0.1.dev1/src/echr_extractor/ECHR_metadata_harvester.py +575 -0
  20. echr_extractor-0.0.1.dev1/src/echr_extractor/ECHR_nodes_edges_list_transform.py +308 -0
  21. echr_extractor-0.0.1.dev1/src/echr_extractor/__init__.py +18 -0
  22. echr_extractor-0.0.1.dev1/src/echr_extractor/_version.py +34 -0
  23. echr_extractor-0.0.1.dev1/src/echr_extractor/clean_ref.py +5 -0
  24. echr_extractor-0.0.1.dev1/src/echr_extractor/cli.py +125 -0
  25. echr_extractor-0.0.1.dev1/src/echr_extractor/echr.py +266 -0
  26. echr_extractor-0.0.1.dev1/src/echr_extractor/testing_file.py +20 -0
  27. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/PKG-INFO +189 -0
  28. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/SOURCES.txt +34 -0
  29. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/dependency_links.txt +1 -0
  30. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/entry_points.txt +2 -0
  31. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/requires.txt +17 -0
  32. echr_extractor-0.0.1.dev1/src/echr_extractor.egg-info/top_level.txt +1 -0
  33. echr_extractor-0.0.1.dev1/tests/__init__.py +1 -0
  34. echr_extractor-0.0.1.dev1/tests/conftest.py +27 -0
  35. echr_extractor-0.0.1.dev1/tests/test_basic.py +53 -0
  36. echr_extractor-0.0.1.dev1/tests/test_echr.py +175 -0
@@ -0,0 +1,10 @@
1
+ [flake8]
2
+ max-line-length = 88
3
+ extend-ignore = E203, W503, E501
4
+ exclude =
5
+ .git,
6
+ __pycache__,
7
+ .venv,
8
+ build,
9
+ dist,
10
+ *.egg-info
@@ -0,0 +1,163 @@
1
+ name: Build, Test, Lint & Upload to TestPyPI and PyPI for ECHR-extractor
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+
10
+ jobs:
11
+ lint:
12
+ if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Check out the repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: '3.9'
22
+
23
+ - name: Lint with super linter
24
+ uses: github/super-linter@v4
25
+ env:
26
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27
+ DEFAULT_BRANCH: 'main'
28
+ VALIDATE_PYTHON_BLACK: true
29
+ IGNORE_GITIGNORED_FILES: true
30
+ VALIDATE_ALL_CODEBASE: false
31
+
32
+ test:
33
+ needs: lint
34
+ if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
35
+ name: Test on ${{ matrix.os }}
36
+ runs-on: ${{ matrix.os }}
37
+ strategy:
38
+ matrix:
39
+ os: [ubuntu-latest, windows-latest, macos-latest]
40
+ python-version: ['3.9', '3.10', '3.11', '3.12']
41
+
42
+ steps:
43
+ - name: Check out the repository
44
+ uses: actions/checkout@v4
45
+
46
+ - name: Set up Python ${{ matrix.python-version }}
47
+ uses: actions/setup-python@v5
48
+ with:
49
+ python-version: ${{ matrix.python-version }}
50
+
51
+ - name: Install dependencies
52
+ run: |
53
+ python -m pip install --upgrade pip
54
+ pip install setuptools wheel pytest pytest-cov
55
+ pip install -r requirements.txt
56
+
57
+
58
+ - name: Install package for testing
59
+ run: |
60
+ pip install -e .
61
+
62
+ - name: Run tests with pytest
63
+ run: |
64
+ mkdir -p junit
65
+ pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=src/echr_extractor --cov-report=xml --cov-report=html
66
+
67
+ build:
68
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
69
+ name: Build Python package
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+ - name: Set up Python
74
+ uses: actions/setup-python@v5
75
+ with:
76
+ python-version: '3.9'
77
+
78
+ - name: Install build dependencies
79
+ run: |
80
+ python -m pip install --upgrade pip
81
+ pip install setuptools wheel build setuptools_scm
82
+
83
+ - name: Show version that will be built
84
+ run: |
85
+ python -c "import setuptools_scm; print('Version:', setuptools_scm.get_version())"
86
+
87
+ - name: Build package
88
+ run: |
89
+ python -m build
90
+
91
+ - name: Upload build artifacts
92
+ if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
93
+ uses: actions/upload-artifact@v4
94
+ with:
95
+ name: python-package-distributions
96
+ path: dist/
97
+
98
+ pypi-publish:
99
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
100
+ name: Publish to PyPI
101
+ needs: build
102
+ runs-on: ubuntu-latest
103
+ environment:
104
+ name: pypi
105
+ url: https://pypi.org/project/echr-extractor/
106
+ permissions:
107
+ id-token: write
108
+ steps:
109
+ - name: Download all the artifacts
110
+ uses: actions/download-artifact@v4
111
+ with:
112
+ name: python-package-distributions
113
+ path: dist/
114
+
115
+ - name: Publish distribution to PyPI
116
+ uses: pypa/gh-action-pypi-publish@release/v1
117
+
118
+ github-release:
119
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
120
+ name: Sign the Python distribution with Sigstore and upload them to GitHub Releases
121
+ needs:
122
+ - pypi-publish
123
+ runs-on: ubuntu-latest
124
+ permissions:
125
+ id-token: write
126
+ contents: write
127
+
128
+ steps:
129
+ - name: Download all the artifacts
130
+ uses: actions/download-artifact@v4
131
+ with:
132
+ name: python-package-distributions
133
+ path: dist/
134
+
135
+ - name: Sign the Python distribution with Sigstore
136
+ uses: sigstore/gh-action-sigstore-python@v3.0.0
137
+ with:
138
+ inputs: >-
139
+ ./dist/*.tar.gz
140
+ ./dist/*.whl
141
+
142
+ - name: Get version from setuptools_scm
143
+ id: version
144
+ run: |
145
+ python -c "import setuptools_scm; print('version=' + setuptools_scm.get_version())" >> $GITHUB_OUTPUT
146
+
147
+ - name: Create Github release
148
+ env:
149
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150
+ run: |
151
+ gh release create \
152
+ 'echr-extractor-${{ steps.version.outputs.version }}' \
153
+ --repo '${{ github.repository }}' \
154
+ --target 'main' \
155
+ --notes ""
156
+
157
+ - name: Upload artifact signatures to Github release
158
+ env:
159
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160
+ run: |
161
+ gh release upload \
162
+ 'echr-extractor-${{ env.RELEASE_VERSION }}' ./dist/*.tar.gz ./dist/*.whl \
163
+ --repo '${{ github.repository }}'
@@ -0,0 +1,139 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # Data files
132
+ data/
133
+ *.csv
134
+ *.json
135
+
136
+ # Temporary files
137
+ temp_repo/
138
+
139
+ .vscode
@@ -0,0 +1,71 @@
1
+ # Changelog
2
+
3
+ All notable changes to the ECHR Extractor project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.0] - 2025-09-12
9
+
10
+ ### Added
11
+
12
+ - Date range batching for large datasets to prevent API timeouts
13
+ - Enhanced error handling with exponential backoff retry logic
14
+ - Progress tracking with tqdm progress bars for long-running operations
15
+ - Memory management with chunked processing for large datasets
16
+ - Configurable batch sizes, timeouts, and retry parameters
17
+ - Comprehensive docstrings and usage examples for all functions
18
+ - New parameters: `batch_size`, `timeout`, `retry_attempts`, `max_attempts`, `days_per_batch`, `progress_bar`, `memory_efficient`
19
+
20
+ ### Changed
21
+
22
+ - Enhanced `get_r()` function with better error handling and exponential backoff
23
+ - Completely rewritten `get_echr_metadata()` with batching and memory management
24
+ - Updated `get_echr()` and `get_echr_extra()` functions with new configuration parameters
25
+ - Improved logging and status reporting throughout the extraction process
26
+ - Better handling of large date ranges by splitting them into manageable chunks
27
+
28
+ ### Fixed
29
+
30
+ - Memory issues when processing very large datasets
31
+ - API timeout issues for multi-year date range extractions
32
+ - Better error recovery and retry mechanisms
33
+ - Improved handling of network failures and connection errors
34
+
35
+ ### Performance
36
+
37
+ - Significantly improved reliability for large-scale data extraction
38
+ - Reduced memory usage through intelligent chunked processing
39
+ - Better progress visibility for long-running operations
40
+ - More robust handling of network interruptions
41
+
42
+ ## [1.0.44] - 2025-07-02
43
+
44
+ ### Added
45
+
46
+ - Initial release as standalone package
47
+ - Migrated from maastrichtlawtech/extraction_libraries echr branch
48
+ - Modern Python package structure with pyproject.toml
49
+ - Command-line interface (CLI) support
50
+ - Comprehensive documentation and examples
51
+ - CI/CD pipeline with GitHub Actions
52
+ - Development tools setup (black, isort, flake8, pytest)
53
+
54
+ ### Changed
55
+
56
+ - Restructured as proper Python package with src/ layout
57
+ - Updated import statements for relative imports
58
+ - Improved package metadata and dependencies
59
+ - Enhanced README with comprehensive usage examples
60
+
61
+ ### Fixed
62
+
63
+ - Import paths for proper package distribution
64
+ - Package structure for PyPI publishing
65
+ - Dependencies and requirements specifications
66
+
67
+ ## Previous Versions
68
+
69
+ This package was previously part of the extraction_libraries repository
70
+ under the 'echr' branch. For historical changes, please refer to:
71
+ https://github.com/maastrichtlawtech/extraction_libraries/tree/echr
@@ -0,0 +1,216 @@
1
+ # ECHR Extractor Improvements - Technical Documentation
2
+
3
+ ## Overview
4
+
5
+ Improved error handling, memory management, and processing capabilities. These changes address reliability issues in large-scale data extraction while maintaining full backward compatibility.
6
+
7
+ ## Problem Statement
8
+
9
+ ### Issues Addressed
10
+
11
+ - Large data extractions frequently failed due to API timeouts
12
+ - Memory consumption issues when processing large datasets
13
+ - Lack of progress visibility during long-running extractions
14
+ - Limited error recovery mechanisms for network failures
15
+
16
+ ### Impact
17
+
18
+ - Failed extractions required manual intervention and restart
19
+ - Large datasets could not be processed due to memory constraints
20
+ - Users had no visibility into extraction progress
21
+ - Network interruptions caused complete extraction failures
22
+
23
+ ## Technical Improvements
24
+
25
+ ### 1. Date Range Batching System
26
+
27
+ **Implementation:**
28
+
29
+ - Automatically splits large date ranges into manageable chunks (default: 365 days)
30
+ - Prevents API timeouts that previously caused extraction failures
31
+ - Processes each chunk independently with proper error handling
32
+
33
+ **Technical Details:**
34
+
35
+ - Chunk size is configurable via `days_per_batch` parameter
36
+ - Each chunk is processed as a separate API request
37
+ - Failed chunks can be retried independently
38
+
39
+ **Code Example:**
40
+
41
+ ```python
42
+ # Automatic batching for large date ranges
43
+ df = get_echr(
44
+ start_date='2010-01-01',
45
+ end_date='2020-12-31',
46
+ days_per_batch=365 # Processes in 1-year chunks
47
+ )
48
+ ```
49
+
50
+ ### 2. Enhanced Error Handling and Retry Logic
51
+
52
+ **Implementation:**
53
+
54
+ - Implements exponential backoff retry strategy (2^count seconds, max 30s)
55
+ - Better error detection with HTTP status code checking
56
+ - Detailed error logging for troubleshooting
57
+
58
+ **Technical Details:**
59
+
60
+ - Retry strategy: 3 attempts with exponential backoff
61
+ - Error types handled: timeouts, connection errors, HTTP errors
62
+ - Comprehensive logging with error context
63
+
64
+ ### 3. Progress Tracking
65
+
66
+ **Implementation:**
67
+
68
+ - Real-time progress bars using tqdm library
69
+ - Batch-level progress reporting
70
+ - Clear status messages and completion estimates
71
+
72
+ **Technical Details:**
73
+
74
+ - Progress bars show current batch and overall progress
75
+ - Configurable via `progress_bar` parameter
76
+ - Displays processing speed and estimated completion time
77
+
78
+ **Example Output:**
79
+
80
+ ```
81
+ Batch 1/5: 2020-01-01 to 2020-12-31: 100%|██████████| 1500/1500 [05:30<00:00, 4.54it/s]
82
+ Batch 2/5: 2021-01-01 to 2021-12-31: 100%|██████████| 1200/1200 [04:20<00:00, 4.61it/s]
83
+ ```
84
+
85
+ ### 4. Memory Management
86
+
87
+ **Implementation:**
88
+
89
+ - Chunked processing for large datasets (10,000 records per chunk)
90
+ - Automatic garbage collection between chunks
91
+ - Configurable memory efficiency settings
92
+
93
+ **Technical Details:**
94
+
95
+ - Memory-efficient processing controlled by `memory_efficient` parameter
96
+ - Garbage collection forced between chunks to free memory
97
+ - Prevents memory accumulation during large extractions
98
+
99
+ ### 5. Configuration Parameters
100
+
101
+ **New Parameters:**
102
+
103
+ - `batch_size`: Records per API request (default: 500, max: 500)
104
+ - `timeout`: Request timeout in seconds (default: 60)
105
+ - `retry_attempts`: Number of retry attempts (default: 3)
106
+ - `max_attempts`: Maximum total attempts (default: 20)
107
+ - `days_per_batch`: Days per date batch (default: 365)
108
+ - `progress_bar`: Show progress bars (default: True)
109
+ - `memory_efficient`: Use chunked processing (default: True)
110
+
111
+ ## Performance Improvements
112
+
113
+ ### Memory Usage
114
+
115
+ - Memory consumption is now controlled through chunked processing
116
+ - Large datasets are processed in 10,000-record chunks
117
+ - Garbage collection is forced between chunks to prevent memory accumulation
118
+
119
+ ### Error Recovery
120
+
121
+ - Automatic retry mechanism with exponential backoff
122
+ - Network failures no longer cause complete extraction failures
123
+ - Individual chunks can be retried independently
124
+
125
+ ### Progress Visibility
126
+
127
+ - Real-time progress bars show extraction status
128
+ - Users can monitor progress and estimate completion time
129
+ - Batch-level reporting provides detailed progress information
130
+
131
+ ## Backward Compatibility
132
+
133
+ ### Compatibility Guarantee
134
+
135
+ - All existing code continues to work unchanged
136
+ - New parameters are optional with sensible defaults
137
+ - Original function signatures preserved
138
+ - Default behavior identical to previous version
139
+
140
+ ### Migration Path
141
+
142
+ ```python
143
+ # Existing code - works exactly as before
144
+ df = get_echr(start_id=0, end_id=1000, verbose=True)
145
+
146
+ # Enhanced code - same result, additional features available
147
+ df = get_echr(
148
+ start_id=0,
149
+ end_id=1000,
150
+ verbose=True,
151
+ batch_size=250, # Optional: smaller batches
152
+ progress_bar=True, # Optional: show progress
153
+ memory_efficient=True # Optional: use chunked processing
154
+ )
155
+ ```
156
+
157
+ ## User Benefits
158
+
159
+ ### For Researchers
160
+
161
+ - Improved reliability for large dataset extractions
162
+ - Progress visibility during long-running operations
163
+ - Configurable parameters for different research needs
164
+ - Better memory management for large extractions
165
+
166
+ ### For IT Support
167
+
168
+ - Reduced extraction failure reports due to better error handling
169
+ - Detailed error logs and status messages for troubleshooting
170
+ - Clear progress indicators and error reporting
171
+
172
+ ### For Project Managers
173
+
174
+ - More reliable extractions enable better project planning
175
+ - Reduced support overhead due to improved error handling
176
+ - Better scalability for large research projects
177
+
178
+ ## Implementation Details
179
+
180
+ ### Files Modified
181
+
182
+ 1. **`ECHR_metadata_harvester.py`**: Core extraction logic with batching and error handling
183
+ 2. **`echr.py`**: Main API functions with new configuration parameters
184
+ 3. **`CHANGELOG.md`**: Documentation of changes
185
+
186
+ ### Dependencies
187
+
188
+ - **tqdm**: Progress bar library (already in requirements.txt)
189
+ - **timedelta**: Date manipulation (part of standard library)
190
+
191
+ ### Testing
192
+
193
+ - Backward compatibility verified with existing code
194
+ - New features tested with real ECHR data
195
+ - Memory usage improvements validated
196
+ - Error handling tested with various failure scenarios
197
+
198
+ ## Technical Benefits
199
+
200
+ ### Scalability
201
+
202
+ - Improved handling of large datasets through chunked processing
203
+ - Memory usage controlled through configurable chunk sizes
204
+ - Better suited for enterprise-level research projects
205
+
206
+ ### Maintainability
207
+
208
+ - Enhanced error handling reduces debugging time
209
+ - Comprehensive logging improves troubleshooting
210
+ - Modular design facilitates future enhancements
211
+
212
+ ### Usability
213
+
214
+ - Progress tracking improves user experience
215
+ - Configurable parameters support diverse research needs
216
+ - Better error messages aid in troubleshooting