folio-migration-tools 1.9.0rc4__py3-none-any.whl → 1.9.0rc5__py3-none-any.whl

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.
@@ -260,11 +260,15 @@ class BatchPoster(MigrationTaskBase):
260
260
  """
261
261
  Synchronous wrapper for set_version_async
262
262
  """
263
- loop = asyncio.get_event_loop()
264
- if loop.is_running():
263
+ try:
264
+ loop = asyncio.get_running_loop()
265
+ except RuntimeError:
266
+ loop = asyncio.new_event_loop()
267
+ asyncio.set_event_loop(loop)
265
268
  loop.run_until_complete(self.set_version_async(batch, query_api, object_type))
269
+ asyncio.set_event_loop(None) # Reset the event loop
266
270
  else:
267
- asyncio.run(self.set_version_async(batch, query_api, object_type))
271
+ loop.run_until_complete(self.set_version_async(batch, query_api, object_type))
268
272
 
269
273
  async def set_version_async(self, batch, query_api, object_type) -> None:
270
274
  """
@@ -298,7 +302,7 @@ class BatchPoster(MigrationTaskBase):
298
302
 
299
303
  for response in responses:
300
304
  if response.status_code == 200:
301
- response_json = await response.json()
305
+ response_json = response.json()
302
306
  for record in response_json[object_type]:
303
307
  updates[record["id"]] = {
304
308
  "_version": record["_version"],
@@ -325,8 +329,6 @@ class BatchPoster(MigrationTaskBase):
325
329
  logging.info(json.dumps(json_rec, indent=True))
326
330
  batch.append(json_rec)
327
331
  if len(batch) == int(self.batch_size):
328
- if self.query_params.get("upsert", False) and self.api_info.get("query_endpoint", ""):
329
- self.set_version(batch, self.api_info['query_endpoint'], self.api_info['object_name'])
330
332
  self.post_batch(batch, failed_recs_file, self.processed)
331
333
  batch = []
332
334
  return batch
@@ -451,6 +453,8 @@ class BatchPoster(MigrationTaskBase):
451
453
  logging.info("=======================", flush=True)
452
454
 
453
455
  def post_batch(self, batch, failed_recs_file, num_records, recursion_depth=0):
456
+ if self.query_params.get("upsert", False) and self.api_info.get("query_endpoint", ""):
457
+ self.set_version(batch, self.api_info['query_endpoint'], self.api_info['object_name'])
454
458
  response = self.do_post(batch)
455
459
  if response.status_code == 401:
456
460
  logging.error("Authorization failed (%s). Fetching new auth token...", response.text)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: folio_migration_tools
3
- Version: 1.9.0rc4
3
+ Version: 1.9.0rc5
4
4
  Summary: A tool allowing you to migrate data from legacy ILS:s (Library systems) into FOLIO LSP
5
5
  License: MIT
6
6
  Keywords: FOLIO,ILS,LSP,Library Systems,MARC21,Library data
@@ -37,7 +37,7 @@ folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py,sha256=
37
37
  folio_migration_tools/migration_report.py,sha256=BkRspM1hwTBnWeqsHamf7yVEofzLj560Q-9G--O00hw,4258
38
38
  folio_migration_tools/migration_tasks/__init__.py,sha256=ZkbY_yGyB84Ke8OMlYUzyyBj4cxxNrhMTwQlu_GbdDs,211
39
39
  folio_migration_tools/migration_tasks/authority_transformer.py,sha256=AoXg9s-GLO3yEEDCrQV7hc4YVXxwxsdxDdpj1zhHydE,4251
40
- folio_migration_tools/migration_tasks/batch_poster.py,sha256=xwrjx8Lh--B1tGUcIzzvDi6r_5g3up6rq-6-Z2DY6YQ,35285
40
+ folio_migration_tools/migration_tasks/batch_poster.py,sha256=8Oksp7uGjr6eAq-aqSpelQDTum14V9VzYGa_ZfLJQCM,35451
41
41
  folio_migration_tools/migration_tasks/bibs_transformer.py,sha256=XzlPo-0uuugJA4SM80xOlOj5nDK6OMDXFnAYg80hOBc,7791
42
42
  folio_migration_tools/migration_tasks/courses_migrator.py,sha256=CzXnsu-KGP7B4zcINJzLYUqz47D16NuFfzu_DPqRlTQ,7061
43
43
  folio_migration_tools/migration_tasks/holdings_csv_transformer.py,sha256=WT-RlDRm2ILr2-2shfG3TZ3nlSfqxEXT3TklZSqtJCM,22311
@@ -60,8 +60,8 @@ folio_migration_tools/transaction_migration/legacy_request.py,sha256=1ulyFzPQw_I
60
60
  folio_migration_tools/transaction_migration/legacy_reserve.py,sha256=d0qbh2fWpwlVSYRL6wZyZG20__NAYNxh7sPSsB-LAes,1804
61
61
  folio_migration_tools/transaction_migration/transaction_result.py,sha256=cTdCN0BnlI9_ZJB2Z3Fdkl9gpymIi-9mGZsRFlQcmDk,656
62
62
  folio_migration_tools/translations/en.json,sha256=HOVpkb_T-SN_x0NpDp8gyvV1hMLCui3SsG7ByyIv0OU,38669
63
- folio_migration_tools-1.9.0rc4.dist-info/LICENSE,sha256=PhIEkitVi3ejgq56tt6sWoJIG_zmv82cjjd_aYPPGdI,1072
64
- folio_migration_tools-1.9.0rc4.dist-info/METADATA,sha256=zh8mko180EbmuZjoSJ9ElvXWmQQVg0TW_NGgjRzS_Qc,7415
65
- folio_migration_tools-1.9.0rc4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
66
- folio_migration_tools-1.9.0rc4.dist-info/entry_points.txt,sha256=Hbe-HjqMcU8FwVshVIkeWyZd9XwgT1CCMNf06EpHQu8,77
67
- folio_migration_tools-1.9.0rc4.dist-info/RECORD,,
63
+ folio_migration_tools-1.9.0rc5.dist-info/LICENSE,sha256=PhIEkitVi3ejgq56tt6sWoJIG_zmv82cjjd_aYPPGdI,1072
64
+ folio_migration_tools-1.9.0rc5.dist-info/METADATA,sha256=6MxKZNM3wUsGNheI_nzS9YpJjR2XqDTigIedpeAcvzA,7415
65
+ folio_migration_tools-1.9.0rc5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
66
+ folio_migration_tools-1.9.0rc5.dist-info/entry_points.txt,sha256=Hbe-HjqMcU8FwVshVIkeWyZd9XwgT1CCMNf06EpHQu8,77
67
+ folio_migration_tools-1.9.0rc5.dist-info/RECORD,,