port-ocean 0.10.1__py3-none-any.whl → 0.10.5__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.

@@ -58,11 +58,24 @@ class EntityClientMixin:
58
58
  )
59
59
  handle_status_code(response, should_raise)
60
60
  result = response.json()
61
- result_entity = Entity.parse_obj(result["entity"])
62
- # Set the results of the search relation and identifier to the entity
63
- entity.identifier = result_entity.identifier or entity.identifier
64
- entity.relations = result_entity.relations or entity.relations
65
- return entity
61
+ result_entity = (
62
+ Entity.parse_obj(result["entity"]) if result.get("entity") else entity
63
+ )
64
+ # In order to save memory we'll keep only the identifier, blueprint and relations of the
65
+ # upserted entity result for later calculations
66
+ reduced_entity = Entity(
67
+ identifier=result_entity.identifier, blueprint=result_entity.blueprint
68
+ )
69
+
70
+ # Turning dict typed relations (raw search relations) is required
71
+ # for us to be able to successfully calculate the participation related entities
72
+ # and ignore the ones that don't as they weren't upserted
73
+ reduced_entity.relations = {
74
+ key: None if isinstance(relation, dict) else relation
75
+ for key, relation in result_entity.relations.items()
76
+ }
77
+
78
+ return reduced_entity
66
79
 
