port-ocean 0.12.2.dev4__py3-none-any.whl → 0.12.2.dev6__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.

Potentially problematic release.


This version of port-ocean might be problematic. Click here for more details.

@@ -3,6 +3,7 @@ import inspect
3
3
  import typing
4
4
  from typing import Callable, Awaitable, Any
5
5
 
6
+ import httpx
6
7
  from loguru import logger
7
8
 
8
9
  from port_ocean.clients.port.types import UserAgentType
@@ -139,9 +140,9 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
139
140
  objects_diff = await self._calculate_raw(
140
141
  [(resource, results)], parse_all, send_raw_data_examples_amount
141
142
  )
142
- # modified_objects = await self.entities_state_applier.upsert(
143
- # objects_diff[0].entity_selector_diff.passed, user_agent_type
144
- # )
143
+ await self.entities_state_applier.upsert(
144
+ objects_diff[0].entity_selector_diff.passed, user_agent_type
145
+ )
145
146
  return CalculationResult(
146
147
  objects_diff[0].entity_selector_diff._replace(passed=objects_diff[0].entity_selector_diff.passed),
147
148
  errors=objects_diff[0].errors,
@@ -425,20 +426,20 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
425
426
  use_cache=False
426
427
  )
427
428
  logger.info(f"Resync will use the following mappings: {app_config.dict()}")
428
- # try:
429
- # did_fetched_current_state = True
430
- # entities_at_port = await ocean.port_client.search_entities(
431
- # user_agent_type
432
- # )
433
- # except httpx.HTTPError as e:
434
- # logger.warning(
435
- # "Failed to fetch the current state of entities at Port. "
436
- # "Skipping delete phase due to unknown initial state. "
437
- # f"Error: {e}\n"
438
- # f"Response status code: {e.response.status_code if isinstance(e, httpx.HTTPStatusError) else None}\n"
439
- # f"Response content: {e.response.text if isinstance(e, httpx.HTTPStatusError) else None}\n"
440
- # )
441
- # did_fetched_current_state = False
429
+ try:
430
+ did_fetched_current_state = True
431
+ entities_at_port = await ocean.port_client.search_entities(
432
+ user_agent_type
433
+ )
434
+ except httpx.HTTPError as e:
435
+ logger.warning(
436
+ "Failed to fetch the current state of entities at Port. "
437
+ "Skipping delete phase due to unknown initial state. "
438
+ f"Error: {e}\n"
439
+ f"Response status code: {e.response.status_code if isinstance(e, httpx.HTTPStatusError) else None}\n"
440
+ f"Response content: {e.response.text if isinstance(e, httpx.HTTPStatusError) else None}\n"
441
+ )
442
+ did_fetched_current_state = False
442
443
 
443
444
  creation_results: list[tuple[list[Entity], list[Exception]]] = []
444
445
 
@@ -457,36 +458,36 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
457
458
  except asyncio.CancelledError as e:
458
459
  logger.warning("Resync aborted successfully, skipping delete phase. This leads to an incomplete state")
459
460
  raise
