port-ocean 0.9.2.dev2__py3-none-any.whl → 0.9.4__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/config/settings.py +1 -0
- port_ocean/core/defaults/initialize.py +1 -1
- port_ocean/core/handlers/entity_processor/jq_entity_processor.py +19 -42
- port_ocean/core/handlers/port_app_config/base.py +1 -0
- port_ocean/core/integrations/mixins/sync_raw.py +1 -2
- {port_ocean-0.9.2.dev2.dist-info → port_ocean-0.9.4.dist-info}/METADATA +1 -1
- {port_ocean-0.9.2.dev2.dist-info → port_ocean-0.9.4.dist-info}/RECORD +10 -10
- {port_ocean-0.9.2.dev2.dist-info → port_ocean-0.9.4.dist-info}/LICENSE.md +0 -0
- {port_ocean-0.9.2.dev2.dist-info → port_ocean-0.9.4.dist-info}/WHEEL +0 -0
- {port_ocean-0.9.2.dev2.dist-info → port_ocean-0.9.4.dist-info}/entry_points.txt +0 -0
port_ocean/config/settings.py
CHANGED
|
@@ -62,6 +62,7 @@ class IntegrationSettings(BaseOceanModel, extra=Extra.allow):
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
class IntegrationConfiguration(BaseOceanSettings, extra=Extra.allow):
|
|
65
|
+
allow_environment_variables_jq_access: bool = True
|
|
65
66
|
initialize_port_resources: bool = True
|
|
66
67
|
scheduled_resync_interval: int | None = None
|
|
67
68
|
client_timeout: int = 30
|
|
@@ -71,7 +71,7 @@ async def _initialize_required_integration_settings(
|
|
|
71
71
|
integration_config.event_listener.to_request(),
|
|
72
72
|
port_app_config=default_mapping,
|
|
73
73
|
)
|
|
74
|
-
elif not integration
|
|
74
|
+
elif not integration.get("config"):
|
|
75
75
|
logger.info(
|
|
76
76
|
"Encountered that the integration's mapping is empty, Initializing to default mapping"
|
|
77
77
|
)
|
|
@@ -4,7 +4,6 @@ from asyncio import Task
|
|
|
4
4
|
from dataclasses import dataclass, field
|
|
5
5
|
from functools import lru_cache
|
|
6
6
|
from typing import Any, Optional
|
|
7
|
-
from uuid import uuid4
|
|
8
7
|
|
|
9
8
|
import pyjq as jq # type: ignore
|
|
10
9
|
from loguru import logger
|
|
@@ -45,62 +44,31 @@ class JQEntityProcessor(BaseEntityProcessor):
|
|
|
45
44
|
|
|
46
45
|
@lru_cache
|
|
47
46
|
def _compile(self, pattern: str) -> Any:
|
|
47
|
+
if not ocean.config.allow_environment_variables_jq_access:
|
|
48
|
+
pattern = "def env: {}; {} as $ENV | " + pattern
|
|
48
49
|
return jq.compile(pattern)
|
|
49
50
|
|
|
50
51
|
async def _search(self, data: dict[str, Any], pattern: str) -> Any:
|
|
51
|
-
identifier = str(uuid4())
|
|
52
52
|
try:
|
|
53
53
|
loop = asyncio.get_event_loop()
|
|
54
|
-
logger.info(
|
|
55
|
-
f"__COMPILING__ jq execution with pattern: {pattern}. trace-id: {identifier}"
|
|
56
|
-
)
|
|
57
54
|
compiled_pattern = self._compile(pattern)
|
|
58
55
|
first_value_callable = functools.partial(compiled_pattern.first, data)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
logger.info(
|
|
64
|
-
f"__FINISHED__ jq execution with pattern: {pattern}. trace-id: {identifier} \n"
|
|
65
|
-
f"Result {result}"
|
|
66
|
-
)
|
|
67
|
-
return result
|
|
68
|
-
except Exception as e:
|
|
69
|
-
logger.error(
|
|
70
|
-
f"__FAILED__ jq execution with pattern: {pattern}. trace-id: {identifier} \n"
|
|
71
|
-
f"Error {e}"
|
|
56
|
+
return await loop.run_in_executor(None, first_value_callable)
|
|
57
|
+
except Exception as exc:
|
|
58
|
+
logger.debug(
|
|
59
|
+
f"Failed to search for pattern {pattern} in data {data}, {exc}"
|
|
72
60
|
)
|
|
73
61
|
return None
|
|
74
62
|
|
|
75
63
|
async def _search_as_bool(self, data: dict[str, Any], pattern: str) -> bool:
|
|
76
64
|
loop = asyncio.get_event_loop()
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
f"__COMPILING_BOOL__ jq execution with pattern: {pattern}. trace-id: {identifier}"
|
|
81
|
-
)
|
|
82
|
-
compiled_pattern = self._compile(pattern)
|
|
83
|
-
first_value_callable = functools.partial(compiled_pattern.first, data)
|
|
84
|
-
logger.info(
|
|
85
|
-
f"__STARTING_BOOL__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier}"
|
|
86
|
-
)
|
|
87
|
-
value = await loop.run_in_executor(None, first_value_callable)
|
|
88
|
-
logger.info(
|
|
89
|
-
f"__FINISHED_BOOL__ jq execution with pattern: {pattern}. trace-id: {identifier} \n"
|
|
90
|
-
f"Result {value}"
|
|
91
|
-
)
|
|
92
|
-
except Exception as e:
|
|
93
|
-
logger.error(
|
|
94
|
-
f"__FAILED_BOOL__ jq execution with pattern: {pattern}. trace-id: {identifier} \n"
|
|
95
|
-
f"Error {e}"
|
|
96
|
-
)
|
|
97
|
-
raise
|
|
65
|
+
compiled_pattern = self._compile(pattern)
|
|
66
|
+
first_value_callable = functools.partial(compiled_pattern.first, data)
|
|
67
|
+
value = await loop.run_in_executor(None, first_value_callable)
|
|
98
68
|
|
|
99
69
|
if isinstance(value, bool):
|
|
100
70
|
return value
|
|
101
|
-
|
|
102
|
-
f"__FAILED_BOOL__ jq execution with pattern: {pattern}. Invalid type got {type(value)} instead. trace-id: {identifier}"
|
|
103
|
-
)
|
|
71
|
+
|
|
104
72
|
raise EntityProcessorException(
|
|
105
73
|
f"Expected boolean value, got {type(value)} instead"
|
|
106
74
|
)
|
|
@@ -244,6 +212,15 @@ class JQEntityProcessor(BaseEntityProcessor):
|
|
|
244
212
|
examples_to_send.append(result.raw_data)
|
|
245
213
|
else:
|
|
246
214
|
failed_entities.append(parsed_entity)
|
|
215
|
+
if (
|
|
216
|
+
not calculated_entities_results
|
|
217
|
+
and raw_results
|
|
218
|
+
and send_raw_data_examples_amount > 0
|
|
219
|
+
):
|
|
220
|
+
logger.warning(
|
|
221
|
+
f"No entities were parsed from {len(raw_results)} raw results, sending raw data examples"
|
|
222
|
+
)
|
|
223
|
+
examples_to_send = raw_results[:send_raw_data_examples_amount]
|
|
247
224
|
|
|
248
225
|
await self._send_examples(examples_to_send, mapping.kind)
|
|
249
226
|
|
|
@@ -76,6 +76,7 @@ class BasePortAppConfig(BaseHandler):
|
|
|
76
76
|
logger.error(
|
|
77
77
|
"Invalid port app config found. Please check that the integration has been configured correctly."
|
|
78
78
|
)
|
|
79
|
+
logger.warning(f"Invalid port app config: {raw_config}")
|
|
79
80
|
raise
|
|
80
81
|
|
|
81
82
|
event.port_app_config = self._app_config_cache.port_app_config
|
|
@@ -90,7 +90,6 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
|
|
|
90
90
|
) -> tuple[RESYNC_RESULT, list[RAW_RESULT | Exception]]:
|
|
91
91
|
tasks = []
|
|
92
92
|
results = []
|
|
93
|
-
|
|
94
93
|
for task in fns:
|
|
95
94
|
if inspect.isasyncgenfunction(task):
|
|
96
95
|
results.append(resync_generator_wrapper(task, resource_config.kind))
|
|
@@ -415,7 +414,7 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
|
|
|
415
414
|
app_config = await self.port_app_config_handler.get_port_app_config(
|
|
416
415
|
use_cache=False
|
|
417
416
|
)
|
|
418
|
-
|
|
417
|
+
logger.info(f"Resync will use the following mappings: {app_config.dict()}")
|
|
419
418
|
try:
|
|
420
419
|
entities_at_port = await ocean.port_client.search_entities(
|
|
421
420
|
user_agent_type
|
|
@@ -48,7 +48,7 @@ port_ocean/clients/port/utils.py,sha256=O9mBu6zp4TfpS4SQ3qCPpn9ZVyYF8GKnji4UnYhM
|
|
|
48
48
|
port_ocean/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
port_ocean/config/base.py,sha256=J_FUvlo0D4FbEbr4mgJsbGB5JjW9I7zMwfekj6T30KY,6389
|
|
50
50
|
port_ocean/config/dynamic.py,sha256=qOFkRoJsn_BW7581omi_AoMxoHqasf_foxDQ_G11_SI,2030
|
|
51
|
-
port_ocean/config/settings.py,sha256=
|
|
51
|
+
port_ocean/config/settings.py,sha256=Hm2glSmLPtBR2EUtnyOnBmP5rPpbK5d67jfzuPe9gJg,3183
|
|
52
52
|
port_ocean/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
port_ocean/consumers/kafka_consumer.py,sha256=N8KocjBi9aR0BOPG8hgKovg-ns_ggpEjrSxqSqF_BSo,4710
|
|
54
54
|
port_ocean/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -59,7 +59,7 @@ port_ocean/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
59
59
|
port_ocean/core/defaults/__init__.py,sha256=8qCZg8n06WAdMu9s_FiRtDYLGPGHbOuS60vapeUoAks,142
|
|
60
60
|
port_ocean/core/defaults/clean.py,sha256=S3UAfca-oU89WJKIB4OgGjGjPr0vxBQ2aRZsLTZhQ04,2185
|
|
61
61
|
port_ocean/core/defaults/common.py,sha256=QnLFTkT3yIWIRtLQb7fUvvfe5AfInYJy0q5LjlzHkOw,3553
|
|
62
|
-
port_ocean/core/defaults/initialize.py,sha256=
|
|
62
|
+
port_ocean/core/defaults/initialize.py,sha256=DSY7kbSHQxs6-4ZAK3QYw-kVRsYq5txX7mUjkUB20Qw,8865
|
|
63
63
|
port_ocean/core/event_listener/__init__.py,sha256=mzJ33wRq0kh60fpVdOHVmvMTUQIvz3vxmifyBgwDn0E,889
|
|
64
64
|
port_ocean/core/event_listener/base.py,sha256=4RujgPz4VfDFlviu4qLGJFnJougSCL-Ewf0rfTQfwgc,1133
|
|
65
65
|
port_ocean/core/event_listener/factory.py,sha256=AYYfSHPAF7P5H-uQECXT0JVJjKDHrYkWJJBSL4mGkg8,3697
|
|
@@ -77,10 +77,10 @@ port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py,sha
|
|
|
77
77
|
port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py,sha256=82BvU8t5w9uhsxX8hbnwuRPuWhW3cMeuT_5sVIkip1I,1550
|
|
78
78
|
port_ocean/core/handlers/entity_processor/__init__.py,sha256=FvFCunFg44wNQoqlybem9MthOs7p1Wawac87uSXz9U8,156
|
|
79
79
|
port_ocean/core/handlers/entity_processor/base.py,sha256=udR0w5TstTOS5xOfTjAZIEdldn4xr6Oyb3DylatYX3Q,1869
|
|
80
|
-
port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=
|
|
80
|
+
port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=_nQtlY0ZcCDf_Mpq4qcG7vVQ8LJS6DfkFMv-NHyFiJI,8421
|
|
81
81
|
port_ocean/core/handlers/port_app_config/__init__.py,sha256=8AAT5OthiVM7KCcM34iEgEeXtn2pRMrT4Dze5r1Ixbk,134
|
|
82
82
|
port_ocean/core/handlers/port_app_config/api.py,sha256=6VbKPwFzsWG0IYsVD81hxSmfqtHUFqrfUuj1DBX5g4w,853
|
|
83
|
-
port_ocean/core/handlers/port_app_config/base.py,sha256
|
|
83
|
+
port_ocean/core/handlers/port_app_config/base.py,sha256=-n6b9oLjOA87YqxZv-r7paXxI8R86s44N_g56BEs56A,2970
|
|
84
84
|
port_ocean/core/handlers/port_app_config/models.py,sha256=4dw6HbgjMG3advpN3x6XF35xsgScnWm0KKTERG4CYZ8,2201
|
|
85
85
|
port_ocean/core/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
86
|
port_ocean/core/integrations/base.py,sha256=KHsRYFZ38ff3AkkqIQu45883ovgKOJn_fZfnTNy7HWY,2952
|
|
@@ -88,7 +88,7 @@ port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4
|
|
|
88
88
|
port_ocean/core/integrations/mixins/events.py,sha256=Ddfx2L4FpghV38waF8OfVeOV0bHBxNIgjU-q5ffillI,2341
|
|
89
89
|
port_ocean/core/integrations/mixins/handler.py,sha256=mZ7-0UlG3LcrwJttFbMe-R4xcOU2H_g33tZar7PwTv8,3771
|
|
90
90
|
port_ocean/core/integrations/mixins/sync.py,sha256=TKqRytxXONVhuCo3CB3rDvWNbITnZz33TYTDs3SWWVk,3880
|
|
91
|
-
port_ocean/core/integrations/mixins/sync_raw.py,sha256=
|
|
91
|
+
port_ocean/core/integrations/mixins/sync_raw.py,sha256=qgkxlh6_comyPNZ9p52ZhM9I7YQOwaEpn4kR0j20vbw,18103
|
|
92
92
|
port_ocean/core/integrations/mixins/utils.py,sha256=7y1rGETZIjOQadyIjFJXIHKkQFKx_SwiP-TrAIsyyLY,2303
|
|
93
93
|
port_ocean/core/models.py,sha256=4bDvMeydlSpG0YSXjE1Bo2AcZC0aQ2zqFhpsOvZat_A,1190
|
|
94
94
|
port_ocean/core/ocean_types.py,sha256=3_d8-n626f1kWLQ_Jxw194LEyrOVupz05qs_Y1pvB-A,990
|
|
@@ -122,8 +122,8 @@ port_ocean/utils/queue_utils.py,sha256=KWWl8YVnG-glcfIHhM6nefY-2sou_C6DVP1VynQwz
|
|
|
122
122
|
port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,3231
|
|
123
123
|
port_ocean/utils/signal.py,sha256=K-6kKFQTltcmKDhtyZAcn0IMa3sUpOHGOAUdWKgx0_E,1369
|
|
124
124
|
port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
|
|
125
|
-
port_ocean-0.9.
|
|
126
|
-
port_ocean-0.9.
|
|
127
|
-
port_ocean-0.9.
|
|
128
|
-
port_ocean-0.9.
|
|
129
|
-
port_ocean-0.9.
|
|
125
|
+
port_ocean-0.9.4.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
126
|
+
port_ocean-0.9.4.dist-info/METADATA,sha256=qHdvh3XX8EIrWRn6-Yu8_6hyEL6p0cNHzo0R37tPGkU,6561
|
|
127
|
+
port_ocean-0.9.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
128
|
+
port_ocean-0.9.4.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
|
|
129
|
+
port_ocean-0.9.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|