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

@@ -2,6 +2,7 @@ import asyncio
2
2
  import functools
3
3
  from functools import lru_cache
4
4
  from typing import Any
5
+ from loguru import logger
5
6
 
6
7
  import pyjq as jq # type: ignore
7
8
 
@@ -67,25 +68,74 @@ class JQEntityProcessor(BaseEntityProcessor):
67
68
 
68
69
  return result
69
70
 
71
+ async def _get_entity_if_passed_selector(
72
+ self,
73
+ data: dict[str, Any],
74
+ raw_entity_mappings: dict[str, Any],
75
+ selector_query: str,
76
+ ) -> dict[str, Any]:
77
+ should_run = await self._search_as_bool(data, selector_query)
78
+ if should_run:
79
+ return await self._search_as_object(data, raw_entity_mappings)
80
+ return {}
81
+
82
+ async def _calculate_entity(
83
+ self,
84
+ data: dict[str, Any],
85
+ raw_entity_mappings: dict[str, Any],
86
+ items_to_parse: str | None,
87
+ selector_query: str,
88
+ ) -> list[dict[str, Any]]:
89
+ if items_to_parse:
90
+ items = await self._search(data, items_to_parse)
91
+ if isinstance(items, list):
92
+ return await asyncio.gather(
93
+ *[
94
+ self._get_entity_if_passed_selector(
95
+ {"item": item, **data},
96
+ raw_entity_mappings,
97
+ selector_query,
98
+ )
99
+ for item in items
100
+ ]
101
+ )
102
+ logger.warning(
103
+ f"Failed to parse items for JQ expression {items_to_parse}, Expected list but got {type(items)}."
104
+ f" Skipping..."
105
+ )
106
+ else:
107
+ return [
108
+ await self._get_entity_if_passed_selector(
109
+ data, raw_entity_mappings, selector_query
110
+ )
111
+ ]
112
+ return [{}]
113
+
70
114
  async def _calculate_entities(
71
115
  self, mapping: ResourceConfig, raw_data: list[dict[str, Any]]
72
116
  ) -> list[Entity]:
73
- async def calculate_raw(data: dict[str, Any]) -> dict[str, Any]:
74
- should_run = await self._search_as_bool(data, mapping.selector.query)
75
- if should_run and mapping.port.entity:
76
- return await self._search_as_object(
77
- data, mapping.port.entity.mappings.dict(exclude_unset=True)
117
+ raw_entity_mappings: dict[str, Any] = mapping.port.entity.mappings.dict(
118
+ exclude_unset=True
119
+ )
120
+ entities_tasks = [
121
+ asyncio.create_task(
122
+ self._calculate_entity(
123
+ data,
124
+ raw_entity_mappings,
125
+ mapping.port.items_to_parse,
126
+ mapping.selector.query,
78
127
  )
79
- return {}
80
-
81
- entities_tasks = [asyncio.create_task(calculate_raw(data)) for data in raw_data]
128
+ )
129
+ for data in raw_data
130
+ ]
82
131
  entities = await asyncio.gather(*entities_tasks)
83
132
 
84
133
  return [
85
134
  Entity.parse_obj(entity_data)
135
+ for flatten in entities
86
136
  for entity_data in filter(
87
137
  lambda entity: entity.get("identifier") and entity.get("blueprint"),
88
- entities,
138
+ flatten,
89
139
  )
90
140
  ]
91
141
 
@@ -19,6 +19,7 @@ class PortResourceConfig(BaseModel):
19
19
  mappings: EntityMapping
20
20
 
21
21
  entity: MappingsConfig
22
+ items_to_parse: str | None = Field(alias="itemsToParse")
22
23
 
23
24
 
24
25
  class Selector(BaseModel):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.5.6
3
+ Version: 0.5.7
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
@@ -42,8 +42,7 @@ Requires-Dist: werkzeug (>=2.3.4,<4.0.0)
42
42
  Project-URL: Repository, https://github.com/port-labs/Port-Ocean
43
43
  Description-Content-Type: text/markdown
44
44
 
45
- <img src="./assets/Thumbnail.jpg" alt="Ocean">
46
-
45
+ <img src="./assets/Thumbnail.png" alt="Ocean">
47
46
 
48
47
  # Ocean <img src="./assets/OceanSymbol.svg" alt="Ocean" width="100" height="100" align="right">
49
48
 
@@ -56,9 +55,8 @@ empowering engineers to effortlessly prioritize key features and streamline the
56
55
 
57
56
  - Python 3.11
58
57
 
59
-
60
-
61
58
  ## Installation
59
+
62
60
  In order to install the Ocean Framework, run the following command:
63
61
 
64
62
  ```bash
@@ -73,7 +71,7 @@ poetry add port-ocean[cli]
73
71
 
74
72
  ## Run Integration
75
73
 
76
- 1. source the integration venv
74
+ 1. source the integration venv
77
75
 
78
76
  ```bash
79
77
  . .venv/bin/activate
@@ -91,14 +89,15 @@ poetry add port-ocean[cli]
91
89
  ![image](./assets/ExportArchitecture.svg)
92
90
 
93
91
  ## Real-Time updates Architecture
92
+
94
93
  ![image](./assets/RealTimeUpdatesArchitecture.svg)
95
94
 
96
95
  ## Integration Lifecycle
97
96
 
98
97
  ![image](./assets/LifecycleOfIntegration.svg)
99
98
 
100
-
101
99
  ## Folder Structure
100
+
102
101
  The Ocean Integration Framework follows a specific folder structure within this mono repository. This structure ensures proper organization and easy identification of integration modules. The suggested folder structure is as follows:
103
102
 
104
103
  ```
@@ -122,9 +121,11 @@ port-ocean/
122
121
  - The `pyproject.toml` file inside each integration folder lists the required dependencies for that integration.
123
122
 
124
123
  ## Configuration
124
+
125
125
  The Integration Framework utilizes a `config.yaml` file for its configuration. This file defines both the framework configuration and the integration configuration within it. Each integration is identified by its type and unique identifier, which are utilized during initialization to appropriately update Port.
126
126
 
127
127
  Example `config.yaml`:
128
+
128
129
  ```yaml
129
130
  # This is an example configuration file for the integration service.
130
131
  # Please copy this file to config.yaml file in the integration folder and edit it to your needs.
@@ -153,6 +154,7 @@ The reason Ocean is open source is that we aim for the Port integration library
153
154
  In order to learn how you can contribute to Ocean, read our [contributing guide](./CONTRIBUTING.md)
154
155
 
155
156
  ### Local Development (Framework)
157
+
156
158
  1. Clone the repository
157
159
 
158
160
  2. Install dependencies:
@@ -174,6 +176,7 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
174
176
  ```
175
177
 
176
178
  ### Local Development (Integration)
179
+
177
180
  1. Clone the repository
178
181
 
179
182
  2. For new integration run
@@ -209,7 +212,10 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
209
212
  ```
210
213
 
211
214
  ## License
215
+
212
216
  The Ocean Framework is open-source software licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). See the [LICENSE](./LICENSE) file for more information.
