omnata-plugin-runtime 0.3.28a84__py3-none-any.whl → 0.4.0__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/api.py +2 -1
- omnata_plugin_runtime/omnata_plugin.py +11 -1
- omnata_plugin_runtime/rate_limiting.py +1 -5
- {omnata_plugin_runtime-0.3.28a84.dist-info → omnata_plugin_runtime-0.4.0.dist-info}/METADATA +1 -1
- omnata_plugin_runtime-0.4.0.dist-info/RECORD +12 -0
- omnata_plugin_runtime-0.3.28a84.dist-info/RECORD +0 -12
- {omnata_plugin_runtime-0.3.28a84.dist-info → omnata_plugin_runtime-0.4.0.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.3.28a84.dist-info → omnata_plugin_runtime-0.4.0.dist-info}/WHEEL +0 -0
omnata_plugin_runtime/api.py
CHANGED
@@ -66,8 +66,9 @@ class PluginMessageStreamProgressUpdate(BaseModel):
|
|
66
66
|
message_type: Literal["stream_record_counts"] = "stream_record_counts"
|
67
67
|
stream_total_counts: Dict[str, int]
|
68
68
|
completed_streams: List[str]
|
69
|
-
# older runtime versions didn't have
|
69
|
+
# older runtime versions didn't have these, so the sync engine can't expect it
|
70
70
|
stream_errors: Optional[Dict[str,str]]
|
71
|
+
total_records_estimate: Optional[Dict[str,int]]
|
71
72
|
|
72
73
|
|
73
74
|
class PluginMessageCancelledStreams(BaseModel):
|
@@ -906,6 +906,7 @@ class InboundSyncRequest(SyncRequest):
|
|
906
906
|
self._stream_record_counts: Dict[str, int] = {
|
907
907
|
stream_name: 0 for stream_name in self._streams_dict.keys()
|
908
908
|
}
|
909
|
+
self._total_records_estimate: Optional[Dict[str,int]] = {}
|
909
910
|
self._stream_change_counts: Dict[str, int] = {
|
910
911
|
stream_name: 0 for stream_name in self._streams_dict.keys()
|
911
912
|
}
|
@@ -933,6 +934,7 @@ class InboundSyncRequest(SyncRequest):
|
|
933
934
|
] = self._stream_record_counts[stream_name] + total_length
|
934
935
|
results.extend(non_empty_dfs) # remove any None/empty dataframes
|
935
936
|
stream_names.append(stream_name)
|
937
|
+
self._session.sql("begin").collect()
|
936
938
|
if len(results) > 0:
|
937
939
|
logger.info(
|
938
940
|
f"Applying {len(results)} batches of queued results"
|
@@ -943,6 +945,7 @@ class InboundSyncRequest(SyncRequest):
|
|
943
945
|
self._apply_results_dataframe(stream_names, all_dfs)
|
944
946
|
# update the stream state object too
|
945
947
|
self._apply_latest_states()
|
948
|
+
self._session.sql("commit").collect()
|
946
949
|
for stream_name in stream_names:
|
947
950
|
self._apply_results[stream_name] = None
|
948
951
|
self._apply_results = {}
|
@@ -975,7 +978,8 @@ class InboundSyncRequest(SyncRequest):
|
|
975
978
|
new_progress_update = PluginMessageStreamProgressUpdate(
|
976
979
|
stream_total_counts=self._stream_record_counts,
|
977
980
|
completed_streams=self._completed_streams,
|
978
|
-
stream_errors=self._omnata_log_handler.stream_global_errors
|
981
|
+
stream_errors=self._omnata_log_handler.stream_global_errors,
|
982
|
+
total_records_estimate=self._total_records_estimate
|
979
983
|
)
|
980
984
|
if self._last_stream_progress_update is None or new_progress_update != self._last_stream_progress_update:
|
981
985
|
self._plugin_message(
|
@@ -1109,6 +1113,12 @@ class InboundSyncRequest(SyncRequest):
|
|
1109
1113
|
self._completed_streams.append(stream_name)
|
1110
1114
|
# dedup just in case it's called twice
|
1111
1115
|
self._completed_streams = list(set(self._completed_streams))
|
1116
|
+
|
1117
|
+
def set_stream_record_count(self, stream_name: str, count: int):
|
1118
|
+
"""
|
1119
|
+
Sets the record count for a stream, used to provide progress updates.
|
1120
|
+
"""
|
1121
|
+
self._stream_record_counts[stream_name] = count
|
1112
1122
|
|
1113
1123
|
def _enqueue_state(self, stream_name: str, new_state: Any):
|
1114
1124
|
"""
|
@@ -132,19 +132,15 @@ class ApiLimits(SubscriptableBaseModel):
|
|
132
132
|
):
|
133
133
|
longest_wait = rate_limit_state.wait_until
|
134
134
|
for request_rate in self.request_rates:
|
135
|
-
print(request_rate)
|
136
135
|
if rate_limit_state.previous_request_timestamps is not None and len(rate_limit_state.previous_request_timestamps) > 0:
|
137
136
|
previous_request_timestamps = rate_limit_state.get_relevant_history(request_rate)
|
138
|
-
print(f"previous_request_timestamps: {len(previous_request_timestamps)}")
|
139
137
|
request_index = request_rate.request_count - 1
|
140
138
|
if request_index > len(previous_request_timestamps) - 1:
|
141
139
|
continue # we have not yet made enough requests to hit this rate limit
|
142
140
|
request_index = len(previous_request_timestamps) - 1
|
143
141
|
timestamp_at_horizon = previous_request_timestamps[request_index]
|
144
|
-
print("timestamp_at_horizon: " + str(timestamp_at_horizon))
|
145
142
|
now = datetime.datetime.now().astimezone(datetime.timezone.utc)
|
146
143
|
seconds_since_horizon = (timestamp_at_horizon - now).total_seconds()
|
147
|
-
print("seconds_since_horizon: " + str(seconds_since_horizon))
|
148
144
|
next_allowed_request = timestamp_at_horizon + datetime.timedelta(
|
149
145
|
seconds=request_rate.number_of_seconds()
|
150
146
|
)
|
@@ -374,7 +370,7 @@ class RateLimitedSession(requests.Session):
|
|
374
370
|
total=max_retries,
|
375
371
|
backoff_factor=backoff_factor,
|
376
372
|
status_forcelist=statuses_to_include,
|
377
|
-
|
373
|
+
allowed_methods=["HEAD", "GET", "OPTIONS", "POST", "PUT", "DELETE"]
|
378
374
|
)
|
379
375
|
adapter = HTTPAdapter(max_retries=retry_strategy)
|
380
376
|
self.mount("https://", adapter)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
omnata_plugin_runtime/__init__.py,sha256=MS9d1whnfT_B3-ThqZ7l63QeC_8OEKTuaYV5wTwRpBA,1576
|
2
|
+
omnata_plugin_runtime/api.py,sha256=W79CsAcl127Dzy-XVS9CzvzsbS3IigVH4QAhFFDkaXg,6270
|
3
|
+
omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
|
4
|
+
omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
|
5
|
+
omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
|
6
|
+
omnata_plugin_runtime/omnata_plugin.py,sha256=y03j6ivm-lHGKQjIhlzSY1DSmb3-OhmFwwU9jusoFVo,105723
|
7
|
+
omnata_plugin_runtime/plugin_entrypoints.py,sha256=D2f0Qih7KTJNXIDYkA-E55RTEK_7Jtv9ySqspWxERVA,28272
|
8
|
+
omnata_plugin_runtime/rate_limiting.py,sha256=29Hjsr0i1rE8jERVdIFGINfQfp_kI3PDft-IM_ZxvCA,21509
|
9
|
+
omnata_plugin_runtime-0.4.0.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
+
omnata_plugin_runtime-0.4.0.dist-info/METADATA,sha256=fwWghGIXYu3pCJ_urCUoly08C40AkXHrmEGfbY36oEc,1600
|
11
|
+
omnata_plugin_runtime-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
12
|
+
omnata_plugin_runtime-0.4.0.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
omnata_plugin_runtime/__init__.py,sha256=MS9d1whnfT_B3-ThqZ7l63QeC_8OEKTuaYV5wTwRpBA,1576
|
2
|
-
omnata_plugin_runtime/api.py,sha256=_N5ok5LN7GDO4J9n3yduXp3tpjmhpySY__U2baiygrs,6217
|
3
|
-
omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
|
4
|
-
omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
|
5
|
-
omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
|
6
|
-
omnata_plugin_runtime/omnata_plugin.py,sha256=aXC-Ui9qeYKJM7VCZtZLQsVod9yH8ecEQ6e-IuJuVnY,105248
|
7
|
-
omnata_plugin_runtime/plugin_entrypoints.py,sha256=D2f0Qih7KTJNXIDYkA-E55RTEK_7Jtv9ySqspWxERVA,28272
|
8
|
-
omnata_plugin_runtime/rate_limiting.py,sha256=n83ANCla6DLwM_oHKmTKHG-JFM99i5-KjsgnkB9pYGo,21786
|
9
|
-
omnata_plugin_runtime-0.3.28a84.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
-
omnata_plugin_runtime-0.3.28a84.dist-info/METADATA,sha256=GQsx3J1EHelIRI53WezceZ8x5BOGwAhFPEeqOUUODnU,1604
|
11
|
-
omnata_plugin_runtime-0.3.28a84.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
12
|
-
omnata_plugin_runtime-0.3.28a84.dist-info/RECORD,,
|
File without changes
|
File without changes
|