folio-data-import 0.2.8rc6__tar.gz → 0.2.8rc7__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.

Potentially problematic release.


This version of folio-data-import might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: folio_data_import
3
- Version: 0.2.8rc6
3
+ Version: 0.2.8rc7
4
4
  Summary: A python module to interact with the data importing capabilities of the open-source FOLIO ILS
5
5
  License: MIT
6
6
  Author: Brooks Travis
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "folio_data_import"
3
- version = "0.2.8rc6"
3
+ version = "0.2.8rc7"
4
4
  description = "A python module to interact with the data importing capabilities of the open-source FOLIO ILS"
5
5
  authors = ["Brooks Travis <brooks.travis@gmail.com>"]
6
6
  license = "MIT"
@@ -21,6 +21,7 @@ import pymarc
21
21
  import tabulate
22
22
  from humps import decamelize
23
23
  from tqdm import tqdm
24
+ from zmq import has
24
25
 
25
26
 
26
27
  try:
@@ -459,34 +460,36 @@ class MARCImportJob:
459
460
  await self.get_job_status()
460
461
  sleep(1)
461
462
  if self.finished:
462
- job_summary = await self.get_job_summary()
463
- job_summary.pop("jobExecutionId")
464
- job_summary.pop("totalErrors")
465
- columns = ["Summary"] + list(job_summary.keys())
466
- rows = set()
467
- for key in columns[1:]:
468
- rows.update(job_summary[key].keys())
469
-
470
- table_data = []
471
- for row in rows:
472
- metric_name = decamelize(row).split("_")[1]
473
- table_row = [metric_name]
474
- for col in columns[1:]:
475
- table_row.append(job_summary[col].get(row, "N/A"))
476
- table_data.append(table_row)
477
- table_data.sort(key=lambda x: REPORT_SUMMARY_ORDERING.get(x[0], 99))
478
- columns = columns[:1] + [
479
- " ".join(decamelize(x).split("_")[:-1]) for x in columns[1:]
480
- ]
481
- print(
482
- f"Results for {'file' if len(self.current_file) == 1 else 'files'}: "
483
- f"{', '.join([os.path.basename(x.name) for x in self.current_file])}"
484
- )
485
- print(
486
- tabulate.tabulate(
487
- table_data, headers=columns, tablefmt="fancy_grid"
488
- ),
489
- )
463
+ if job_summary := await self.get_job_summary():
464
+ job_summary.pop("jobExecutionId")
465
+ job_summary.pop("totalErrors")
466
+ columns = ["Summary"] + list(job_summary.keys())
467
+ rows = set()
468
+ for key in columns[1:]:
469
+ rows.update(job_summary[key].keys())
470
+
471
+ table_data = []
472
+ for row in rows:
473
+ metric_name = decamelize(row).split("_")[1]
474
+ table_row = [metric_name]
475
+ for col in columns[1:]:
476
+ table_row.append(job_summary[col].get(row, "N/A"))
477
+ table_data.append(table_row)
478
+ table_data.sort(key=lambda x: REPORT_SUMMARY_ORDERING.get(x[0], 99))
479
+ columns = columns[:1] + [
480
+ " ".join(decamelize(x).split("_")[:-1]) for x in columns[1:]
481
+ ]
482
+ print(
483
+ f"Results for {'file' if len(self.current_file) == 1 else 'files'}: "
484
+ f"{', '.join([os.path.basename(x.name) for x in self.current_file])}"
485
+ )
486
+ print(
487
+ tabulate.tabulate(
488
+ table_data, headers=columns, tablefmt="fancy_grid"
489
+ ),
490
+ )
491
+ else:
492
+ print(f"No job summary available for job {self.job_id}.")
490
493
  self.last_current = 0
491
494
  self.finished = False
492
495
 
@@ -501,9 +504,14 @@ class MARCImportJob:
501
504
  self.current_retry_timeout = (
502
505
  self.current_retry_timeout * RETRY_TIMEOUT_RETRY_FACTOR
503
506
  ) if self.current_retry_timeout else RETRY_TIMEOUT_START
504
- job_summary = self.folio_client.folio_get(
505
- f"/metadata-provider/jobSummary/{self.job_id}"
506
- )
507
+ with httpx.Client(
508
+ timeout=self.current_retry_timeout,
509
+ verify=self.folio_client.ssl_verify
510
+ ) as temp_client:
511
+ self.folio_client.httpx_client = temp_client
512
+ job_summary = self.folio_client.folio_get(
513
+ f"/metadata-provider/jobSummary/{self.job_id}"
514
+ )
507
515
  self.current_retry_timeout = None
508
516
  except (httpx.ConnectTimeout, httpx.ReadTimeout, httpx.HTTPStatusError) as e:
509
517
  if not hasattr(e, "response") or e.response.status_code == 502:
@@ -514,6 +522,8 @@ class MARCImportJob:
514
522
  ) as temp_client:
515
523
  self.folio_client.httpx_client = temp_client
516
524
  return await self.get_job_status()
525
+ elif hasattr(e, "response") and e.response.status_code == 504:
526
+ job_summary = {}
517
527
  else:
518
528
  raise e
519
529
  return job_summary