cognite-extractor-utils 7.5.9__py3-none-any.whl → 7.5.11__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.

@@ -16,7 +16,7 @@
16
16
  Cognite extractor utils is a Python package that simplifies the development of new extractors.
17
17
  """
18
18
 
19
- __version__ = "7.5.9"
19
+ __version__ = "7.5.11"
20
20
  from .base import Extractor
21
21
 
22
22
  __all__ = ["Extractor"]
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import re
2
3
  from datetime import timedelta
3
4
  from enum import Enum
@@ -215,6 +216,36 @@ class ConnectionConfig(ConfigModel):
215
216
 
216
217
  return CogniteClient(client_config)
217
218
 
219
+ @classmethod
220
+ def from_environment(cls) -> "ConnectionConfig":
221
+ auth: AuthenticationConfig
222
+ if "COGNITE_CLIENT_SECRET" in os.environ:
223
+ auth = _ClientCredentialsConfig(
224
+ type="client-credentials",
225
+ client_id=os.environ["COGNITE_CLIENT_ID"],
226
+ client_secret=os.environ["COGNITE_CLIENT_SECRET"],
227
+ token_url=os.environ["COGNITE_TOKEN_URL"],
228
+ scopes=os.environ["COGNITE_TOKEN_SCOPES"].split(","),
229
+ )
230
+ elif "COGNITE_CLIENT_CERTIFICATE_PATH" in os.environ:
231
+ auth = _ClientCertificateConfig(
232
+ type="client-certificate",
233
+ client_id=os.environ["COGNITE_CLIENT_ID"],
234
+ path=Path(os.environ["COGNITE_CLIENT_CERTIFICATE_PATH"]),
235
+ password=os.environ.get("COGNITE_CLIENT_CERTIFICATE_PATH"),
236
+ authority_url=os.environ["COGNITE_AUTHORITY_URL"],
237
+ scopes=os.environ["COGNITE_TOKEN_SCOPES"].split(","),
238
+ )
239
+ else:
240
+ raise KeyError("Missing auth, either COGNITE_CLIENT_SECRET or COGNITE_CLIENT_CERTIFICATE_PATH must be set")
241
+
242
+ return ConnectionConfig(
243
+ project=os.environ["COGNITE_PROJECT"],
244
+ base_url=os.environ["COGNITE_BASE_URL"],
245
+ integration=os.environ["COGNITE_INTEGRATION"],
246
+ authentication=auth,
247
+ )
248
+
218
249
 
219
250
  class CronConfig(ConfigModel):
220
251
  type: Literal["cron"]
@@ -25,6 +25,7 @@ from typing import (
25
25
  )
26
26
  from urllib.parse import ParseResult, urlparse
27
27
 
28
+ from h11._util import LocalProtocolError
28
29
  from httpx import URL, Client, Headers, Request, StreamConsumed, SyncByteStream
29
30
  from requests.utils import super_len
30
31
 
@@ -481,6 +482,19 @@ class IOFileUploadQueue(AbstractUploadQueue):
481
482
  try:
482
483
  upload_file(read_file, file_meta)
483
484
 
485
+ except LocalProtocolError as e:
486
+ error_message = str(e)
487
+ if (
488
+ "Too much data for declared Content" in error_message
489
+ or "Too little data for declared Content-Length" in error_message
490
+ ):
491
+ self.logger.error(
492
+ f"Content Length Mismatch while uploading file: {file_meta} error message: {error_message}"
493
+ )
494
+
495
+ self.add_entry_failure_logger(file_name=str(file_meta.name), error=e)
496
+ self.errors.append(e)
497
+
484
498
  except Exception as e:
485
499
  self.logger.exception(
486
500
  f"Unexpected error while uploading file: {file_meta.external_id} {file_meta.name}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite-extractor-utils
3
- Version: 7.5.9
3
+ Version: 7.5.11
4
4
  Summary: Utilities for easier development of extractors for CDF
5
5
  Project-URL: repository, https://github.com/cognitedata/python-extractor-utils
6
6
  Author-email: Mathias Lohne <mathias.lohne@cognite.com>
@@ -14,7 +14,7 @@ Requires-Dist: azure-identity>=1.14.0
14
14
  Requires-Dist: azure-keyvault-secrets>=4.7.0
15
15
  Requires-Dist: cognite-sdk>=7.59.0
16
16
  Requires-Dist: croniter>=6.0.0
17
- Requires-Dist: dacite>=1.6.0
17
+ Requires-Dist: dacite<1.9.0,>=1.6.0
18
18
  Requires-Dist: decorator>=5.1.1
19
19
  Requires-Dist: httpx<1,>=0.27.0
20
20
  Requires-Dist: jsonlines>=4.0.0
@@ -1,4 +1,4 @@
1
- cognite/extractorutils/__init__.py,sha256=9ImaA1fzZeO4aXeQjkMOpz_E7Nky0b4IP9htbfQLNjI,764
1
+ cognite/extractorutils/__init__.py,sha256=QMrJrW8mM_pXGYl31dhRBsnmCVY7HtLNYMUG_X-BvLw,765
2
2
  cognite/extractorutils/_inner_util.py,sha256=ZMZIBwFpSD39RzLZq_OJlrFtVt8NFOtU4ObzAG8vTB4,1779
3
3
  cognite/extractorutils/base.py,sha256=-jkGgUMYKdhFReua8ZoGUQwT1qbOvg6nTrt0lyJOGVc,16354
4
4
  cognite/extractorutils/exceptions.py,sha256=4qreRiTwZH9lyLIKR67TP02MUxN9oYhCd2vFTb5bRME,1125
@@ -21,7 +21,7 @@ cognite/extractorutils/unstable/__init__.py,sha256=L6nqJHjylpk67CE-PbXJyb_TBI4yj
21
21
  cognite/extractorutils/unstable/configuration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  cognite/extractorutils/unstable/configuration/exceptions.py,sha256=2-0jUp9IFwzk2QTQzWLoGgW1KOApk9UmPmLwtwRUBaE,591
23
23
  cognite/extractorutils/unstable/configuration/loaders.py,sha256=guBSVz7nd3dfsNEfPEHUUmU5WoYdPQmBBaJk2FuKXVw,3640
24
- cognite/extractorutils/unstable/configuration/models.py,sha256=vrwe53CZroujNVVpgQbmZEOywtR8PMJ0exi9gBjc5Gw,8160
24
+ cognite/extractorutils/unstable/configuration/models.py,sha256=YYGXxSwct04J9A6NDlW0kpKHvlvtPxuLeMHgq5KwH-g,9567
25
25
  cognite/extractorutils/unstable/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  cognite/extractorutils/unstable/core/_dto.py,sha256=tvvy39cvf-QT28GWz5FpqxQ5vAVk0t69JoPPhpWlweY,1293
27
27
  cognite/extractorutils/unstable/core/_messaging.py,sha256=D9rOW8fijryXffbm90d8VTf2vy5FmwVGU-H0O-cn-EI,68
@@ -40,11 +40,11 @@ cognite/extractorutils/uploader/_metrics.py,sha256=J2LJXb19L_SLSJ_voNIQHYLp0pjxU
40
40
  cognite/extractorutils/uploader/assets.py,sha256=a6LKbGjWh29Lj0PnL1bdhP88e27FKh8xfTFTsOBUOew,5713
41
41
  cognite/extractorutils/uploader/data_modeling.py,sha256=h4uRnppU2dVBquJz0Uy2SKNy5A1Gq-g7ZAlERu5vjIU,3614
42
42
  cognite/extractorutils/uploader/events.py,sha256=soU8TslPFIA7Ck4ATR_a7MHGitztRcn0cEt7LIbMPsE,5643
43
- cognite/extractorutils/uploader/files.py,sha256=U3wBU8iJNbOIP-JV_K3tRVHkB1gsb4lCjNlWbr-wg-0,26553
43
+ cognite/extractorutils/uploader/files.py,sha256=ag3TUrImJdAUiOSXugagD03-9WGlFpIyd31z3WMJU20,27180
44
44
  cognite/extractorutils/uploader/raw.py,sha256=8duMk9uVJPK3O6C0nzwnvrl0UzBtJs_T_L1la0Vo89k,6713
45
45
  cognite/extractorutils/uploader/time_series.py,sha256=rs-jEChEZymxc98TYePpSRstPjQnDJd97vjOEYc-0-A,26568
46
46
  cognite/extractorutils/uploader/upload_failure_handler.py,sha256=wbUSXUP26rbmK2NGdQMzcWQwNOh2sXYOnlj0A_sk1n8,2003
47
- cognite_extractor_utils-7.5.9.dist-info/METADATA,sha256=jInc1LEbqmrE65cSI1kdktojnU0Y8AU5muy98PjmT7I,5272
48
- cognite_extractor_utils-7.5.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- cognite_extractor_utils-7.5.9.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
50
- cognite_extractor_utils-7.5.9.dist-info/RECORD,,
47
+ cognite_extractor_utils-7.5.11.dist-info/METADATA,sha256=Ywvqxw4d9cEHRmAzbjjiNwdAmgb2FB2mxpo9XhLmGBE,5280
48
+ cognite_extractor_utils-7.5.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
+ cognite_extractor_utils-7.5.11.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
50
+ cognite_extractor_utils-7.5.11.dist-info/RECORD,,