213
217
 
214
218
  ## Contact
219
+
215
220
  For any questions or inquiries, please reach out to our team at support@getport.io
221
+
@@ -79,11 +79,11 @@ port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependenc
79
79
  port_ocean/core/handlers/entities_state_applier/port/validate_entity_relations.py,sha256=nKuQ-RlalGG07olxm6l5NHeOuQT9dEZLoMpD-AN5nq0,1392
80
80
  port_ocean/core/handlers/entity_processor/__init__.py,sha256=FvFCunFg44wNQoqlybem9MthOs7p1Wawac87uSXz9U8,156
81
81
  port_ocean/core/handlers/entity_processor/base.py,sha256=3ucPc-esMI5M6gFl_l2j_ncEqOIe7m1bCH4rAXtGDzg,1710
82
- port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=R1oejEASXT9LWtJZ-HNKmd-vpPdyWt2HAq_GJTymO2o,3875
82
+ port_ocean/core/handlers/entity_processor/jq_entity_processor.py,sha256=Xn_BfsddY_NR2Ssbiw6TT6xAm_7gKlZSFVlhlmb2TyA,5425
83
83
  port_ocean/core/handlers/port_app_config/__init__.py,sha256=8AAT5OthiVM7KCcM34iEgEeXtn2pRMrT4Dze5r1Ixbk,134
84
84
  port_ocean/core/handlers/port_app_config/api.py,sha256=6VbKPwFzsWG0IYsVD81hxSmfqtHUFqrfUuj1DBX5g4w,853
85
85
  port_ocean/core/handlers/port_app_config/base.py,sha256=nnMZ4jH6a-4Of9Cn-apMsU0CgNLD9avd5q0gRmc7nZ8,1495
86
- port_ocean/core/handlers/port_app_config/models.py,sha256=E-1J4ccfKD74S86hierzRAX0gRaq571nYcD2aBR8ir0,1924
86
+ port_ocean/core/handlers/port_app_config/models.py,sha256=WtF2uW4KPUPfDpy6E2tl9qXh5GUcDucVvKt0DCTYv6w,1985
87
87
  port_ocean/core/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
88
88
  port_ocean/core/integrations/base.py,sha256=3jU0skK_gMLB8a_fN8whsRKva-Dz058TFoI0vXTbryU,3193
89
89
  port_ocean/core/integrations/mixins/__init__.py,sha256=FA1FEKMM6P-L2_m7Q4L20mFa4_RgZnwSRmTCreKcBVM,220
@@ -122,8 +122,8 @@ port_ocean/utils/misc.py,sha256=2XmO8W0SgPjV0rd9HZvrHhoMlHprIwmMFsINxlAmgyw,1723
122
122
  port_ocean/utils/repeat.py,sha256=0EFWM9d8lLXAhZmAyczY20LAnijw6UbIECf5lpGbOas,3231
123
123
  port_ocean/utils/signal.py,sha256=Fab0049Cjs69TPTQgvEvilaVZKACQr6tGkRdySjNCi8,1515
124
124
  port_ocean/version.py,sha256=UsuJdvdQlazzKGD3Hd5-U7N69STh8Dq9ggJzQFnu9fU,177
125
- port_ocean-0.5.6.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
126
- port_ocean-0.5.6.dist-info/METADATA,sha256=mVyVE17g71s_j21aiLJjfVtpiWsh6_NKnNLLHtAemh4,6510
127
- port_ocean-0.5.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
128
- port_ocean-0.5.6.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
129
- port_ocean-0.5.6.dist-info/RECORD,,
125
+ port_ocean-0.5.7.dist-info/LICENSE.md,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
126
+ port_ocean-0.5.7.dist-info/METADATA,sha256=rsoY88yea-y1ZcgFKGtIglzy5UgJUOYNPwaSq-M5ZSQ,6515
127
+ port_ocean-0.5.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
128
+ port_ocean-0.5.7.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
129
+ port_ocean-0.5.7.dist-info/RECORD,,