cognite-extractor-utils 7.4.8__tar.gz → 7.4.9__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.

Files changed (44) hide show
  1. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/PKG-INFO +1 -1
  2. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/__init__.py +1 -1
  3. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/configtools/__init__.py +2 -0
  4. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/configtools/elements.py +40 -0
  5. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/configtools/loaders.py +3 -1
  6. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/pyproject.toml +1 -1
  7. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/LICENSE +0 -0
  8. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/README.md +0 -0
  9. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/_inner_util.py +0 -0
  10. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/base.py +0 -0
  11. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/configtools/_util.py +0 -0
  12. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/configtools/validators.py +0 -0
  13. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/exceptions.py +0 -0
  14. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/metrics.py +0 -0
  15. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/py.typed +0 -0
  16. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/statestore/__init__.py +0 -0
  17. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/statestore/_base.py +0 -0
  18. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/statestore/hashing.py +0 -0
  19. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/statestore/watermark.py +0 -0
  20. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/threading.py +0 -0
  21. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/__init__.py +0 -0
  22. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/configuration/__init__.py +0 -0
  23. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/configuration/loaders.py +0 -0
  24. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/configuration/models.py +0 -0
  25. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/core/__init__.py +0 -0
  26. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/core/__main__.py +0 -0
  27. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/core/_messaging.py +0 -0
  28. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/core/base.py +0 -0
  29. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/core/runtime.py +0 -0
  30. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/scheduling/__init__.py +0 -0
  31. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/scheduling/_scheduler.py +0 -0
  32. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/unstable/scheduling/_schedules.py +0 -0
  33. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/__init__.py +0 -0
  34. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/_base.py +0 -0
  35. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/_metrics.py +0 -0
  36. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/assets.py +0 -0
  37. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/data_modeling.py +0 -0
  38. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/events.py +0 -0
  39. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/files.py +0 -0
  40. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/raw.py +0 -0
  41. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader/time_series.py +0 -0
  42. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader_extractor.py +0 -0
  43. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/uploader_types.py +0 -0
  44. {cognite_extractor_utils-7.4.8 → cognite_extractor_utils-7.4.9}/cognite/extractorutils/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-extractor-utils
3
- Version: 7.4.8
3
+ Version: 7.4.9
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
@@ -16,5 +16,5 @@
16
16
  Cognite extractor utils is a Python package that simplifies the development of new extractors.
17
17
  """
18
18
 
19
- __version__ = "7.4.8"
19
+ __version__ = "7.4.9"
20
20
  from .base import Extractor
@@ -90,6 +90,7 @@ from cognite.extractorutils.exceptions import InvalidConfigError
90
90
  from .elements import (
91
91
  AuthenticatorConfig,
92
92
  BaseConfig,
93
+ CastableInt,
93
94
  CertificateConfig,
94
95
  CogniteConfig,
95
96
  ConfigType,
@@ -99,6 +100,7 @@ from .elements import (
99
100
  LocalStateStoreConfig,
100
101
  LoggingConfig,
101
102
  MetricsConfig,
103
+ PortNumber,
102
104
  RawDestinationConfig,
103
105
  RawStateStoreConfig,
104
106
  StateStoreConfig,
@@ -744,3 +744,43 @@ class IgnorePattern:
744
744
  _logger.warning("'options' is preferred over 'flags' as this may be removed in a future release")
745
745
  self.options = self.flags
746
746
  self.flags = None
747
+
748
+
749
+ class CastableInt(int):
750
+ """
751
+ Represents an integer in a config schema. Difference from regular int is that the
752
+ value if this type can be either a string or an integer in the yaml file.
753
+ """
754
+
755
+ def __new__(cls, value: Any) -> "CastableInt":
756
+ """
757
+ Returns value as is if it's int. If it's str or bytes try to convert to int.
758
+ Raises ValueError if conversion is unsuccessful or value is of not supported type.
759
+
760
+ Type check is required to avoid unexpected behaviour, such as implictly casting booleans,
761
+ floats and other types supported by standard int.
762
+ """
763
+
764
+ if not isinstance(value, (int, str, bytes)):
765
+ raise ValueError(f"CastableInt cannot be created form value {value!r} of type {type(value)!r}.")
766
+
767
+ return super().__new__(cls, value)
768
+
769
+
770
+ class PortNumber(CastableInt):
771
+ """
772
+ A subclass of int to be used in config schemas. It represents a valid port number (0 to 65535) and allows the value
773
+ to be of either str or int type. If the value is not a valid port number raises a ValueError at instantiation.
774
+ """
775
+
776
+ def __new__(cls, value: Any) -> "PortNumber":
777
+ """
778
+ Try to convert the `value` to int. If successful, check if it's within a valid range for a port number.
779
+ Raises ValueError if conversion to int or validation is unsuccessful.
780
+ """
781
+ value = super().__new__(cls, value)
782
+
783
+ if not (0 <= value <= 65535):
784
+ raise ValueError(f"Port number must be between 0 and 65535. Got: {value}.")
785
+
786
+ return value
@@ -36,8 +36,10 @@ from cognite.client import CogniteClient
36
36
  from cognite.extractorutils.configtools._util import _to_snake_case
37
37
  from cognite.extractorutils.configtools.elements import (
38
38
  BaseConfig,
39
+ CastableInt,
39
40
  ConfigType,
40
41
  IgnorePattern,
42
+ PortNumber,
41
43
  TimeIntervalConfig,
42
44
  _BaseConfig,
43
45
  )
@@ -224,7 +226,7 @@ def _load_yaml(
224
226
  config = dacite.from_dict(
225
227
  data=config_dict,
226
228
  data_class=config_type,
227
- config=dacite.Config(strict=True, cast=[Enum, TimeIntervalConfig, Path]),
229
+ config=dacite.Config(strict=True, cast=[Enum, TimeIntervalConfig, Path, CastableInt, PortNumber]),
228
230
  )
229
231
  except dacite.UnexpectedDataError as e:
230
232
  unknowns = [f'"{k.replace("_", "-") if case_style == "hyphen" else k}"' for k in e.keys]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cognite-extractor-utils"
3
- version = "7.4.8"
3
+ version = "7.4.9"
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"