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

port_ocean/bootstrap.py CHANGED
@@ -16,7 +16,7 @@ def _get_base_integration_class_from_module(
16
16
  for name, obj in getmembers(module):
17
17
  if (
18
18
  isclass(obj)
19
- and type(obj) == type
19
+ and type(obj) is type
20
20
  and issubclass(obj, BaseIntegration)
21
21
  and obj != BaseIntegration
22
22
  ):
@@ -11,14 +11,14 @@ port_ocean = { version = "^{% version %}", extras = ["cli"] }
11
11
  [tool.poetry.group.dev.dependencies]
12
12
  # Uncomment this if you want to debug the ocean core together with your integration
13
13
  # port_ocean = { path = '../../', develop = true, extras = ['all'] }
14
- pytest = "^7.2"
15
- pytest-xdist = "^3.6.1"
16
- pre-commit = "^3.7.1"
17
- requests = "^2.32.3"
18
- black = "^23.3.0"
14
+ black = "^24.4.2"
19
15
  mypy = "^1.3.0"
20
- ruff = "^0.0.278"
21
- pylint = "^2.17.4"
16
+ pylint = ">=2.17.4,<4.0.0"
17
+ pytest = ">=8.2,<9.0"
18
+ pytest-asyncio = ">=0.24.0"
19
+ pytest-httpx = ">=0.30.0"
20
+ pytest-xdist = "^3.6.1"
21
+ ruff = "^0.6.3"
22
22
  towncrier = "^23.6.0"
23
23
 
24
24
  [tool.towncrier]
@@ -106,3 +106,8 @@ exclude = '''
106
106
  |\.venv
107
107
  )/
108
108
  '''
109
+
110
+ [tool.pytest.ini_options]
111
+ asyncio_mode = "auto"
112
+ asyncio_default_fixture_loop_scope = "function"
113
+ addopts = "-vv -n auto ./tests"
@@ -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)
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,
@@ -110,7 +110,7 @@ class IntegrationClientMixin:
110
110
  "logs": logs,
111
111
  },
112
112
  )
113
- handle_status_code(response)
113
+ handle_status_code(response, should_log=False)
114
114
  logger.debug("Logs successfully ingested")
115
115
 