67
80
  async def batch_upsert_entities(
68
81
  self,
port_ocean/ocean.py CHANGED
@@ -89,6 +89,7 @@ class Ocean:
89
89
  raise e
90
90
 
91
91
  interval = self.config.scheduled_resync_interval
92
+ loop = asyncio.get_event_loop()
92
93
  if interval is not None:
93
94
  logger.info(
94
95
  f"Setting up scheduled resync, the integration will automatically perform a full resync every {interval} minutes)"
@@ -99,7 +100,9 @@ class Ocean:
99
100
  wait_first=True,
100
101
  )(
101
102
  lambda: threading.Thread(
102
- target=lambda: asyncio.run(execute_resync_all())
103
+ target=lambda: asyncio.run_coroutine_threadsafe(
104
+ execute_resync_all(), loop
105
+ )
103
106
  ).start()
104
107
  )
105
108
  await repeated_function()
@@ -0,0 +1,75 @@
1
+ import sys
2
+ from inspect import getmembers
3
+ from typing import Dict, List, Set, Tuple, Union
4
+
5
+ from yaml import safe_load
6
+
7
+ from port_ocean.bootstrap import create_default_app
8
+ from port_ocean.core.handlers.port_app_config.models import ResourceConfig
9
+ from port_ocean.core.ocean_types import RESYNC_RESULT
10
+ from port_ocean.ocean import Ocean
11
+ from port_ocean.utils.misc import load_module
12
+
13
+
14
+ def get_integration_ocean_app(integration_path: str) -> Ocean:
15
+ default_app = create_default_app(
16
+ integration_path,
17
+ None,
18
+ {
19
+ "port": {
20
+ "client_id": "bla",
21
+ "client_secret": "bla",
22
+ },
23
+ },
24
+ )
25
+ main_path = f"{integration_path}/main.py"
26
+ sys.path.append(integration_path)
27
+ app_module = load_module(main_path)
28
+ app: Ocean = {name: item for name, item in getmembers(app_module)}.get(
29
+ "app", default_app
30
+ )
31
+
32
+ return app
33
+
34
+
35
+ def get_integation_resource_configs(integration_path: str) -> List[ResourceConfig]:
36
+ with open(
37
+ f"{integration_path}/.port/resources/port-app-config.yml"
38
+ ) as port_app_config_file:
39
+ resource_configs = safe_load(port_app_config_file)
40
+
41
+ return [ResourceConfig(**item) for item in resource_configs["resources"]]
42
+
43
+
44
+ def get_integation_resource_config_by_name(
45
+ integration_path: str, kind: str
46
+ ) -> Union[ResourceConfig, None]:
47
+ resource_configs = get_integation_resource_configs(integration_path)
48
+
49
+ relevant_configs = [x for x in resource_configs if x.kind == kind]
50
+
51
+ return relevant_configs[0] if len(relevant_configs) else None
52
+
53
+
54
+ async def get_raw_result_on_integration_sync_kinds(
55
+ integration_path: str, override_kinds: Union[Set[str], None] = None
56
+ ) -> Dict[str, List[Tuple[RESYNC_RESULT, List[Exception]]]]:
57
+ app = get_integration_ocean_app(integration_path)
58
+
59
+ resource_configs = get_integation_resource_configs(integration_path)
60
+
61
+ if override_kinds:
62
+ resource_configs = [x for x in resource_configs if x.kind in override_kinds]
63
+
64
+ results: Dict[str, List[Tuple[RESYNC_RESULT, List[Exception]]]] = {}
65
+
66
+ for resource_config in resource_configs:
67
+ resource_result = await app.integration._get_resource_raw_results(
68
+ resource_config
69
+ )
70
+
71
+ results[resource_config.kind] = results.get(resource_config.kind, []) + [
72
+ resource_result
73
+ ]
74
+
75
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.10.1
3
+ Version: 0.10.5
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
@@ -44,7 +44,7 @@ port_ocean/clients/port/authentication.py,sha256=t3z6h4vld-Tzkpth15sstaMJg0rccX-
44
44
  port_ocean/clients/port/client.py,sha256=Xd8Jk25Uh4WXY_WW-z1Qbv6F3ZTBFPoOolsxHMfozKw,3366
45
45
  port_ocean/clients/port/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  port_ocean/clients/port/mixins/blueprints.py,sha256=8ZVC5i8K1WKQMJJiPqZmgcOlF3OyxWz1aAQ_WA5UW3c,4500
47
- port_ocean/clients/port/mixins/entities.py,sha256=zAyw5FL0rahggdWw-jslTWqQ0ZQgqYitj3CMca8TJPw,8114
47
+ port_ocean/clients/port/mixins/entities.py,sha256=oyd1mVlaoRnQLMpN9oOuYOC2PqLTMfJ51Z7cNyuVNNc,8647
48
48
  port_ocean/clients/port/mixins/integrations.py,sha256=Ro6h9BwLxglQWniCVmfC---4oyGuUxk_Qejswl2t-J8,4841
49
49
  port_ocean/clients/port/mixins/migrations.py,sha256=A6896oJF6WbFL2WroyTkMzr12yhVyWqGoq9dtLNSKBY,1457
50
50
  port_ocean/clients/port/retry_transport.py,sha256=PtIZOAZ6V-ncpVysRUsPOgt8Sf01QLnTKB5YeKBxkJk,1861
@@ -116,11 +116,12 @@ port_ocean/log/handlers.py,sha256=k9G_Mb4ga2-Jke9irpdlYqj6EYiwv0gEsh4TgyqqOmI,28
116
116
  port_ocean/log/logger_setup.py,sha256=BaXt-mh9CVXhneh37H46d04lqOdIBixG1pFyGfotuZs,2328
117
117
  port_ocean/log/sensetive.py,sha256=wkyvkKMbyLTjZDSbvvLHL9bv4RvD0DPAyL3uWSttUOA,2916
118
118
  port_ocean/middlewares.py,sha256=6GrhldYAazxSwK2TbS-J28XdZ-9wO3PgCcyIMhnnJvI,2480
119
- port_ocean/ocean.py,sha256=0L8sj5TaIJSeYydO7jyANNinB1k0WwN-Q-ChWNnhJOs,4729
119
+ port_ocean/ocean.py,sha256=0dtaiRxKgY3kYNm1ZI3uFCJRhnNoTMwVv-PkWlLJQrQ,4842
120
120
  port_ocean/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
121
121
  port_ocean/run.py,sha256=rTxBlrQd4yyrtgErCFJCHCEHs7d1OXrRiJehUYmIbN0,2212
122
122
  port_ocean/sonar-project.properties,sha256=X_wLzDOkEVmpGLRMb2fg9Rb0DxWwUFSvESId8qpvrPI,73
123
123
  port_ocean/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
124
+ port_ocean/tests/helpers/__init__.py,sha256=XQBdAi54t9VavF11dGVLeS1jSoEKRjqRemKskLh-nSo,2377
124
125
  port_ocean/tests/test_sample.py,sha256=Ew5LA_G1k6DC5a2ygU2FoyjZQa0fRmPy73N0bio0d14,46
125
126
  port_ocean/utils/__init__.py,sha256=KMGnCPXZJbNwtgxtyMycapkDz8tpSyw23MSYT3iVeHs,91
126
127
  port_ocean/utils/async_http.py,sha256=arnH458TExn2Dju_Sy6pHas_vF5RMWnOp-jBz5WAAcE,1226
@@ -132,8 +133,8 @@ port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,32
132
133
  port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
133
134
  port_ocean/utils/time.py,sha256=pufAOH5ZQI7gXvOvJoQXZXZJV-Dqktoj9Qp9eiRwmJ4,1939
134
135
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
135
- port_ocean-0.10.1.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
136
- port_ocean-0.10.1.dist-info/METADATA,sha256=tNiC4yGVwLDcHumtUn6Xr87FHhYntjVdKvIEvyGLsi8,6616
137
- port_ocean-0.10.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
138
- port_ocean-0.10.1.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
139
- port_ocean-0.10.1.dist-info/RECORD,,
136
+ port_ocean-0.10.5.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
137
+ port_ocean-0.10.5.dist-info/METADATA,sha256=0ml7R1dYtI2YzfgwkkkhECc1P_-oV5FjYIBeiMXdF9Y,6616
138
+ port_ocean-0.10.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
139
+ port_ocean-0.10.5.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
140
+ port_ocean-0.10.5.dist-info/RECORD,,