460
- # else:
461
- # if not did_fetched_current_state:
462
- # logger.warning(
463
- # "Due to an error before the resync, the previous state of entities at Port is unknown."
464
- # " Skipping delete phase due to unknown initial state."
465
- # )
466
- # return
467
- #
468
- # logger.info("Starting resync diff calculation")
469
- # flat_created_entities, errors = zip_and_sum(creation_results) or [
470
- # [],
471
- # [],
472
- # ]
473
- #
474
- # if errors:
475
- # message = f"Resync failed with {len(errors)}. Skipping delete phase due to incomplete state"
476
- # error_group = ExceptionGroup(
477
- # f"Resync failed with {len(errors)}. Skipping delete phase due to incomplete state",
478
- # errors,
479
- # )
480
- # if not silent:
481
- # raise error_group
482
- #
483
- # logger.error(message, exc_info=error_group)
484
- # else:
485
- # logger.info(
486
- # f"Running resync diff calculation, number of entities at Port before resync: {len(entities_at_port)}, number of entities created during sync: {len(flat_created_entities)}"
487
- # )
488
- # await self.entities_state_applier.delete_diff(
489
- # {"before": entities_at_port, "after": flat_created_entities},
490
- # user_agent_type,
491
- # )
492
- # logger.info("Resync finished successfully")
461
+ else:
462
+ if not did_fetched_current_state:
463
+ logger.warning(
464
+ "Due to an error before the resync, the previous state of entities at Port is unknown."
465
+ " Skipping delete phase due to unknown initial state."
466
+ )
467
+ return
468
+
469
+ logger.info("Starting resync diff calculation")
470
+ flat_created_entities, errors = zip_and_sum(creation_results) or [
471
+ [],
472
+ [],
473
+ ]
474
+
475
+ if errors:
476
+ message = f"Resync failed with {len(errors)}. Skipping delete phase due to incomplete state"
477
+ error_group = ExceptionGroup(
478
+ f"Resync failed with {len(errors)}. Skipping delete phase due to incomplete state",
479
+ errors,
480
+ )
481
+ if not silent:
482
+ raise error_group
483
+
484
+ logger.error(message, exc_info=error_group)
485
+ else:
486
+ logger.info(
487
+ f"Running resync diff calculation, number of entities at Port before resync: {len(entities_at_port)}, number of entities created during sync: {len(flat_created_entities)}"
488
+ )
489
+ await self.entities_state_applier.delete_diff(
490
+ {"before": entities_at_port, "after": flat_created_entities},
491
+ user_agent_type,
492
+ )
493
+ logger.info("Resync finished successfully")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.12.2.dev4
3
+ Version: 0.12.2.dev6
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -94,7 +94,7 @@ port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4
94
94
  port_ocean/core/integrations/mixins/events.py,sha256=Ddfx2L4FpghV38waF8OfVeOV0bHBxNIgjU-q5ffillI,2341
95
95
  port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcOU2H_g33tZar7PwTv8,3771
96
96
  port_ocean/core/integrations/mixins/sync.py,sha256=B9fEs8faaYLLikH9GBjE_E61vo0bQDjIGQsQ1SRXOlA,3931
97
- port_ocean/core/integrations/mixins/sync_raw.py,sha256=VVAReztpakDil4DSuXWdBnVSyKSBs-Dv7GCdm6toJp4,18988
97
+ port_ocean/core/integrations/mixins/sync_raw.py,sha256=hWaO1XbW7m2pUTGXlPJE30gOfbVhYhPXz0uNKEuDaNs,18849
98
98
  port_ocean/core/integrations/mixins/utils.py,sha256=7y1rGETZIjOQadyIjFJXIHKkQFKx_SwiP-TrAIsyyLY,2303
99
99
  port_ocean/core/models.py,sha256=dJ2_olTdbjUpObQJNmg7e7EENU_zZiX6XOaknNp54B0,1342
100
100
  port_ocean/core/ocean_types.py,sha256=3_d8-n626f1kWLQ_Jxw194LEyrOVupz05qs_Y1pvB-A,990
@@ -140,8 +140,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
140
140
  port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
141
141
  port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
142
142
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
143
- port_ocean-0.12.2.dev4.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
144
- port_ocean-0.12.2.dev4.dist-info/METADATA,sha256=3cMB6gYPioiLXq7OE1hKHR6EPqDPjZuP9w8aRVpXV34,6619
145
- port_ocean-0.12.2.dev4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
146
- port_ocean-0.12.2.dev4.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
147
- port_ocean-0.12.2.dev4.dist-info/RECORD,,
143
+ port_ocean-0.12.2.dev6.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
144
+ port_ocean-0.12.2.dev6.dist-info/METADATA,sha256=2jHYgbU6PsEbwOZIXbqyF9PfomB4mCoGmsBcdsr0XZU,6619
145
+ port_ocean-0.12.2.dev6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
146
+ port_ocean-0.12.2.dev6.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
147
+ port_ocean-0.12.2.dev6.dist-info/RECORD,,