116
116
  async def ingest_integration_kind_examples(
@@ -64,7 +64,7 @@ async def _initialize_required_integration_settings(
64
64
  )
65
65
  if not integration:
66
66
  logger.info(
67
- "Integration does not exist, Creating new integration with default default mapping"
67
+ "Integration does not exist, Creating new integration with default mapping"
68
68
  )
69
69
  integration = await port_client.create_integration(
70
70
  integration_config.integration.type,
port_ocean/core/utils.py CHANGED
@@ -39,7 +39,9 @@ async def validate_integration_runtime(
39
39
  requested_runtime: Runtime,
40
40
  ) -> None:
41
41
  logger.debug("Validating integration runtime")
42
- current_integration = await port_client.get_current_integration(should_raise=False)
42
+ current_integration = await port_client.get_current_integration(
43
+ should_raise=False, should_log=False
44
+ )
43
45
  current_runtime = current_integration.get("installationType", "OnPrem")
44
46
  if current_integration and current_runtime != requested_runtime.value:
45
47
  raise IntegrationRuntimeException(
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.2
3
+ Version: 0.10.6
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
@@ -1,5 +1,5 @@
1
1
  port_ocean/__init__.py,sha256=J3Mqp7d-CkEe9eMigGG8gSEiVKICY2bf7csNEwVOXk0,294
2
- port_ocean/bootstrap.py,sha256=ydGk40dYRXDL8KD0XcFChulcezAWRDSLHJz-evLfN8A,1321
2
+ port_ocean/bootstrap.py,sha256=CN1M5pVecZ7z_Vfu86Dk2HjFMiuiwt6E_SSOLFCYRMk,1321
3
3
  port_ocean/cli/__init__.py,sha256=ZjTGS305llhbjC2BH2KkVj34gCASBGwqc5HZEO_0T_Q,328
4
4
  port_ocean/cli/cli.py,sha256=RvWTELEn5YFw9aM0vaNqm5YqZZrL50ILaBs27ptiGl0,57
5
5
  port_ocean/cli/commands/__init__.py,sha256=Y9Q6jeYw_ZAZ-mdfE_5DZTdS2KHhieQZoUTggk_AkwM,369
@@ -33,7 +33,7 @@ port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/changelog/.gitigno
33
33
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/debug.py,sha256=_TRsA2s6GV2E3CTI8CHcsH-ZuH4_Eh5-juDXWaET0ho,65
34
34
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/main.py,sha256=XUwo9yroqSKxAdwVrTKGNGSWvec9n1Rh9Cqvep4HIuE,2257
35
35
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/poetry.toml,sha256=kENq8nNmFPIzw9vySheyG4xHxAPuBSpZO1CYGD6G2NE,46
36
- port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml,sha256=3DvCdbagz9RczLtBJlmec9zZ5jOepGZ_0SwUE_Xr2ZA,2206
36
+ port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml,sha256=6B_RiBsk20XZAb3nXnnUAf_FEiaTGlWedw7NZeVxTz0,2358
37
37
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/sonar-project.properties,sha256=timmRpoSd50BdxLf45OcFUk2qs855z610kzz3yLAqJw,124
38
38
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/test_sample.py,sha256=Ew5LA_G1k6DC5a2ygU2FoyjZQa0fRmPy73N0bio0d14,46
@@ -44,8 +44,8 @@ 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=j3YqLb1zMmJrIutYsYsZ_WCT4xh9VXEIH1A0kYMUUtk,8104
48
- port_ocean/clients/port/mixins/integrations.py,sha256=Ro6h9BwLxglQWniCVmfC---4oyGuUxk_Qejswl2t-J8,4841
47
+ port_ocean/clients/port/mixins/entities.py,sha256=oyd1mVlaoRnQLMpN9oOuYOC2PqLTMfJ51Z7cNyuVNNc,8647
48
+ port_ocean/clients/port/mixins/integrations.py,sha256=HnWXaJt41SUcha-bhvLdJW07j-l7xIo91GUzzwl2f_E,4859
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
51
51
  port_ocean/clients/port/types.py,sha256=nvlgiAq4WH5_F7wQbz_GAWl-faob84LVgIjZ2Ww5mTk,451
@@ -64,7 +64,7 @@ port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
65
65
  port_ocean/core/defaults/clean.py,sha256=S3UAfca-oU89WJKIB4OgGjGjPr0vxBQ2aRZsLTZhQ04,2185
66
66
  port_ocean/core/defaults/common.py,sha256=uVUg6VEn4RqtXQwLwMNGfkmT5zYRN_h5USfKw3poVyo,3561
67
- port_ocean/core/defaults/initialize.py,sha256=U1JWdpG_snAyqBXEikCjA7JzL7UtpOyx5rLfPhrBIZk,8721
67
+ port_ocean/core/defaults/initialize.py,sha256=5po9QtZNIXwxH8c0QoTKp8ag4aHt4rmOsO5CKH7fft0,8713
68
68
  port_ocean/core/event_listener/__init__.py,sha256=mzJ33wRq0kh60fpVdOHVmvMTUQIvz3vxmifyBgwDn0E,889
69
69
  port_ocean/core/event_listener/base.py,sha256=1Nmpg00OfT2AD2L8eFm4VQEcdG2TClpSWJMhWhAjkEE,2356
70
70
  port_ocean/core/event_listener/factory.py,sha256=AYYfSHPAF7P5H-uQECXT0JVJjKDHrYkWJJBSL4mGkg8,3697
@@ -99,7 +99,7 @@ port_ocean/core/integrations/mixins/sync_raw.py,sha256=2vyHhGWyPchVfSUKRRfSJ2XsX
99
99
  port_ocean/core/integrations/mixins/utils.py,sha256=7y1rGETZIjOQadyIjFJXIHKkQFKx_SwiP-TrAIsyyLY,2303
100
100
  port_ocean/core/models.py,sha256=8yYyF4DQ4jMmQJPsmh5-XoF9gfHUTuBit6zuT-bxZ7Y,1228
101
101
  port_ocean/core/ocean_types.py,sha256=3_d8-n626f1kWLQ_Jxw194LEyrOVupz05qs_Y1pvB-A,990
102
- port_ocean/core/utils.py,sha256=GjAm66FiGR48-hT3Mo66G8B4_jYTqSEGh80zs39qYQs,3599
102
+ port_ocean/core/utils.py,sha256=40UjRauRJO47WDSNn9bkCRD2bfhfB3e-dnOLULnuVzE,3631
103
103
  port_ocean/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
104
  port_ocean/exceptions/api.py,sha256=TLmTMqn4uHGaHgZK8PMIJ0TVJlPB4iP7xl9rx7GtCyY,426
105
105
  port_ocean/exceptions/base.py,sha256=uY4DX7fIITDFfemCJDWpaZi3bD51lcANc5swpoNvMJA,46
@@ -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.2.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
136
- port_ocean-0.10.2.dist-info/METADATA,sha256=L5Aa6v-KJXAUJ_z2X3GbpGaWBk0_8MO7YbPfzaWg4Io,6616
137
- port_ocean-0.10.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
138
- port_ocean-0.10.2.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
139
- port_ocean-0.10.2.dist-info/RECORD,,
136
+ port_ocean-0.10.6.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
137
+ port_ocean-0.10.6.dist-info/METADATA,sha256=bU-QFO_CsBFDwaEVaDqlBctyNMbrlIM7DGbjyhh-JVU,6616
138
+ port_ocean-0.10.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
139
+ port_ocean-0.10.6.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
140
+ port_ocean-0.10.6.dist-info/RECORD,,