omnata-plugin-runtime 0.2.34__py3-none-any.whl → 0.2.39__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/omnata_plugin.py +20 -3
- omnata_plugin_runtime/plugin_entrypoints.py +1 -0
- omnata_plugin_runtime/rate_limiting.py +3 -7
- {omnata_plugin_runtime-0.2.34.dist-info → omnata_plugin_runtime-0.2.39.dist-info}/METADATA +1 -1
- omnata_plugin_runtime-0.2.39.dist-info/RECORD +12 -0
- omnata_plugin_runtime-0.2.34.dist-info/RECORD +0 -12
- {omnata_plugin_runtime-0.2.34.dist-info → omnata_plugin_runtime-0.2.39.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.2.34.dist-info → omnata_plugin_runtime-0.2.39.dist-info}/WHEEL +0 -0
@@ -20,7 +20,7 @@ import jinja2
|
|
20
20
|
import pandas
|
21
21
|
import pydantic
|
22
22
|
import pydantic.json
|
23
|
-
from pydantic import parse_obj_as
|
23
|
+
from pydantic import parse_obj_as, root_validator
|
24
24
|
from dateutil.parser import parse
|
25
25
|
from jinja2 import Environment
|
26
26
|
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
@@ -297,7 +297,9 @@ class SyncRequest(ABC):
|
|
297
297
|
# rate limiting windows than this one, but it's fairly unlikely users would override defaults to that extent
|
298
298
|
if self.rate_limit_state_this_sync_and_branch is not None:
|
299
299
|
for endpoint_category in self.rate_limit_state_this_sync_and_branch:
|
300
|
-
self.
|
300
|
+
api_limits_for_category = [x for x in self.api_limits if x.endpoint_category == endpoint_category]
|
301
|
+
if len(api_limits_for_category) > 0:
|
302
|
+
self.rate_limit_state_this_sync_and_branch[endpoint_category].prune_history(api_limits_for_category[0].request_rates)
|
301
303
|
logger.info(f"Updating rate limit state for sync {self._run_id}")
|
302
304
|
update_rate_limit_result = self._plugin_message(
|
303
305
|
PluginMessageRateLimitState(rate_limit_state=self.rate_limit_state_this_sync_and_branch)
|
@@ -1142,12 +1144,25 @@ class SnowflakeBillingEvent(BaseModel):
|
|
1142
1144
|
|
1143
1145
|
billing_class: str
|
1144
1146
|
base_charge: Decimal
|
1145
|
-
timestamp: datetime.datetime = datetime.datetime.now()
|
1147
|
+
timestamp: datetime.datetime = datetime.datetime.now(tz=datetime.timezone.utc)
|
1146
1148
|
sub_class: Optional[str] = None
|
1147
1149
|
start_timestamp: Optional[datetime.datetime] = None
|
1148
1150
|
objects: List[str] = []
|
1149
1151
|
additional_info: Dict[str, Any] = {}
|
1150
1152
|
|
1153
|
+
@root_validator(pre=True)
|
1154
|
+
def validate_datetime_fields(cls, values):
|
1155
|
+
# Handling timestamps, we want to be strict on supplying a timezone
|
1156
|
+
timestamp = values.get('timestamp')
|
1157
|
+
if timestamp is not None and isinstance(timestamp, datetime.datetime):
|
1158
|
+
if timestamp.tzinfo is None or timestamp.tzinfo.utcoffset(timestamp) is None:
|
1159
|
+
raise ValueError("timestamp must be timezone aware")
|
1160
|
+
|
1161
|
+
start_timestamp = values.get('start_timestamp')
|
1162
|
+
if start_timestamp is not None and isinstance(start_timestamp, datetime.datetime):
|
1163
|
+
if start_timestamp.tzinfo is None or start_timestamp.tzinfo.utcoffset(start_timestamp) is None:
|
1164
|
+
raise ValueError("start_timestamp must be timezone aware")
|
1165
|
+
|
1151
1166
|
class BillingEventRequest(BaseModel):
|
1152
1167
|
"""
|
1153
1168
|
Represents a request to provide billing events for that day.
|
@@ -1174,6 +1189,8 @@ class OmnataPlugin(ABC):
|
|
1174
1189
|
# the current parameters are available here for the benefit of jinja filters,
|
1175
1190
|
# so that they don't get in the way of the other function arguments
|
1176
1191
|
self._configuration_parameters: Optional[SyncConfigurationParameters] = None
|
1192
|
+
# the Snowpark session shouldn't need to be used, ordinarily
|
1193
|
+
self._session: Optional[Session] = None
|
1177
1194
|
|
1178
1195
|
|
1179
1196
|
@abstractmethod
|
@@ -58,6 +58,7 @@ class PluginEntrypoint:
|
|
58
58
|
module = importlib.import_module(module_name)
|
59
59
|
class_obj = getattr(module, class_name)
|
60
60
|
self._plugin_instance: OmnataPlugin = class_obj()
|
61
|
+
self._plugin_instance._session = session # pylint: disable=protected-access
|
61
62
|
|
62
63
|
def sync(self, sync_request: Dict):
|
63
64
|
logger.info("Entered sync method")
|
@@ -134,13 +134,9 @@ class ApiLimits(SubscriptableBaseModel):
|
|
134
134
|
for request_rate in self.request_rates:
|
135
135
|
if rate_limit_state.previous_request_timestamps is not None and len(rate_limit_state.previous_request_timestamps) > 0:
|
136
136
|
request_index = request_rate.request_count - 1
|
137
|
-
if len(rate_limit_state.previous_request_timestamps)
|
138
|
-
request_index = (
|
139
|
-
|
140
|
-
)
|
141
|
-
timestamp_at_horizon = rate_limit_state.previous_request_timestamps[
|
142
|
-
request_index
|
143
|
-
]
|
137
|
+
if request_index > len(rate_limit_state.previous_request_timestamps) - 1:
|
138
|
+
request_index = len(rate_limit_state.previous_request_timestamps) - 1
|
139
|
+
timestamp_at_horizon = rate_limit_state.previous_request_timestamps[request_index]
|
144
140
|
next_allowed_request = timestamp_at_horizon + datetime.timedelta(
|
145
141
|
seconds=request_rate.number_of_seconds()
|
146
142
|
)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
omnata_plugin_runtime/__init__.py,sha256=w63LVME5nY-hQ4BBzfacy9kvTunwqHGs8iiSPGAX2ns,1214
|
2
|
+
omnata_plugin_runtime/api.py,sha256=vKq7goVPX5cPQ9CVN9l8RmpJDcqDwS5y9v1IWhWjBbk,6024
|
3
|
+
omnata_plugin_runtime/configuration.py,sha256=D5y3IxGpI3a5B7cGHWRgCy-V7PD-nvnk-r3tWr8lVB8,31506
|
4
|
+
omnata_plugin_runtime/forms.py,sha256=a76q0mZep-Q1XYw0c0uXA0_qbYLwQGAwHZMpZ8125Is,15235
|
5
|
+
omnata_plugin_runtime/logging.py,sha256=Q6eSqrr3SzwfVAg4r4sV1dlxeNS_PzOtZfieoWUEOZQ,3232
|
6
|
+
omnata_plugin_runtime/omnata_plugin.py,sha256=It1j9NmEHslcpmSzqJ49lPu2SW7Gl43G3bfYw1FrBhk,84156
|
7
|
+
omnata_plugin_runtime/plugin_entrypoints.py,sha256=_mU2iDEoRtLElO7c5c6WW9qvaOg6Lu7EV-wxkLFmPZA,22798
|
8
|
+
omnata_plugin_runtime/rate_limiting.py,sha256=QO8VB1H8al6a8-ydohUmL0c5JynXG2bulmuPRs2-2-Y,14910
|
9
|
+
omnata_plugin_runtime-0.2.39.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
+
omnata_plugin_runtime-0.2.39.dist-info/METADATA,sha256=2EaZZOfZr_ewnSsXH0cODK8Abp97EY1qITVSmcj8lng,1086
|
11
|
+
omnata_plugin_runtime-0.2.39.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
12
|
+
omnata_plugin_runtime-0.2.39.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
omnata_plugin_runtime/__init__.py,sha256=w63LVME5nY-hQ4BBzfacy9kvTunwqHGs8iiSPGAX2ns,1214
|
2
|
-
omnata_plugin_runtime/api.py,sha256=vKq7goVPX5cPQ9CVN9l8RmpJDcqDwS5y9v1IWhWjBbk,6024
|
3
|
-
omnata_plugin_runtime/configuration.py,sha256=D5y3IxGpI3a5B7cGHWRgCy-V7PD-nvnk-r3tWr8lVB8,31506
|
4
|
-
omnata_plugin_runtime/forms.py,sha256=a76q0mZep-Q1XYw0c0uXA0_qbYLwQGAwHZMpZ8125Is,15235
|
5
|
-
omnata_plugin_runtime/logging.py,sha256=Q6eSqrr3SzwfVAg4r4sV1dlxeNS_PzOtZfieoWUEOZQ,3232
|
6
|
-
omnata_plugin_runtime/omnata_plugin.py,sha256=ZRVDOwxwEcFsEuYfLYSbOFeN51PbTbsn0p01R1YD33w,83027
|
7
|
-
omnata_plugin_runtime/plugin_entrypoints.py,sha256=wmXOwJl9ACN2gjDV-hDN9WSHDSy6UK1gGXgsLMqqoKs,22713
|
8
|
-
omnata_plugin_runtime/rate_limiting.py,sha256=P5tjl50-mjUPZC8jaIfvkzq-0gezRKtmFffo1iQK_T4,14992
|
9
|
-
omnata_plugin_runtime-0.2.34.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
10
|
-
omnata_plugin_runtime-0.2.34.dist-info/METADATA,sha256=JKeaa3SFSXA8ZoaRx-TNxH0g3S8fXrdsZYDAWrHDnyE,1086
|
11
|
-
omnata_plugin_runtime-0.2.34.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
12
|
-
omnata_plugin_runtime-0.2.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|