cognite-extractor-utils 7.4.8__py3-none-any.whl → 7.4.9__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/__init__.py +2 -0
- cognite/extractorutils/configtools/elements.py +40 -0
- cognite/extractorutils/configtools/loaders.py +3 -1
- {cognite_extractor_utils-7.4.8.dist-info → cognite_extractor_utils-7.4.9.dist-info}/METADATA +1 -1
- {cognite_extractor_utils-7.4.8.dist-info → cognite_extractor_utils-7.4.9.dist-info}/RECORD +8 -8
- {cognite_extractor_utils-7.4.8.dist-info → cognite_extractor_utils-7.4.9.dist-info}/LICENSE +0 -0
- {cognite_extractor_utils-7.4.8.dist-info → cognite_extractor_utils-7.4.9.dist-info}/WHEEL +0 -0
|
@@ -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,10 +1,10 @@
|
|
|
1
|
-
cognite/extractorutils/__init__.py,sha256=
|
|
1
|
+
cognite/extractorutils/__init__.py,sha256=Cxd38BeR0YorUxKXaS9dz_FKoKa2trhrZJFhiHh0EuY,739
|
|
2
2
|
cognite/extractorutils/_inner_util.py,sha256=gmz6aqS7jDNsg8z4RHgJjMFohDLOMiaU4gMWBhg3xcE,1558
|
|
3
3
|
cognite/extractorutils/base.py,sha256=q6NU2bPec3WOasVnnIFoh-aUJudVZWZ2R6emz3IRj8Q,16391
|
|
4
|
-
cognite/extractorutils/configtools/__init__.py,sha256=
|
|
4
|
+
cognite/extractorutils/configtools/__init__.py,sha256=YEpFGJoza23eM8Zj5DqqUj7sEstERV_QYsN6Nw4dKCg,3092
|
|
5
5
|
cognite/extractorutils/configtools/_util.py,sha256=WdZptkZz_vkn1M4Vqwb39Gb1wxTOe_MNJXWHzOtwv50,4797
|
|
6
|
-
cognite/extractorutils/configtools/elements.py,sha256=
|
|
7
|
-
cognite/extractorutils/configtools/loaders.py,sha256=
|
|
6
|
+
cognite/extractorutils/configtools/elements.py,sha256=6HWhh4jVS-v7Wzl9j3D-Gbli7tEtVidnkIT-eQKCOAE,26314
|
|
7
|
+
cognite/extractorutils/configtools/loaders.py,sha256=TEBW9SuvYY-sCq6is0nYSFGM4kcwUdomqcuK9Dv0GbQ,18262
|
|
8
8
|
cognite/extractorutils/configtools/validators.py,sha256=5or-lg8UHNzl7KfZpbVx8b40835RZwHbUQlMsUCAs4w,1053
|
|
9
9
|
cognite/extractorutils/exceptions.py,sha256=1PgvW1FrgVnuNtkwC0RTvG1-FZp1qmBuYrY1AWW-BJc,1188
|
|
10
10
|
cognite/extractorutils/metrics.py,sha256=01ZMRbDisXPxrfCSyTSEkXMsslzmZwEqw18fuu9okdc,15509
|
|
@@ -38,7 +38,7 @@ cognite/extractorutils/uploader/time_series.py,sha256=HBtQdsQoIOaL-EG5lMsaY-ORwV
|
|
|
38
38
|
cognite/extractorutils/uploader_extractor.py,sha256=E-mpVvbPg_Tk90U4S9JybV0duptJ2SXE88HB6npE3zI,7732
|
|
39
39
|
cognite/extractorutils/uploader_types.py,sha256=wxfrsiKPTzG5lmoYtQsxt8Xyj-s5HnaLl8WDzJNrazg,1020
|
|
40
40
|
cognite/extractorutils/util.py,sha256=T6ef5b7aYJ8yq9swQwybYaLe3YGr3hElsJQy8E-d5Rs,17469
|
|
41
|
-
cognite_extractor_utils-7.4.
|
|
42
|
-
cognite_extractor_utils-7.4.
|
|
43
|
-
cognite_extractor_utils-7.4.
|
|
44
|
-
cognite_extractor_utils-7.4.
|
|
41
|
+
cognite_extractor_utils-7.4.9.dist-info/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
|
|
42
|
+
cognite_extractor_utils-7.4.9.dist-info/METADATA,sha256=I5rq1WJzAnrchQKwS75G30Xx_qZkJ-ZDYP9w_8RZ2jw,5598
|
|
43
|
+
cognite_extractor_utils-7.4.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
44
|
+
cognite_extractor_utils-7.4.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|