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.
Files changed (42) hide show
  1. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/PKG-INFO +1 -1
  2. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/config.json +1 -1
  3. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/grobid_client.py +12 -6
  4. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/PKG-INFO +1 -1
  5. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/pyproject.toml +1 -1
  6. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_config.json +1 -1
  7. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_grobid_client.py +4 -4
  8. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/test_integration.py +2 -3
  9. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.github/workflows/ci-build.yml +0 -0
  10. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.github/workflows/ci-release.yml +0 -0
  11. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/.gitignore +0 -0
  12. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/LICENSE +0 -0
  13. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/MANIFEST.in +0 -0
  14. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/Readme.md +0 -0
  15. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/example.py +0 -0
  16. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/__init__.py +0 -0
  17. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client/client.py +0 -0
  18. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/SOURCES.txt +0 -0
  19. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/dependency_links.txt +0 -0
  20. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/entry_points.txt +0 -0
  21. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/requires.txt +0 -0
  22. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/top_level.txt +0 -0
  23. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/pytest.ini +0 -0
  24. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/requirements.txt +0 -0
  25. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/20180928112135.png +0 -0
  26. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/20180928112138.csv +0 -0
  27. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_out/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
  28. {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
  29. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.pdf +0 -0
  30. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
  31. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-1.txt +0 -0
  32. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-2.txt +0 -0
  33. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-3.txt +0 -0
  34. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-4.txt +0 -0
  35. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-5.txt +0 -0
  36. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-6.txt +0 -0
  37. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-7.txt +0 -0
  38. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/setup.cfg +0 -0
  39. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/__init__.py +0 -0
  40. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/conftest.py +0 -0
  41. {grobid_client_python-0.0.17 → grobid_client_python-0.0.18}/tests/run_tests.py +0 -0
  42. {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.17
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>
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "logging": {
21
21
  "level": "INFO",
22
- "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
22
+ "format": "%(asctime)s - %(levelname)s - %(message)s",
23
23
  "console": true,
24
24
  "file": null,
25
25
  "max_file_size": "10MB",
@@ -60,7 +60,7 @@ class GrobidClient(ApiClient):
60
60
  ],
61
61
  'logging': {
62
62
  'level': 'INFO',
63
- 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)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 - %(name)s - %(levelname)s - %(message)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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: grobid-client-python
3
- Version: 0.0.17
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>
@@ -3,7 +3,7 @@ requires = ["setuptools", "setuptools-scm"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.bumpversion]
6
- current_version = "0.0.17"
6
+ current_version = "0.0.18"
7
7
  commit = "true"
8
8
  tag = "true"
9
9
  tag_name = "v{new_version}"
@@ -6,7 +6,7 @@
6
6
  "timeout": 30,
7
7
  "logging": {
8
8
  "level": "DEBUG",
9
- "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
9
+ "format": "%(asctime)s - %(levelname)s - %(message)s",
10
10
  "console": true,
11
11
  "file": null,
12
12
  "max_file_size": "10MB",
@@ -26,7 +26,7 @@ class TestGrobidClient:
26
26
  'timeout': 60,
27
27
  'logging': {
28
28
  'level': 'INFO',
29
- 'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)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'] == 1000
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)