cognite-extractor-utils 7.2.0__py3-none-any.whl → 7.2.2__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 cognite-extractor-utils might be problematic. Click here for more details.
- cognite/extractorutils/__init__.py +1 -1
- cognite/extractorutils/configtools/elements.py +2 -0
- cognite/extractorutils/configtools/loaders.py +48 -10
- cognite/extractorutils/uploader/time_series.py +2 -2
- {cognite_extractor_utils-7.2.0.dist-info → cognite_extractor_utils-7.2.2.dist-info}/METADATA +2 -2
- {cognite_extractor_utils-7.2.0.dist-info → cognite_extractor_utils-7.2.2.dist-info}/RECORD +8 -8
- {cognite_extractor_utils-7.2.0.dist-info → cognite_extractor_utils-7.2.2.dist-info}/LICENSE +0 -0
- {cognite_extractor_utils-7.2.0.dist-info → cognite_extractor_utils-7.2.2.dist-info}/WHEEL +0 -0
|
@@ -327,6 +327,8 @@ class CogniteConfig:
|
|
|
327
327
|
elif self.idp_authentication.tenant:
|
|
328
328
|
base_url = urljoin(self.idp_authentication.authority, self.idp_authentication.tenant)
|
|
329
329
|
kwargs["token_url"] = f"{base_url}/oauth2/v2.0/token"
|
|
330
|
+
else:
|
|
331
|
+
raise InvalidConfigError("Either token-url or tenant is required for client credentials authentication")
|
|
330
332
|
kwargs["client_id"] = self.idp_authentication.client_id
|
|
331
333
|
kwargs["client_secret"] = self.idp_authentication.secret
|
|
332
334
|
kwargs["scopes"] = self.idp_authentication.scopes
|
|
@@ -139,11 +139,10 @@ def _env_constructor(_: yaml.SafeLoader, node: yaml.Node) -> bool:
|
|
|
139
139
|
return bool_values.get(expanded_value.lower(), expanded_value)
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
def
|
|
142
|
+
def _load_yaml_dict_raw(
|
|
143
143
|
source: Union[TextIO, str],
|
|
144
|
-
case_style: str = "hyphen",
|
|
145
144
|
expand_envvars: bool = True,
|
|
146
|
-
|
|
145
|
+
keyvault_loader: Optional[KeyVaultLoader] = None,
|
|
147
146
|
) -> Dict[str, Any]:
|
|
148
147
|
loader = _EnvLoader if expand_envvars else yaml.SafeLoader
|
|
149
148
|
|
|
@@ -159,11 +158,14 @@ def _load_yaml_dict(
|
|
|
159
158
|
if not isinstance(source, str):
|
|
160
159
|
source.seek(0)
|
|
161
160
|
|
|
162
|
-
|
|
161
|
+
if keyvault_loader:
|
|
162
|
+
_EnvLoader.add_constructor("!keyvault", keyvault_loader)
|
|
163
|
+
else:
|
|
164
|
+
keyvault_config = initial_load.get("azure-keyvault", initial_load.get("key-vault"))
|
|
165
|
+
_EnvLoader.add_constructor("!keyvault", KeyVaultLoader(keyvault_config))
|
|
163
166
|
|
|
164
167
|
_EnvLoader.add_implicit_resolver("!env", re.compile(r"\$\{([^}^{]+)\}"), None)
|
|
165
168
|
_EnvLoader.add_constructor("!env", _env_constructor)
|
|
166
|
-
_EnvLoader.add_constructor("!keyvault", KeyVaultLoader(keyvault_config))
|
|
167
169
|
|
|
168
170
|
try:
|
|
169
171
|
config_dict = yaml.load(source, Loader=loader) # noqa: S506
|
|
@@ -173,12 +175,26 @@ def _load_yaml_dict(
|
|
|
173
175
|
cause = e.problem or e.context
|
|
174
176
|
raise InvalidConfigError(f"Invalid YAML{formatted_location}: {cause or ''}") from e
|
|
175
177
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
return config_dict
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _load_yaml_dict(
|
|
182
|
+
source: Union[TextIO, str],
|
|
183
|
+
case_style: str = "hyphen",
|
|
184
|
+
expand_envvars: bool = True,
|
|
185
|
+
dict_manipulator: Callable[[Dict[str, Any]], Dict[str, Any]] = lambda x: x,
|
|
186
|
+
keyvault_loader: Optional[KeyVaultLoader] = None,
|
|
187
|
+
) -> Dict[str, Any]:
|
|
188
|
+
config_dict = _load_yaml_dict_raw(source, expand_envvars, keyvault_loader)
|
|
178
189
|
|
|
179
190
|
config_dict = dict_manipulator(config_dict)
|
|
180
191
|
config_dict = _to_snake_case(config_dict, case_style)
|
|
181
192
|
|
|
193
|
+
if "azure_keyvault" in config_dict:
|
|
194
|
+
config_dict.pop("azure_keyvault")
|
|
195
|
+
if "key_vault" in config_dict:
|
|
196
|
+
config_dict.pop("key_vault")
|
|
197
|
+
|
|
182
198
|
return config_dict
|
|
183
199
|
|
|
184
200
|
|
|
@@ -188,9 +204,14 @@ def _load_yaml(
|
|
|
188
204
|
case_style: str = "hyphen",
|
|
189
205
|
expand_envvars: bool = True,
|
|
190
206
|
dict_manipulator: Callable[[Dict[str, Any]], Dict[str, Any]] = lambda x: x,
|
|
207
|
+
keyvault_loader: Optional[KeyVaultLoader] = None,
|
|
191
208
|
) -> CustomConfigClass:
|
|
192
209
|
config_dict = _load_yaml_dict(
|
|
193
|
-
source,
|
|
210
|
+
source,
|
|
211
|
+
case_style=case_style,
|
|
212
|
+
expand_envvars=expand_envvars,
|
|
213
|
+
dict_manipulator=dict_manipulator,
|
|
214
|
+
keyvault_loader=keyvault_loader,
|
|
194
215
|
)
|
|
195
216
|
|
|
196
217
|
try:
|
|
@@ -239,6 +260,7 @@ def load_yaml(
|
|
|
239
260
|
config_type: Type[CustomConfigClass],
|
|
240
261
|
case_style: str = "hyphen",
|
|
241
262
|
expand_envvars: bool = True,
|
|
263
|
+
keyvault_loader: Optional[KeyVaultLoader] = None,
|
|
242
264
|
) -> CustomConfigClass:
|
|
243
265
|
"""
|
|
244
266
|
Read a YAML file, and create a config object based on its contents.
|
|
@@ -249,6 +271,7 @@ def load_yaml(
|
|
|
249
271
|
case_style: Casing convention of config file. Valid options are 'snake', 'hyphen' or 'camel'. Should be
|
|
250
272
|
'hyphen'.
|
|
251
273
|
expand_envvars: Substitute values with the pattern ${VAR} with the content of the environment variable VAR
|
|
274
|
+
keyvault_loader: Pre-built loader for keyvault tags. Will be loaded from config if not set.
|
|
252
275
|
|
|
253
276
|
Returns:
|
|
254
277
|
An initialized config object.
|
|
@@ -256,13 +279,20 @@ def load_yaml(
|
|
|
256
279
|
Raises:
|
|
257
280
|
InvalidConfigError: If any config field is given as an invalid type, is missing or is unknown
|
|
258
281
|
"""
|
|
259
|
-
return _load_yaml(
|
|
282
|
+
return _load_yaml(
|
|
283
|
+
source=source,
|
|
284
|
+
config_type=config_type,
|
|
285
|
+
case_style=case_style,
|
|
286
|
+
expand_envvars=expand_envvars,
|
|
287
|
+
keyvault_loader=keyvault_loader,
|
|
288
|
+
)
|
|
260
289
|
|
|
261
290
|
|
|
262
291
|
def load_yaml_dict(
|
|
263
292
|
source: Union[TextIO, str],
|
|
264
293
|
case_style: str = "hyphen",
|
|
265
294
|
expand_envvars: bool = True,
|
|
295
|
+
keyvault_loader: Optional[KeyVaultLoader] = None,
|
|
266
296
|
) -> Dict[str, Any]:
|
|
267
297
|
"""
|
|
268
298
|
Read a YAML file and return a dictionary from its contents
|
|
@@ -272,6 +302,7 @@ def load_yaml_dict(
|
|
|
272
302
|
case_style: Casing convention of config file. Valid options are 'snake', 'hyphen' or 'camel'. Should be
|
|
273
303
|
'hyphen'.
|
|
274
304
|
expand_envvars: Substitute values with the pattern ${VAR} with the content of the environment variable VAR
|
|
305
|
+
keyvault_loader: Pre-built loader for keyvault tags. Will be loaded from config if not set.
|
|
275
306
|
|
|
276
307
|
Returns:
|
|
277
308
|
A raw dict with the contents of the config file.
|
|
@@ -279,7 +310,9 @@ def load_yaml_dict(
|
|
|
279
310
|
Raises:
|
|
280
311
|
InvalidConfigError: If any config field is given as an invalid type, is missing or is unknown
|
|
281
312
|
"""
|
|
282
|
-
return _load_yaml_dict(
|
|
313
|
+
return _load_yaml_dict(
|
|
314
|
+
source=source, case_style=case_style, expand_envvars=expand_envvars, keyvault_loader=keyvault_loader
|
|
315
|
+
)
|
|
283
316
|
|
|
284
317
|
|
|
285
318
|
class ConfigResolver(Generic[CustomConfigClass]):
|
|
@@ -374,6 +407,10 @@ class ConfigResolver(Generic[CustomConfigClass]):
|
|
|
374
407
|
and tmp_config.cognite.idp_authentication == self._config.cognite.idp_authentication
|
|
375
408
|
)
|
|
376
409
|
|
|
410
|
+
def _get_keyvault_loader(self) -> KeyVaultLoader:
|
|
411
|
+
temp_config = _load_yaml_dict_raw(self._config_text)
|
|
412
|
+
return KeyVaultLoader(temp_config.get("azure-keyvault", temp_config.get("key-vault")))
|
|
413
|
+
|
|
377
414
|
def _resolve_config(self) -> None:
|
|
378
415
|
self._reload_file()
|
|
379
416
|
|
|
@@ -400,6 +437,7 @@ class ConfigResolver(Generic[CustomConfigClass]):
|
|
|
400
437
|
source=response.config,
|
|
401
438
|
config_type=self.config_type,
|
|
402
439
|
dict_manipulator=lambda d: self._inject_cognite(tmp_config, d),
|
|
440
|
+
keyvault_loader=self._get_keyvault_loader(),
|
|
403
441
|
)
|
|
404
442
|
|
|
405
443
|
else:
|
|
@@ -264,9 +264,9 @@ class TimeSeriesUploadQueue(AbstractUploadQueue):
|
|
|
264
264
|
missing = [id_dict for id_dict in ex.not_found if id_dict.get("externalId") not in retry_these]
|
|
265
265
|
missing_num = len(ex.not_found) - len(create_these_ids)
|
|
266
266
|
self.logger.error(
|
|
267
|
-
f"{missing_num} time series not found, and could not be created automatically
|
|
267
|
+
f"{missing_num} time series not found, and could not be created automatically: "
|
|
268
268
|
+ str(missing)
|
|
269
|
-
+ "
|
|
269
|
+
+ " Data will be dropped"
|
|
270
270
|
)
|
|
271
271
|
|
|
272
272
|
# Remove entries with non-existing time series from upload queue
|
{cognite_extractor_utils-7.2.0.dist-info → cognite_extractor_utils-7.2.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cognite-extractor-utils
|
|
3
|
-
Version: 7.2.
|
|
3
|
+
Version: 7.2.2
|
|
4
4
|
Summary: Utilities for easier development of extractors for CDF
|
|
5
5
|
Home-page: https://github.com/cognitedata/python-extractor-utils
|
|
6
6
|
License: Apache-2.0
|
|
@@ -24,7 +24,7 @@ Requires-Dist: decorator (>=5.1.1,<6.0.0)
|
|
|
24
24
|
Requires-Dist: more-itertools (>=10.0.0,<11.0.0)
|
|
25
25
|
Requires-Dist: orjson (>=3.10.3,<4.0.0)
|
|
26
26
|
Requires-Dist: prometheus-client (>0.7.0,<=1.0.0)
|
|
27
|
-
Requires-Dist: psutil (>=
|
|
27
|
+
Requires-Dist: psutil (>=6.0.0,<7.0.0)
|
|
28
28
|
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
29
29
|
Requires-Dist: pyyaml (>=5.3.0,<7)
|
|
30
30
|
Requires-Dist: typing-extensions (>=3.7.4,<5)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
cognite/extractorutils/__init__.py,sha256=
|
|
1
|
+
cognite/extractorutils/__init__.py,sha256=G-4E2RTr6EDXP2zRRAR3D2oyZLbluCvTFmL3cvy4IoE,739
|
|
2
2
|
cognite/extractorutils/_inner_util.py,sha256=gmz6aqS7jDNsg8z4RHgJjMFohDLOMiaU4gMWBhg3xcE,1558
|
|
3
3
|
cognite/extractorutils/base.py,sha256=q6NU2bPec3WOasVnnIFoh-aUJudVZWZ2R6emz3IRj8Q,16391
|
|
4
4
|
cognite/extractorutils/configtools/__init__.py,sha256=L-daaqInIsmHcjb2forJeY0fW8tz1mlteOUo7IsWnrU,3059
|
|
5
5
|
cognite/extractorutils/configtools/_util.py,sha256=SZycZm_py9v9WZbDiDQbgS6_PiLtu-TtwuuH7tG2YCI,4739
|
|
6
|
-
cognite/extractorutils/configtools/elements.py,sha256=
|
|
7
|
-
cognite/extractorutils/configtools/loaders.py,sha256=
|
|
6
|
+
cognite/extractorutils/configtools/elements.py,sha256=k6q8NXZrV3efD_8BcTQvhb7lvTvsHbX30nshQgqeIQk,21703
|
|
7
|
+
cognite/extractorutils/configtools/loaders.py,sha256=_bMEb2_WaBL_G9w5IXU5UKwSu1VGge0PPAWgfSribYI,17647
|
|
8
8
|
cognite/extractorutils/exceptions.py,sha256=XiwyNPSN0YxFYaPw7tfA63B94PL48xDK3EfdGdhgQgc,1084
|
|
9
9
|
cognite/extractorutils/metrics.py,sha256=01ZMRbDisXPxrfCSyTSEkXMsslzmZwEqw18fuu9okdc,15509
|
|
10
10
|
cognite/extractorutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -21,11 +21,11 @@ cognite/extractorutils/uploader/data_modeling.py,sha256=w35Ix5mu0Cgfn4ywnDyif4VV
|
|
|
21
21
|
cognite/extractorutils/uploader/events.py,sha256=NZP2tMoU_rh_rb-EZiUBsOT5KdNABHN4c9Oddk0OsdE,5680
|
|
22
22
|
cognite/extractorutils/uploader/files.py,sha256=31kPS4fwz8ZSXWss-CKmYTM6ZLVx9LtsDe7LHT7Wy98,18329
|
|
23
23
|
cognite/extractorutils/uploader/raw.py,sha256=wFjF90PFTjmByOWx_Y4_YfDJ2w2jl0EQJ2Tjx2MP2PM,6738
|
|
24
|
-
cognite/extractorutils/uploader/time_series.py,sha256=
|
|
24
|
+
cognite/extractorutils/uploader/time_series.py,sha256=HBtQdsQoIOaL-EG5lMsaY-ORwVb0kGiXG86VjE5-_Bg,26815
|
|
25
25
|
cognite/extractorutils/uploader_extractor.py,sha256=E-mpVvbPg_Tk90U4S9JybV0duptJ2SXE88HB6npE3zI,7732
|
|
26
26
|
cognite/extractorutils/uploader_types.py,sha256=wxfrsiKPTzG5lmoYtQsxt8Xyj-s5HnaLl8WDzJNrazg,1020
|
|
27
27
|
cognite/extractorutils/util.py,sha256=UA6mUZ1caHd6vtA45gZXrk6cxo5cSB2PZ32bMwfEU0M,17229
|
|
28
|
-
cognite_extractor_utils-7.2.
|
|
29
|
-
cognite_extractor_utils-7.2.
|
|
30
|
-
cognite_extractor_utils-7.2.
|
|
31
|
-
cognite_extractor_utils-7.2.
|
|
28
|
+
cognite_extractor_utils-7.2.2.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
|
|
29
|
+
cognite_extractor_utils-7.2.2.dist-info/METADATA,sha256=8cw9XRHtl8RAjaiaGQFwX4i0rBFgkRidxuitf9Cx00U,5486
|
|
30
|
+
cognite_extractor_utils-7.2.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
31
|
+
cognite_extractor_utils-7.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|