cognite-extractor-utils 7.2.2__tar.gz → 7.2.3__tar.gz
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_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/PKG-INFO +1 -1
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/__init__.py +1 -1
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/configtools/elements.py +35 -6
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/pyproject.toml +3 -3
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/LICENSE +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/README.md +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/_inner_util.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/base.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/configtools/__init__.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/configtools/_util.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/configtools/loaders.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/exceptions.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/metrics.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/py.typed +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/statestore/__init__.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/statestore/_base.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/statestore/hashing.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/statestore/watermark.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/threading.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/__init__.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/_base.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/_metrics.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/assets.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/data_modeling.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/events.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/files.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/raw.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader/time_series.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader_extractor.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/uploader_types.py +0 -0
- {cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/util.py +0 -0
|
@@ -20,7 +20,7 @@ from enum import Enum
|
|
|
20
20
|
from logging.handlers import TimedRotatingFileHandler
|
|
21
21
|
from time import sleep
|
|
22
22
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
23
|
-
from urllib.parse import urljoin
|
|
23
|
+
from urllib.parse import urljoin, urlparse
|
|
24
24
|
|
|
25
25
|
import yaml
|
|
26
26
|
from prometheus_client import REGISTRY, start_http_server
|
|
@@ -70,7 +70,7 @@ class AuthenticatorConfig:
|
|
|
70
70
|
|
|
71
71
|
client_id: str
|
|
72
72
|
scopes: List[str]
|
|
73
|
-
secret: Optional[str]
|
|
73
|
+
secret: Optional[str] = None
|
|
74
74
|
tenant: Optional[str] = None
|
|
75
75
|
token_url: Optional[str] = None
|
|
76
76
|
resource: Optional[str] = None
|
|
@@ -264,6 +264,18 @@ class FileSizeConfig(yaml.YAMLObject):
|
|
|
264
264
|
return self._expression
|
|
265
265
|
|
|
266
266
|
|
|
267
|
+
path_elem_regex = re.compile(r"^([a-zA-Z0-9.\-_~!$&'()*+,;=:@]|%[A-F0-9]{2})*$")
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def _validate_https_url(value: str, name: str) -> None:
|
|
271
|
+
try:
|
|
272
|
+
url = urlparse(value)
|
|
273
|
+
except Exception as e:
|
|
274
|
+
raise InvalidConfigError(f"{name} ({value}) is not a valid URL") from e
|
|
275
|
+
if url.scheme != "https":
|
|
276
|
+
raise InvalidConfigError(f"{name} ({value}) must be HTTPS")
|
|
277
|
+
|
|
278
|
+
|
|
267
279
|
@dataclass
|
|
268
280
|
class CogniteConfig:
|
|
269
281
|
"""
|
|
@@ -272,10 +284,10 @@ class CogniteConfig:
|
|
|
272
284
|
|
|
273
285
|
project: str
|
|
274
286
|
idp_authentication: AuthenticatorConfig
|
|
275
|
-
data_set: Optional[EitherIdConfig]
|
|
276
|
-
data_set_id: Optional[int]
|
|
277
|
-
data_set_external_id: Optional[str]
|
|
278
|
-
extraction_pipeline: Optional[EitherIdConfig]
|
|
287
|
+
data_set: Optional[EitherIdConfig] = None
|
|
288
|
+
data_set_id: Optional[int] = None
|
|
289
|
+
data_set_external_id: Optional[str] = None
|
|
290
|
+
extraction_pipeline: Optional[EitherIdConfig] = None
|
|
279
291
|
timeout: TimeIntervalConfig = TimeIntervalConfig("30s")
|
|
280
292
|
connection: ConnectionConfig = field(default_factory=ConnectionConfig)
|
|
281
293
|
security_categories: Optional[List[int]] = None
|
|
@@ -300,11 +312,20 @@ class CogniteConfig:
|
|
|
300
312
|
global_config.disable_ssl = self.connection.disable_ssl
|
|
301
313
|
global_config.proxies = self.connection.proxies
|
|
302
314
|
|
|
315
|
+
if not self.project:
|
|
316
|
+
raise InvalidConfigError("Project is not set")
|
|
317
|
+
if not path_elem_regex.match(self.project):
|
|
318
|
+
raise InvalidConfigError(f"Project ({self.project}) is not valid")
|
|
319
|
+
|
|
303
320
|
credential_provider: CredentialProvider
|
|
304
321
|
if self.idp_authentication.certificate:
|
|
305
322
|
if self.idp_authentication.certificate.authority_url:
|
|
306
323
|
authority_url = self.idp_authentication.certificate.authority_url
|
|
324
|
+
_validate_https_url(self.idp_authentication.certificate.authority_url, "Authority URL")
|
|
307
325
|
elif self.idp_authentication.tenant:
|
|
326
|
+
_validate_https_url(self.idp_authentication.authority, "Authority")
|
|
327
|
+
if not path_elem_regex.match(self.idp_authentication.tenant):
|
|
328
|
+
raise InvalidConfigError(f"Tenant {self.idp_authentication.tenant} is not valid")
|
|
308
329
|
authority_url = urljoin(self.idp_authentication.authority, self.idp_authentication.tenant)
|
|
309
330
|
else:
|
|
310
331
|
raise InvalidConfigError("Either authority-url or tenant is required for certificate authentication")
|
|
@@ -312,6 +333,8 @@ class CogniteConfig:
|
|
|
312
333
|
self.idp_authentication.certificate.path,
|
|
313
334
|
self.idp_authentication.certificate.password,
|
|
314
335
|
)
|
|
336
|
+
if not self.idp_authentication.scopes:
|
|
337
|
+
_logger.warn("No scopes configured. Authenticating with CDF is unlikely to work correctly")
|
|
315
338
|
credential_provider = OAuthClientCertificate(
|
|
316
339
|
authority_url=authority_url,
|
|
317
340
|
client_id=self.idp_authentication.client_id,
|
|
@@ -323,14 +346,20 @@ class CogniteConfig:
|
|
|
323
346
|
elif self.idp_authentication.secret:
|
|
324
347
|
kwargs: Dict[str, Any] = {}
|
|
325
348
|
if self.idp_authentication.token_url:
|
|
349
|
+
_validate_https_url(self.idp_authentication.token_url, "Token URL")
|
|
326
350
|
kwargs["token_url"] = self.idp_authentication.token_url
|
|
327
351
|
elif self.idp_authentication.tenant:
|
|
352
|
+
_validate_https_url(self.idp_authentication.authority, "Authority")
|
|
353
|
+
if not path_elem_regex.match(self.idp_authentication.tenant):
|
|
354
|
+
raise InvalidConfigError(f"Tenant ({self.idp_authentication.tenant}) is not valid")
|
|
328
355
|
base_url = urljoin(self.idp_authentication.authority, self.idp_authentication.tenant)
|
|
329
356
|
kwargs["token_url"] = f"{base_url}/oauth2/v2.0/token"
|
|
330
357
|
else:
|
|
331
358
|
raise InvalidConfigError("Either token-url or tenant is required for client credentials authentication")
|
|
332
359
|
kwargs["client_id"] = self.idp_authentication.client_id
|
|
333
360
|
kwargs["client_secret"] = self.idp_authentication.secret
|
|
361
|
+
if not self.idp_authentication.scopes:
|
|
362
|
+
_logger.warning("No scopes configured. Authenticating with CDF is unlikely to work correctly")
|
|
334
363
|
kwargs["scopes"] = self.idp_authentication.scopes
|
|
335
364
|
if token_custom_args is None:
|
|
336
365
|
token_custom_args = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cognite-extractor-utils"
|
|
3
|
-
version = "7.2.
|
|
3
|
+
version = "7.2.3"
|
|
4
4
|
description = "Utilities for easier development of extractors for CDF"
|
|
5
5
|
authors = ["Mathias Lohne <mathias.lohne@cognite.com>"]
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -72,7 +72,7 @@ experimental = ["cognite-sdk-experimental"]
|
|
|
72
72
|
|
|
73
73
|
[tool.poetry.group.dev.dependencies]
|
|
74
74
|
mypy = "1.10.1"
|
|
75
|
-
ruff = "^0.
|
|
75
|
+
ruff = "^0.5.0"
|
|
76
76
|
pytest = "^8.0.0"
|
|
77
77
|
pytest-cov = "^5.0.0"
|
|
78
78
|
sphinx = "^7.0.0"
|
|
@@ -85,7 +85,7 @@ parameterized = "*"
|
|
|
85
85
|
requests = "^2.31.0"
|
|
86
86
|
types-requests = "^2.31.0.20240125"
|
|
87
87
|
httpx = "^0.27.0"
|
|
88
|
-
faker = "^
|
|
88
|
+
faker = "^26.0.0"
|
|
89
89
|
|
|
90
90
|
[build-system]
|
|
91
91
|
requires = ["poetry-core>=1.0.0"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/exceptions.py
RENAMED
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/metrics.py
RENAMED
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/threading.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognite_extractor_utils-7.2.2 → cognite_extractor_utils-7.2.3}/cognite/extractorutils/util.py
RENAMED
|
File without changes
|