folio-data-import 0.2.8rc4__tar.gz → 0.2.8rc6__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.
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/PKG-INFO +1 -1
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/pyproject.toml +1 -1
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/MARCDataImport.py +35 -21
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/marc_preprocessors/_preprocessors.py +1 -1
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/LICENSE +0 -0
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/README.md +0 -0
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/UserImport.py +0 -0
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/__init__.py +0 -0
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/__main__.py +0 -0
- {folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/marc_preprocessors/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "folio_data_import"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.8rc6"
|
|
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"
|
{folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/MARCDataImport.py
RENAMED
|
@@ -277,7 +277,7 @@ class MARCImportJob:
|
|
|
277
277
|
total_records = 0
|
|
278
278
|
for import_file in files:
|
|
279
279
|
while True:
|
|
280
|
-
chunk = import_file.read(
|
|
280
|
+
chunk = import_file.read(104857600)
|
|
281
281
|
if not chunk:
|
|
282
282
|
break
|
|
283
283
|
total_records += chunk.count(b"\x1d")
|
|
@@ -291,24 +291,33 @@ class MARCImportJob:
|
|
|
291
291
|
Args:
|
|
292
292
|
batch_payload (dict): A records payload containing the current batch of MARC records.
|
|
293
293
|
"""
|
|
294
|
-
|
|
295
|
-
self.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
294
|
+
try:
|
|
295
|
+
post_batch = self.http_client.post(
|
|
296
|
+
self.folio_client.okapi_url
|
|
297
|
+
+ f"/change-manager/jobExecutions/{self.job_id}/records",
|
|
298
|
+
headers=self.folio_client.okapi_headers,
|
|
299
|
+
json=batch_payload,
|
|
300
|
+
)
|
|
301
|
+
except httpx.ReadTimeout:
|
|
302
|
+
sleep(.25)
|
|
303
|
+
return await self.process_record_batch(batch_payload)
|
|
300
304
|
try:
|
|
301
305
|
post_batch.raise_for_status()
|
|
302
306
|
self.total_records_sent += len(self.record_batch)
|
|
303
307
|
self.record_batch = []
|
|
304
308
|
self.pbar_sent.update(len(batch_payload["initialRecords"]))
|
|
305
309
|
except Exception as e:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
self.
|
|
309
|
-
self.
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
if hasattr(e, "response") and e.response.status_code in [500, 422]: # TODO: #26 Check for specific error code once https://folio-org.atlassian.net/browse/MODSOURMAN-1281 is resolved
|
|
311
|
+
self.total_records_sent += len(self.record_batch)
|
|
312
|
+
self.record_batch = []
|
|
313
|
+
self.pbar_sent.update(len(batch_payload["initialRecords"]))
|
|
314
|
+
else:
|
|
315
|
+
print("Error posting batch: " + str(e))
|
|
316
|
+
for record in self.record_batch:
|
|
317
|
+
self.failed_batches_file.write(record)
|
|
318
|
+
self.error_records += len(self.record_batch)
|
|
319
|
+
self.pbar_sent.total = self.pbar_sent.total - len(self.record_batch)
|
|
320
|
+
self.record_batch = []
|
|
312
321
|
sleep(self.batch_delay)
|
|
313
322
|
|
|
314
323
|
async def process_records(self, files, total_records) -> None:
|
|
@@ -496,14 +505,17 @@ class MARCImportJob:
|
|
|
496
505
|
f"/metadata-provider/jobSummary/{self.job_id}"
|
|
497
506
|
)
|
|
498
507
|
self.current_retry_timeout = None
|
|
499
|
-
except (httpx.ConnectTimeout, httpx.ReadTimeout):
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
508
|
+
except (httpx.ConnectTimeout, httpx.ReadTimeout, httpx.HTTPStatusError) as e:
|
|
509
|
+
if not hasattr(e, "response") or e.response.status_code == 502:
|
|
510
|
+
sleep(.25)
|
|
511
|
+
with httpx.Client(
|
|
512
|
+
timeout=self.current_retry_timeout,
|
|
513
|
+
verify=self.folio_client.ssl_verify
|
|
514
|
+
) as temp_client:
|
|
515
|
+
self.folio_client.httpx_client = temp_client
|
|
516
|
+
return await self.get_job_status()
|
|
517
|
+
else:
|
|
518
|
+
raise e
|
|
507
519
|
return job_summary
|
|
508
520
|
|
|
509
521
|
|
|
@@ -586,6 +598,8 @@ async def main() -> None:
|
|
|
586
598
|
else:
|
|
587
599
|
marc_files = list(Path("./").glob(args.marc_file_path))
|
|
588
600
|
|
|
601
|
+
marc_files.sort()
|
|
602
|
+
|
|
589
603
|
if len(marc_files) == 0:
|
|
590
604
|
print(f"No files found matching {args.marc_file_path}. Exiting.")
|
|
591
605
|
sys.exit(1)
|
|
File without changes
|
|
File without changes
|
{folio_data_import-0.2.8rc4 → folio_data_import-0.2.8rc6}/src/folio_data_import/UserImport.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|