grobid-client-python 0.0.17__tar.gz → 0.0.18__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.
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/PKG-INFO +1 -1
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/config.json +1 -1
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/grobid_client.py +12 -6
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/PKG-INFO +1 -1
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/pyproject.toml +1 -1
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_config.json +1 -1
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_grobid_client.py +4 -4
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_integration.py +2 -3
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.github/workflows/ci-build.yml +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.github/workflows/ci-release.yml +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.gitignore +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/LICENSE +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/MANIFEST.in +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/Readme.md +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/example.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/__init__.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/client.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/SOURCES.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/dependency_links.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/entry_points.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/requires.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/top_level.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/pytest.ini +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/requirements.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/20180928112135.png +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/20180928112138.csv +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_out/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_out/test_1/0f318087-b211-4ace-8ac9-3d9372a73c1c.tei.xml +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.pdf +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-1.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-2.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-3.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-4.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-5.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-6.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-7.txt +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/setup.cfg +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/__init__.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/conftest.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/run_tests.py +0 -0
- {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: grobid-client-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.18
|
|
4
4
|
Summary: Simple python client for GROBID REST services
|
|
5
5
|
Author-email: Patrice Lopez <patrice.lopez@science-miner.com>
|
|
6
6
|
Maintainer-email: Patrice Lopez <patrice.lopez@science-miner.com>, Luca Foppiano <lucanoro@duck.com>
|
|
@@ -60,7 +60,7 @@ class GrobidClient(ApiClient):
|
|
|
60
60
|
],
|
|
61
61
|
'logging': {
|
|
62
62
|
'level': 'INFO',
|
|
63
|
-
'format': '%(asctime)s - %(
|
|
63
|
+
'format': '%(asctime)s - %(levelname)s - %(message)s',
|
|
64
64
|
'console': True,
|
|
65
65
|
'file': None, # Disabled by default
|
|
66
66
|
'max_file_size': '10MB',
|
|
@@ -133,7 +133,7 @@ class GrobidClient(ApiClient):
|
|
|
133
133
|
log_level = getattr(logging, log_level_str, logging.INFO)
|
|
134
134
|
|
|
135
135
|
# Parse log format
|
|
136
|
-
log_format = log_config.get('format', '%(asctime)s - %(
|
|
136
|
+
log_format = log_config.get('format', '%(asctime)s - %(levelname)s - %(message)s')
|
|
137
137
|
|
|
138
138
|
# Create formatter
|
|
139
139
|
formatter = logging.Formatter(log_format)
|
|
@@ -347,6 +347,7 @@ class GrobidClient(ApiClient):
|
|
|
347
347
|
|
|
348
348
|
# Counter for actually processed files
|
|
349
349
|
processed_files_count = 0
|
|
350
|
+
errors_files_count = 0
|
|
350
351
|
input_files = []
|
|
351
352
|
|
|
352
353
|
for input_file in all_input_files:
|
|
@@ -363,7 +364,7 @@ class GrobidClient(ApiClient):
|
|
|
363
364
|
input_files.append(input_file)
|
|
364
365
|
|
|
365
366
|
if len(input_files) == batch_size_pdf:
|
|
366
|
-
batch_processed = self.process_batch(
|
|
367
|
+
batch_processed, batch_errors = self.process_batch(
|
|
367
368
|
service,
|
|
368
369
|
input_files,
|
|
369
370
|
input_path,
|
|
@@ -381,11 +382,12 @@ class GrobidClient(ApiClient):
|
|
|
381
382
|
flavor
|
|
382
383
|
)
|
|
383
384
|
processed_files_count += batch_processed
|
|
385
|
+
errors_files_count += batch_errors
|
|
384
386
|
input_files = []
|
|
385
387
|
|
|
386
388
|
# last batch
|
|
387
389
|
if len(input_files) > 0:
|
|
388
|
-
batch_processed = self.process_batch(
|
|
390
|
+
batch_processed, batch_errors = self.process_batch(
|
|
389
391
|
service,
|
|
390
392
|
input_files,
|
|
391
393
|
input_path,
|
|
@@ -402,9 +404,11 @@ class GrobidClient(ApiClient):
|
|
|
402
404
|
verbose,
|
|
403
405
|
)
|
|
404
406
|
processed_files_count += batch_processed
|
|
407
|
+
errors_files_count += batch_errors
|
|
405
408
|
|
|
406
409
|
# Log final statistics
|
|
407
410
|
self.logger.info(f"Processing completed: {processed_files_count} out of {total_files} files processed")
|
|
411
|
+
self.logger.info(f"Errors: {errors_files_count} out of {total_files} files processed")
|
|
408
412
|
|
|
409
413
|
def process_batch(
|
|
410
414
|
self,
|
|
@@ -428,6 +432,7 @@ class GrobidClient(ApiClient):
|
|
|
428
432
|
self.logger.info(f"{len(input_files)} files to process in current batch")
|
|
429
433
|
|
|
430
434
|
processed_count = 0
|
|
435
|
+
error_count = 0
|
|
431
436
|
|
|
432
437
|
# we use ThreadPoolExecutor and not ProcessPoolExecutor because it is an I/O intensive process
|
|
433
438
|
with concurrent.futures.ThreadPoolExecutor(max_workers=n) as executor:
|
|
@@ -468,10 +473,10 @@ class GrobidClient(ApiClient):
|
|
|
468
473
|
for r in concurrent.futures.as_completed(results):
|
|
469
474
|
input_file, status, text = r.result()
|
|
470
475
|
filename = self._output_file_name(input_file, input_path, output)
|
|
471
|
-
processed_count += 1
|
|
472
476
|
|
|
473
477
|
if status != 200 or text is None:
|
|
474
478
|
self.logger.error(f"Processing of {input_file} failed with error {status}: {text}")
|
|
479
|
+
error_count += 1
|
|
475
480
|
# writing error file with suffixed error code
|
|
476
481
|
try:
|
|
477
482
|
pathlib.Path(os.path.dirname(filename)).mkdir(parents=True, exist_ok=True)
|
|
@@ -485,6 +490,7 @@ class GrobidClient(ApiClient):
|
|
|
485
490
|
except OSError as e:
|
|
486
491
|
self.logger.error(f"Failed to write error file {filename}: {str(e)}")
|
|
487
492
|
else:
|
|
493
|
+
processed_count += 1
|
|
488
494
|
# writing TEI file
|
|
489
495
|
try:
|
|
490
496
|
pathlib.Path(os.path.dirname(filename)).mkdir(parents=True, exist_ok=True)
|
|
@@ -494,7 +500,7 @@ class GrobidClient(ApiClient):
|
|
|
494
500
|
except OSError as e:
|
|
495
501
|
self.logger.error(f"Failed to write TEI XML file {filename}: {str(e)}")
|
|
496
502
|
|
|
497
|
-
return processed_count
|
|
503
|
+
return processed_count, error_count
|
|
498
504
|
|
|
499
505
|
def process_pdf(
|
|
500
506
|
self,
|
{grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: grobid-client-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.18
|
|
4
4
|
Summary: Simple python client for GROBID REST services
|
|
5
5
|
Author-email: Patrice Lopez <patrice.lopez@science-miner.com>
|
|
6
6
|
Maintainer-email: Patrice Lopez <patrice.lopez@science-miner.com>, Luca Foppiano <lucanoro@duck.com>
|
|
@@ -26,7 +26,7 @@ class TestGrobidClient:
|
|
|
26
26
|
'timeout': 60,
|
|
27
27
|
'logging': {
|
|
28
28
|
'level': 'INFO',
|
|
29
|
-
'format': '%(asctime)s - %(
|
|
29
|
+
'format': '%(asctime)s - %(levelname)s - %(message)s',
|
|
30
30
|
'console': True,
|
|
31
31
|
'file': None
|
|
32
32
|
}
|
|
@@ -41,7 +41,7 @@ class TestGrobidClient:
|
|
|
41
41
|
client = GrobidClient(check_server=False)
|
|
42
42
|
|
|
43
43
|
assert client.config['grobid_server'] == 'http://localhost:8070'
|
|
44
|
-
assert client.config['batch_size'] ==
|
|
44
|
+
assert client.config['batch_size'] == 10
|
|
45
45
|
assert client.config['sleep_time'] == 5
|
|
46
46
|
assert client.config['timeout'] == 180
|
|
47
47
|
assert 'persName' in client.config['coordinates']
|
|
@@ -258,7 +258,7 @@ class TestGrobidClient:
|
|
|
258
258
|
with patch('grobid_client.grobid_client.GrobidClient._test_server_connection'):
|
|
259
259
|
with patch('grobid_client.grobid_client.GrobidClient._configure_logging'):
|
|
260
260
|
with patch('grobid_client.grobid_client.GrobidClient.process_batch') as mock_batch:
|
|
261
|
-
mock_batch.return_value = 2
|
|
261
|
+
mock_batch.return_value = (2, 0) # Return tuple as expected
|
|
262
262
|
client = GrobidClient(check_server=False)
|
|
263
263
|
client.logger = Mock()
|
|
264
264
|
|
|
@@ -421,7 +421,7 @@ class TestGrobidClient:
|
|
|
421
421
|
verbose=False
|
|
422
422
|
)
|
|
423
423
|
|
|
424
|
-
assert result == 1 # One file processed
|
|
424
|
+
assert result == (1, 0) # One file processed, zero errors
|
|
425
425
|
|
|
426
426
|
|
|
427
427
|
class TestServerUnavailableException:
|
|
@@ -181,7 +181,7 @@ class TestGrobidClientIntegration:
|
|
|
181
181
|
force=True
|
|
182
182
|
)
|
|
183
183
|
|
|
184
|
-
assert processed_count == 5
|
|
184
|
+
assert processed_count == (5, 0)
|
|
185
185
|
|
|
186
186
|
def test_error_handling_and_recovery(self):
|
|
187
187
|
"""Test error handling and recovery mechanisms."""
|
|
@@ -342,5 +342,4 @@ class TestGrobidClientIntegration:
|
|
|
342
342
|
force=True
|
|
343
343
|
)
|
|
344
344
|
|
|
345
|
-
assert processed_count == 20
|
|
346
|
-
|
|
345
|
+
assert processed_count == (20, 0)
|
|
File without changes
|
{grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.github/workflows/ci-release.yml
RENAMED
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|