omnata-plugin-runtime 0.1.95__py3-none-any.whl → 0.1.97__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.
- omnata_plugin_runtime/forms.py +2 -19
- omnata_plugin_runtime/omnata_plugin.py +18 -3
- omnata_plugin_runtime/plugin_entrypoints.py +3 -68
- {omnata_plugin_runtime-0.1.95.dist-info → omnata_plugin_runtime-0.1.97.dist-info}/METADATA +1 -1
- omnata_plugin_runtime-0.1.97.dist-info/RECORD +12 -0
- omnata_plugin_runtime-0.1.95.dist-info/RECORD +0 -12
- {omnata_plugin_runtime-0.1.95.dist-info → omnata_plugin_runtime-0.1.97.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.1.95.dist-info → omnata_plugin_runtime-0.1.97.dist-info}/WHEEL +0 -0
omnata_plugin_runtime/forms.py
CHANGED
@@ -176,22 +176,6 @@ class FormSliderField(SubscriptableBaseModel):
|
|
176
176
|
step_size: int = 1
|
177
177
|
|
178
178
|
|
179
|
-
class StreamLister(SubscriptableBaseModel):
|
180
|
-
"""
|
181
|
-
A class for managing the listing of Streams. Can depend on other form fields to delay rendering
|
182
|
-
"""
|
183
|
-
|
184
|
-
source_function: Union[
|
185
|
-
Callable[[InboundSyncConfigurationParameters], List[StreamConfiguration]], str
|
186
|
-
]
|
187
|
-
label: str = "Select Objects"
|
188
|
-
depends_on: Optional[str] = None
|
189
|
-
|
190
|
-
@validator("source_function", always=True)
|
191
|
-
def function_name_convertor(cls, v) -> str:
|
192
|
-
return v.__name__ if isinstance(v, MethodType) else v
|
193
|
-
|
194
|
-
|
195
179
|
class FormJinjaTemplate(SubscriptableBaseModel):
|
196
180
|
"""
|
197
181
|
Uses text area to allow the user to create a template, which can include column values from the source
|
@@ -392,12 +376,11 @@ class OutboundSyncConfigurationForm(ConfigurationFormBase):
|
|
392
376
|
|
393
377
|
class InboundSyncConfigurationForm(ConfigurationFormBase):
|
394
378
|
"""
|
395
|
-
Defines a form for configuring an inbound sync.
|
396
|
-
|
379
|
+
Defines a form for configuring an inbound sync, prior to stream selection.
|
380
|
+
The form values provided via these fields are passed into the inbound_list_streams function.
|
397
381
|
"""
|
398
382
|
|
399
383
|
fields: List[FormFieldBase] = Field(default_factory=list)
|
400
|
-
stream_lister: StreamLister
|
401
384
|
|
402
385
|
class SecurityIntegrationTemplate(BaseModel):
|
403
386
|
"""
|
@@ -1158,6 +1158,21 @@ class OmnataPlugin(ABC):
|
|
1158
1158
|
raise NotImplementedError(
|
1159
1159
|
"Your plugin class must implement the inbound_configuration_form method"
|
1160
1160
|
)
|
1161
|
+
|
1162
|
+
def inbound_stream_list(
|
1163
|
+
self, parameters: InboundSyncConfigurationParameters
|
1164
|
+
) -> List[StreamConfiguration]:
|
1165
|
+
"""
|
1166
|
+
Returns a list of streams which can be sync'd from the app. This function is called after the form returned by inbound_configuration_form
|
1167
|
+
has been completed, so that collected information can be used to build the list.
|
1168
|
+
|
1169
|
+
:param InboundSyncConfigurationParameters parameters the parameters of the sync
|
1170
|
+
:return A list of streams which can be sync'd from the app. This may vary based on the parameters provided.
|
1171
|
+
:rtype List[StreamConfiguration]
|
1172
|
+
"""
|
1173
|
+
raise NotImplementedError(
|
1174
|
+
"Your plugin class must implement the inbound_stream_list method"
|
1175
|
+
)
|
1161
1176
|
|
1162
1177
|
@abstractmethod
|
1163
1178
|
def connect(self, parameters: ConnectionConfigurationParameters) -> ConnectResponse:
|
@@ -1562,13 +1577,13 @@ def managed_inbound_processing(concurrency: int):
|
|
1562
1577
|
logger.info(f"method_kwargs: {method_kwargs}")
|
1563
1578
|
if self._sync_request is None:
|
1564
1579
|
raise ValueError(
|
1565
|
-
"To use the managed_inbound_processing decorator, you must attach an apply request to the plugin instance (via the
|
1580
|
+
"To use the managed_inbound_processing decorator, you must attach an apply request to the plugin instance (via the _sync_request property)"
|
1566
1581
|
)
|
1567
1582
|
# if self._sync_request.api_limits is None:
|
1568
1583
|
# raise ValueError('To use the managed_inbound_processing decorator, API constraints must be defined. These can be provided in the response to the connect method')
|
1569
1584
|
if len(method_args) == 0:
|
1570
1585
|
raise ValueError(
|
1571
|
-
"You must provide at least one method argument, and the first argument must be a
|
1586
|
+
"You must provide at least one method argument, and the first argument must be a list of StoredStreamConfigurations (from inbound_sync_request.streams)"
|
1572
1587
|
)
|
1573
1588
|
first_arg: List[StoredStreamConfiguration] = method_args[0]
|
1574
1589
|
logger.info(first_arg.__class__.__name__)
|
@@ -1586,7 +1601,7 @@ def managed_inbound_processing(concurrency: int):
|
|
1586
1601
|
streams_queue.put(stream)
|
1587
1602
|
|
1588
1603
|
tasks = []
|
1589
|
-
logger.info(f"Creating {concurrency} worker(s) for
|
1604
|
+
logger.info(f"Creating {concurrency} worker(s) for retrieving records")
|
1590
1605
|
|
1591
1606
|
for i in range(concurrency):
|
1592
1607
|
# the dataframe/generator was put on the queue, so we remove it from the method args
|
@@ -150,66 +150,7 @@ class PluginEntrypoint:
|
|
150
150
|
sync_parameters=request.sync_parameters,
|
151
151
|
current_form_parameters={},
|
152
152
|
)
|
153
|
-
|
154
|
-
# build streams object from parameters
|
155
|
-
streams_list: List[StoredStreamConfiguration] = []
|
156
|
-
streams_list = streams_list + list(
|
157
|
-
request.streams_configuration.included_streams.values()
|
158
|
-
)
|
159
|
-
|
160
|
-
# if new streams are included, we need to fetch the list first to find them
|
161
|
-
if request.streams_configuration.include_new_streams:
|
162
|
-
# we have to invoke the inbound_configuration_form to get the StreamLister, as the list
|
163
|
-
# of streams may vary based on the sync parameters
|
164
|
-
form = self._plugin_instance.inbound_configuration_form(parameters)
|
165
|
-
if form.stream_lister is None:
|
166
|
-
logger.info(
|
167
|
-
"No stream lister defined, skipping new stream detection"
|
168
|
-
)
|
169
|
-
else:
|
170
|
-
all_streams: List[StreamConfiguration] = getattr(
|
171
|
-
self._plugin_instance, form.stream_lister.source_function
|
172
|
-
)(parameters)
|
173
|
-
for s in all_streams:
|
174
|
-
if (
|
175
|
-
s.stream_name
|
176
|
-
not in request.streams_configuration.included_streams
|
177
|
-
and s.stream_name
|
178
|
-
not in request.streams_configuration.excluded_streams
|
179
|
-
):
|
180
|
-
if (
|
181
|
-
request.streams_configuration.new_stream_sync_strategy
|
182
|
-
not in s.supported_sync_strategies
|
183
|
-
):
|
184
|
-
raise ValueError(
|
185
|
-
f"New object {s.stream_name} was found, but does not support the defined sync strategy {request.streams_configuration}"
|
186
|
-
)
|
187
|
-
|
188
|
-
new_stream = StoredStreamConfiguration(
|
189
|
-
stream_name=s.stream_name,
|
190
|
-
cursor_field=s.source_defined_cursor,
|
191
|
-
primary_key_field=s.source_defined_primary_key,
|
192
|
-
latest_state={},
|
193
|
-
storage_behaviour=request.streams_configuration.new_stream_storage_behaviour,
|
194
|
-
stream=s,
|
195
|
-
sync_strategy=request.streams_configuration.new_stream_sync_strategy,
|
196
|
-
)
|
197
|
-
streams_list.append(new_stream)
|
198
|
-
|
199
|
-
for stream in streams_list:
|
200
|
-
if stream.stream_name in request.latest_stream_state:
|
201
|
-
stream.latest_state = request.latest_stream_state[
|
202
|
-
stream.stream_name
|
203
|
-
]
|
204
|
-
logger.info(
|
205
|
-
f"Updating stream state for {stream.stream_name}: {stream.latest_state}"
|
206
|
-
)
|
207
|
-
else:
|
208
|
-
logger.info(
|
209
|
-
f"Existing stream state for {stream.stream_name} not found"
|
210
|
-
)
|
211
|
-
logger.info(f"streams list: {streams_list}")
|
212
|
-
logger.info(f"streams config: {request.streams_configuration}")
|
153
|
+
|
213
154
|
inbound_sync_request = InboundSyncRequest(
|
214
155
|
run_id=request.run_id,
|
215
156
|
session=self._session,
|
@@ -221,7 +162,7 @@ class PluginEntrypoint:
|
|
221
162
|
rate_limit_state=request.rate_limits_state,
|
222
163
|
run_deadline=datetime.datetime.now() + datetime.timedelta(hours=4),
|
223
164
|
development_mode=False,
|
224
|
-
streams=
|
165
|
+
streams=request.streams_configuration.included_streams,
|
225
166
|
)
|
226
167
|
|
227
168
|
inbound_sync_request.update_activity("Invoking plugin")
|
@@ -237,7 +178,6 @@ class PluginEntrypoint:
|
|
237
178
|
inbound_sync_request._thread_cancellation_token.set() # pylint: disable=protected-access
|
238
179
|
inbound_sync_request._apply_results_task.join() # pylint: disable=protected-access
|
239
180
|
inbound_sync_request._cancel_checking_task.join() # pylint: disable=protected-access
|
240
|
-
return_dict["streams"] = [s.dict() for s in streams_list]
|
241
181
|
return_dict["errored_streams"] = list(
|
242
182
|
omnata_log_handler.stream_has_errors.keys()
|
243
183
|
)
|
@@ -312,7 +252,6 @@ class PluginEntrypoint:
|
|
312
252
|
connection_parameters: Dict,
|
313
253
|
oauth_secret_name: Optional[str],
|
314
254
|
other_secrets_name: Optional[str],
|
315
|
-
function_name: str,
|
316
255
|
sync_parameters: Dict,
|
317
256
|
selected_streams: Optional[List[str]], # None to return all streams without requiring schema
|
318
257
|
):
|
@@ -335,11 +274,7 @@ class PluginEntrypoint:
|
|
335
274
|
currently_selected_streams=selected_streams
|
336
275
|
)
|
337
276
|
|
338
|
-
|
339
|
-
self._plugin_instance,
|
340
|
-
function_name,
|
341
|
-
)
|
342
|
-
script_result = the_function(parameters)
|
277
|
+
script_result = self._plugin_instance.inbound_stream_list(parameters)
|
343
278
|
if isinstance(script_result, BaseModel):
|
344
279
|
script_result = script_result.dict()
|
345
280
|
elif isinstance(script_result, List):
|
@@ -0,0 +1,12 @@
|
|
1
|
+
omnata_plugin_runtime/__init__.py,sha256=w63LVME5nY-hQ4BBzfacy9kvTunwqHGs8iiSPGAX2ns,1214
|
2
|
+
omnata_plugin_runtime/api.py,sha256=vCDTCxPZ5rIhi8aSM6Z0TXWHtGpbCoNvCnM3mKa-47Q,5591
|
3
|
+
omnata_plugin_runtime/configuration.py,sha256=kYvHt_CYn_GZDwkjRVJMqGNbmcO0uEFgHz3B8Fi1JAc,30309
|
4
|
+
omnata_plugin_runtime/forms.py,sha256=a76q0mZep-Q1XYw0c0uXA0_qbYLwQGAwHZMpZ8125Is,15235
|
5
|
+
omnata_plugin_runtime/logging.py,sha256=ne1sLh5cBkjdRS54B30PGc5frABgjy0sF1_2RMcJ_Tk,3012
|
6
|
+
omnata_plugin_runtime/omnata_plugin.py,sha256=62ChwLXpvXN6Q9mIlCGnTuAtjEGUnkbGLdgiamLPd7s,75032
|
7
|
+
omnata_plugin_runtime/plugin_entrypoints.py,sha256=ZARuAavN8s9oqVGyTnx5eYudaoCFuwwtcPm0UgTKUQw,20821
|
8
|
+
omnata_plugin_runtime/rate_limiting.py,sha256=OnFnCdMenpMpAZYumpe6mypRnMmDl1Q02vzlgmQgiw0,10733
|
9
|
+
omnata_plugin_runtime-0.1.97.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
+
omnata_plugin_runtime-0.1.97.dist-info/METADATA,sha256=XaD-UnfuV03ktHekYHHQr7URn75BcSaw_sVONMHh0lM,1086
|
11
|
+
omnata_plugin_runtime-0.1.97.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
12
|
+
omnata_plugin_runtime-0.1.97.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
omnata_plugin_runtime/__init__.py,sha256=w63LVME5nY-hQ4BBzfacy9kvTunwqHGs8iiSPGAX2ns,1214
|
2
|
-
omnata_plugin_runtime/api.py,sha256=vCDTCxPZ5rIhi8aSM6Z0TXWHtGpbCoNvCnM3mKa-47Q,5591
|
3
|
-
omnata_plugin_runtime/configuration.py,sha256=kYvHt_CYn_GZDwkjRVJMqGNbmcO0uEFgHz3B8Fi1JAc,30309
|
4
|
-
omnata_plugin_runtime/forms.py,sha256=BVo7aQ5HUac-KoJ7gmsZFgGzByxPYslQ1iWw5CtAzZY,15770
|
5
|
-
omnata_plugin_runtime/logging.py,sha256=ne1sLh5cBkjdRS54B30PGc5frABgjy0sF1_2RMcJ_Tk,3012
|
6
|
-
omnata_plugin_runtime/omnata_plugin.py,sha256=x4Vvd1a8FNNiQNiURFuhp8s7FIuJgX03xR5d_iNTxK0,74287
|
7
|
-
omnata_plugin_runtime/plugin_entrypoints.py,sha256=XS28q3IEQkvmNrMGMs90R_I48g5DmByIfsrSi1aeIzs,24170
|
8
|
-
omnata_plugin_runtime/rate_limiting.py,sha256=OnFnCdMenpMpAZYumpe6mypRnMmDl1Q02vzlgmQgiw0,10733
|
9
|
-
omnata_plugin_runtime-0.1.95.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
-
omnata_plugin_runtime-0.1.95.dist-info/METADATA,sha256=WgtNnDGExrpJ1NRZ-O20M8AmlC8DTaPCe74V4pEGb6I,1086
|
11
|
-
omnata_plugin_runtime-0.1.95.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
12
|
-
omnata_plugin_runtime-0.1.95.dist-info/RECORD,,
|
File without changes
|
File without changes
|