cognite-extractor-utils 7.7.0__tar.gz → 7.8.1__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.7.0 → cognite_extractor_utils-7.8.1}/PKG-INFO +4 -3
- cognite_extractor_utils-7.8.1/cognite/examples/unstable/extractors/simple_extractor/config/config.yaml +3 -0
- cognite_extractor_utils-7.8.1/cognite/examples/unstable/extractors/simple_extractor/config/connection_config.yaml +10 -0
- cognite_extractor_utils-7.8.1/cognite/examples/unstable/extractors/simple_extractor/main.py +81 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/__init__.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/_inner_util.py +2 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/base.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/configtools/elements.py +4 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/configtools/loaders.py +18 -4
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/exceptions.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/metrics.py +8 -6
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/statestore/watermark.py +6 -3
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/threading.py +2 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/configuration/exceptions.py +28 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/configuration/models.py +157 -32
- cognite_extractor_utils-7.8.1/cognite/extractorutils/unstable/core/_dto.py +119 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/base.py +171 -106
- cognite_extractor_utils-7.8.1/cognite/extractorutils/unstable/core/checkin_worker.py +428 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/errors.py +2 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/logger.py +49 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/runtime.py +200 -31
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/tasks.py +2 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/_base.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/assets.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/data_modeling.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/events.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/files.py +4 -4
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/raw.py +1 -1
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/time_series.py +4 -4
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader_extractor.py +2 -2
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader_types.py +3 -3
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/util.py +8 -6
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/pyproject.toml +11 -7
- cognite_extractor_utils-7.7.0/cognite/extractorutils/unstable/core/_dto.py +0 -46
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/.gitignore +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/LICENSE +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/README.md +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/configtools/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/configtools/_util.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/configtools/validators.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/py.typed +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/statestore/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/statestore/_base.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/statestore/hashing.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/configuration/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/configuration/loaders.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/_messaging.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/core/restart_policy.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/scheduling/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/scheduling/_scheduler.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/unstable/scheduling/_schedules.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/__init__.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/_metrics.py +0 -0
- {cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/uploader/upload_failure_handler.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite-extractor-utils
|
|
3
|
-
Version: 7.
|
|
3
|
+
Version: 7.8.1
|
|
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>
|
|
@@ -12,9 +12,9 @@ Requires-Python: >=3.10
|
|
|
12
12
|
Requires-Dist: arrow>=1.0.0
|
|
13
13
|
Requires-Dist: azure-identity>=1.14.0
|
|
14
14
|
Requires-Dist: azure-keyvault-secrets>=4.7.0
|
|
15
|
-
Requires-Dist: cognite-sdk>=7.
|
|
15
|
+
Requires-Dist: cognite-sdk>=7.75.2
|
|
16
16
|
Requires-Dist: croniter>=6.0.0
|
|
17
|
-
Requires-Dist: dacite<1.
|
|
17
|
+
Requires-Dist: dacite<1.10.0,>=1.9.2
|
|
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
|
|
@@ -26,6 +26,7 @@ Requires-Dist: pydantic>=2.8.2
|
|
|
26
26
|
Requires-Dist: pyhumps>=3.8.0
|
|
27
27
|
Requires-Dist: python-dotenv>=1.0.0
|
|
28
28
|
Requires-Dist: pyyaml<7,>=5.3.0
|
|
29
|
+
Requires-Dist: simple-winservice>=0.1.0; sys_platform == 'win32'
|
|
29
30
|
Requires-Dist: typing-extensions<5,>=3.7.4
|
|
30
31
|
Provides-Extra: experimental
|
|
31
32
|
Requires-Dist: cognite-sdk-experimental; extra == 'experimental'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
project: ${COGNITE_PROJECT}
|
|
2
|
+
base_url: ${COGNITE_BASE_URL}
|
|
3
|
+
integration:
|
|
4
|
+
external_id: ${COGNITE_INTEGRATION_ID}
|
|
5
|
+
authentication:
|
|
6
|
+
type: "client-credentials"
|
|
7
|
+
client_id: ${COGNITE_CLIENT_ID}
|
|
8
|
+
client_secret: ${COGNITE_CLIENT_SECRET}
|
|
9
|
+
token_url: ${COGNITE_TOKEN_URL}
|
|
10
|
+
scopes: ${COGNITE_SCOPES}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
An example extractor that logs messages at various levels.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from cognite.extractorutils.unstable.configuration.models import ExtractorConfig, IntervalConfig, TimeIntervalConfig
|
|
6
|
+
from cognite.extractorutils.unstable.core.base import Extractor, StartupTask, TaskContext
|
|
7
|
+
from cognite.extractorutils.unstable.core.runtime import Runtime
|
|
8
|
+
from cognite.extractorutils.unstable.core.tasks import ScheduledTask
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SimpleConfig(ExtractorConfig):
|
|
12
|
+
"""
|
|
13
|
+
Defines the configuration for the SimpleExtractor.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SimpleExtractor(Extractor[SimpleConfig]):
|
|
20
|
+
"""
|
|
21
|
+
An example extractor that logs messages at various levels.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
NAME = "SimpleTestExtractor"
|
|
25
|
+
EXTERNAL_ID = "test-extractor"
|
|
26
|
+
DESCRIPTION = "An extractor for testing log levels"
|
|
27
|
+
VERSION = "1.0.0"
|
|
28
|
+
CONFIG_TYPE = SimpleConfig
|
|
29
|
+
SUPPORTS_DRY_RUN = True
|
|
30
|
+
|
|
31
|
+
def __init_tasks__(self) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Initializes and adds tasks to the extractor.
|
|
34
|
+
"""
|
|
35
|
+
self.add_task(StartupTask(name="main_task", target=self.run_my_task))
|
|
36
|
+
self.add_task(
|
|
37
|
+
ScheduledTask(
|
|
38
|
+
name="scheduled_task",
|
|
39
|
+
target=self.scheduled_task,
|
|
40
|
+
schedule=IntervalConfig(type="interval", expression=TimeIntervalConfig("3s")),
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# example task that logs messages at different levels
|
|
45
|
+
def run_my_task(self, ctx: TaskContext) -> None:
|
|
46
|
+
"""
|
|
47
|
+
An example task that logs messages at different levels.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
ctx: The context for the task execution, used for logging.
|
|
51
|
+
"""
|
|
52
|
+
ctx.debug("This is a detailed debug message.")
|
|
53
|
+
ctx.info("This is an informational message.")
|
|
54
|
+
ctx.warning("This is a warning message.")
|
|
55
|
+
ctx.info("Test finished.")
|
|
56
|
+
|
|
57
|
+
def scheduled_task(self, ctx: TaskContext) -> None:
|
|
58
|
+
"""
|
|
59
|
+
An example scheduled task that logs a message.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
ctx: The context for the task execution, used for logging.
|
|
63
|
+
"""
|
|
64
|
+
ctx.info("This is a scheduled task running.")
|
|
65
|
+
ctx.warning("This is a warning from the scheduled task.")
|
|
66
|
+
ctx.debug("Debugging the scheduled task execution.")
|
|
67
|
+
ctx.error("This is an error message from the scheduled task.")
|
|
68
|
+
|
|
69
|
+
# add more tasks as needed
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def main() -> None:
|
|
73
|
+
"""
|
|
74
|
+
Main function to run the SimpleExtractor.
|
|
75
|
+
"""
|
|
76
|
+
runtime = Runtime(SimpleExtractor)
|
|
77
|
+
runtime.run()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
|
@@ -37,14 +37,14 @@ def resolve_log_level_for_httpx(level: str) -> str:
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class _DecimalEncoder(json.JSONEncoder):
|
|
40
|
-
def default(self, obj: Any) -> dict[str, str]:
|
|
40
|
+
def default(self, obj: Any) -> dict[str, str]: # noqa: ANN401
|
|
41
41
|
if isinstance(obj, Decimal):
|
|
42
42
|
return {"type": "decimal_encoded", "value": str(obj)}
|
|
43
43
|
return super().default(obj)
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
class _DecimalDecoder(json.JSONDecoder):
|
|
47
|
-
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
47
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
|
|
48
48
|
json.JSONDecoder.__init__(self, *args, object_hook=self.object_hook, **kwargs)
|
|
49
49
|
|
|
50
50
|
def object_hook(self, obj_dict: dict[str, str]) -> dict[str, str] | Decimal:
|
{cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/base.py
RENAMED
|
@@ -112,7 +112,7 @@ class Extractor(Generic[CustomConfigClass]):
|
|
|
112
112
|
reload_config_interval: int | None = 300,
|
|
113
113
|
reload_config_action: ReloadConfigAction = ReloadConfigAction.DO_NOTHING,
|
|
114
114
|
success_message: str = "Successful shutdown",
|
|
115
|
-
):
|
|
115
|
+
) -> None:
|
|
116
116
|
self.name = name
|
|
117
117
|
self.description = description
|
|
118
118
|
self.run_handle = run_handle
|
|
@@ -29,6 +29,7 @@ from urllib.parse import urljoin, urlparse
|
|
|
29
29
|
|
|
30
30
|
import yaml
|
|
31
31
|
from prometheus_client import REGISTRY, start_http_server
|
|
32
|
+
from typing_extensions import Self
|
|
32
33
|
|
|
33
34
|
from cognite.client import ClientConfig, CogniteClient
|
|
34
35
|
from cognite.client.credentials import (
|
|
@@ -604,6 +605,7 @@ class LoggingConfig:
|
|
|
604
605
|
when="midnight",
|
|
605
606
|
utc=True,
|
|
606
607
|
backupCount=self.file.retention,
|
|
608
|
+
encoding="utf-8",
|
|
607
609
|
)
|
|
608
610
|
file_handler.setLevel(self.file.level)
|
|
609
611
|
file_handler.setFormatter(fmt)
|
|
@@ -926,7 +928,7 @@ class CastableInt(int):
|
|
|
926
928
|
file.
|
|
927
929
|
"""
|
|
928
930
|
|
|
929
|
-
def __new__(cls, value:
|
|
931
|
+
def __new__(cls, value: int | str | bytes) -> Self:
|
|
930
932
|
"""
|
|
931
933
|
Returns value as is if it's int.
|
|
932
934
|
|
|
@@ -955,7 +957,7 @@ class PortNumber(CastableInt):
|
|
|
955
957
|
not a valid port number raises a ValueError at instantiation.
|
|
956
958
|
"""
|
|
957
959
|
|
|
958
|
-
def __new__(cls, value:
|
|
960
|
+
def __new__(cls, value: int | str | bytes) -> Self:
|
|
959
961
|
"""
|
|
960
962
|
Try to cast the value to an integer and validate it as a port number.
|
|
961
963
|
|
|
@@ -72,7 +72,7 @@ class KeyVaultLoader:
|
|
|
72
72
|
config: A dictionary containing the configuration for the keyvault.
|
|
73
73
|
"""
|
|
74
74
|
|
|
75
|
-
def __init__(self, config: dict | None):
|
|
75
|
+
def __init__(self, config: dict | None) -> None:
|
|
76
76
|
self.config = config
|
|
77
77
|
|
|
78
78
|
self.client: SecretClient | None = None
|
|
@@ -374,7 +374,7 @@ class ConfigResolver(Generic[CustomConfigClass]):
|
|
|
374
374
|
Automatically reloads the configuration file if it has changed
|
|
375
375
|
"""
|
|
376
376
|
|
|
377
|
-
def __init__(self, config_path: str, config_type: type[CustomConfigClass]):
|
|
377
|
+
def __init__(self, config_path: str, config_type: type[CustomConfigClass]) -> None:
|
|
378
378
|
self.config_path = config_path
|
|
379
379
|
self.config_type = config_type
|
|
380
380
|
|
|
@@ -384,8 +384,22 @@ class ConfigResolver(Generic[CustomConfigClass]):
|
|
|
384
384
|
self._cognite_client: CogniteClient | None = None
|
|
385
385
|
|
|
386
386
|
def _reload_file(self) -> None:
|
|
387
|
-
|
|
388
|
-
self.
|
|
387
|
+
try:
|
|
388
|
+
with open(self.config_path, encoding="utf-8") as stream:
|
|
389
|
+
self._config_text = stream.read()
|
|
390
|
+
except UnicodeDecodeError:
|
|
391
|
+
_logger.warning(
|
|
392
|
+
f"Config file '{self.config_path}' is not valid UTF-8. Falling back to system default encoding."
|
|
393
|
+
)
|
|
394
|
+
try:
|
|
395
|
+
with open(self.config_path) as stream:
|
|
396
|
+
self._config_text = stream.read()
|
|
397
|
+
except Exception as e:
|
|
398
|
+
_logger.error(
|
|
399
|
+
f"Failed to read '{self.config_path}' with both UTF-8 and system default encoding. "
|
|
400
|
+
f"The file may be corrupt or in an unsupported format. Final error: {e}"
|
|
401
|
+
)
|
|
402
|
+
raise RuntimeError("Unable to read configuration file.") from e
|
|
389
403
|
|
|
390
404
|
@property
|
|
391
405
|
def cognite_client(self) -> CogniteClient | None:
|
{cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/exceptions.py
RENAMED
|
@@ -25,7 +25,7 @@ class InvalidConfigError(Exception):
|
|
|
25
25
|
* Unknown fields
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
|
-
def __init__(self, message: str, details: list[str] | None = None):
|
|
28
|
+
def __init__(self, message: str, details: list[str] | None = None) -> None:
|
|
29
29
|
super().__init__()
|
|
30
30
|
self.message = message
|
|
31
31
|
self.details = details
|
{cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/metrics.py
RENAMED
|
@@ -67,7 +67,7 @@ _metrics_singularities = {}
|
|
|
67
67
|
T = TypeVar("T")
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def safe_get(cls: type[T], *args: Any, **kwargs: Any) -> T:
|
|
70
|
+
def safe_get(cls: type[T], *args: Any, **kwargs: Any) -> T: # noqa: ANN401
|
|
71
71
|
"""
|
|
72
72
|
A factory for instances of metrics collections.
|
|
73
73
|
|
|
@@ -122,7 +122,7 @@ class BaseMetrics:
|
|
|
122
122
|
process_scrape_interval: Interval (in seconds) between each fetch of data for the ``process_*`` gauges
|
|
123
123
|
"""
|
|
124
124
|
|
|
125
|
-
def __init__(self, extractor_name: str, extractor_version: str, process_scrape_interval: float = 15):
|
|
125
|
+
def __init__(self, extractor_name: str, extractor_version: str, process_scrape_interval: float = 15) -> None:
|
|
126
126
|
extractor_name = extractor_name.strip().replace(" ", "_")
|
|
127
127
|
|
|
128
128
|
self.startup = Gauge(f"{extractor_name}_start_time", "Timestamp (seconds) of when the extractor last started")
|
|
@@ -187,7 +187,7 @@ class AbstractMetricsPusher(ABC):
|
|
|
187
187
|
push_interval: int | None = None,
|
|
188
188
|
thread_name: str | None = None,
|
|
189
189
|
cancellation_token: CancellationToken | None = None,
|
|
190
|
-
):
|
|
190
|
+
) -> None:
|
|
191
191
|
self.push_interval = push_interval
|
|
192
192
|
self.thread_name = thread_name
|
|
193
193
|
|
|
@@ -274,7 +274,7 @@ class PrometheusPusher(AbstractMetricsPusher):
|
|
|
274
274
|
password: str | None = None,
|
|
275
275
|
thread_name: str | None = None,
|
|
276
276
|
cancellation_token: CancellationToken | None = None,
|
|
277
|
-
):
|
|
277
|
+
) -> None:
|
|
278
278
|
super().__init__(push_interval, thread_name, cancellation_token)
|
|
279
279
|
|
|
280
280
|
self.username = username
|
|
@@ -283,7 +283,9 @@ class PrometheusPusher(AbstractMetricsPusher):
|
|
|
283
283
|
|
|
284
284
|
self.url = url
|
|
285
285
|
|
|
286
|
-
def _auth_handler(
|
|
286
|
+
def _auth_handler(
|
|
287
|
+
self, url: str, method: str, timeout: int, headers: list[tuple[str, str]], data: bytes
|
|
288
|
+
) -> Callable[[], None]:
|
|
287
289
|
"""
|
|
288
290
|
Returns a authentication handler against the Prometheus Pushgateway to use in the pushadd_to_gateway method.
|
|
289
291
|
|
|
@@ -350,7 +352,7 @@ class CognitePusher(AbstractMetricsPusher):
|
|
|
350
352
|
data_set: EitherId | None = None,
|
|
351
353
|
thread_name: str | None = None,
|
|
352
354
|
cancellation_token: CancellationToken | None = None,
|
|
353
|
-
):
|
|
355
|
+
) -> None:
|
|
354
356
|
super().__init__(push_interval, thread_name, cancellation_token)
|
|
355
357
|
|
|
356
358
|
self.cdf_client = cdf_client
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# ruff: noqa: ANN401
|
|
2
|
+
# TODO: the state stores should be generic over the type of state, not just Any.
|
|
3
|
+
|
|
1
4
|
# Copyright 2020 Cognite AS
|
|
2
5
|
#
|
|
3
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -66,7 +69,7 @@ class AbstractStateStore(_BaseStateStore, ABC):
|
|
|
66
69
|
trigger_log_level: str = "DEBUG",
|
|
67
70
|
thread_name: str | None = None,
|
|
68
71
|
cancellation_token: CancellationToken | None = None,
|
|
69
|
-
):
|
|
72
|
+
) -> None:
|
|
70
73
|
super().__init__(
|
|
71
74
|
save_interval=save_interval,
|
|
72
75
|
trigger_log_level=trigger_log_level,
|
|
@@ -249,7 +252,7 @@ class RawStateStore(AbstractStateStore):
|
|
|
249
252
|
trigger_log_level: str = "DEBUG",
|
|
250
253
|
thread_name: str | None = None,
|
|
251
254
|
cancellation_token: CancellationToken | None = None,
|
|
252
|
-
):
|
|
255
|
+
) -> None:
|
|
253
256
|
super().__init__(save_interval, trigger_log_level, thread_name, cancellation_token)
|
|
254
257
|
|
|
255
258
|
self._cdf_client = cdf_client
|
|
@@ -395,7 +398,7 @@ class LocalStateStore(AbstractStateStore):
|
|
|
395
398
|
trigger_log_level: str = "DEBUG",
|
|
396
399
|
thread_name: str | None = None,
|
|
397
400
|
cancellation_token: CancellationToken | None = None,
|
|
398
|
-
):
|
|
401
|
+
) -> None:
|
|
399
402
|
super().__init__(save_interval, trigger_log_level, thread_name, cancellation_token)
|
|
400
403
|
|
|
401
404
|
self._file_path = file_path
|
{cognite_extractor_utils-7.7.0 → cognite_extractor_utils-7.8.1}/cognite/extractorutils/threading.py
RENAMED
|
@@ -6,7 +6,7 @@ import logging
|
|
|
6
6
|
import signal
|
|
7
7
|
from threading import Condition
|
|
8
8
|
from time import time
|
|
9
|
-
from
|
|
9
|
+
from types import FrameType
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class CancellationToken:
|
|
@@ -114,7 +114,7 @@ class CancellationToken:
|
|
|
114
114
|
This will set the cancellation token instead of throwing a KeyboardInterrupt exception.
|
|
115
115
|
"""
|
|
116
116
|
|
|
117
|
-
def sigint_handler(sig_num: int, frame:
|
|
117
|
+
def sigint_handler(sig_num: int, frame: FrameType | None) -> None:
|
|
118
118
|
logger = logging.getLogger(__name__)
|
|
119
119
|
logger.warning("Interrupt signal received, stopping extractor gracefully")
|
|
120
120
|
self.cancel()
|
|
@@ -12,7 +12,7 @@ class InvalidConfigError(Exception):
|
|
|
12
12
|
* Unknown fields
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
def __init__(self, message: str, details: list[str] | None = None):
|
|
15
|
+
def __init__(self, message: str, details: list[str] | None = None) -> None:
|
|
16
16
|
super().__init__()
|
|
17
17
|
self.message = message
|
|
18
18
|
self.details = details
|
|
@@ -30,3 +30,30 @@ class InvalidConfigError(Exception):
|
|
|
30
30
|
Underlying message prefixed with 'Invalid config:'.
|
|
31
31
|
"""
|
|
32
32
|
return self.__str__()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class InvalidArgumentError(Exception):
|
|
36
|
+
"""
|
|
37
|
+
Exception thrown when an invalid argument is passed to the extractor.
|
|
38
|
+
|
|
39
|
+
This can be due to:
|
|
40
|
+
* Missing required arguments
|
|
41
|
+
* Invalid argument types
|
|
42
|
+
* Unsupported argument values
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, message: str) -> None:
|
|
46
|
+
super().__init__(message)
|
|
47
|
+
self.message = message
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
"""
|
|
51
|
+
Underlying message prefixed with 'Invalid argument:'.
|
|
52
|
+
"""
|
|
53
|
+
return f"Invalid argument: {self.message}"
|
|
54
|
+
|
|
55
|
+
def __repr__(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
Underlying message prefixed with 'Invalid argument:'.
|
|
58
|
+
"""
|
|
59
|
+
return self.__str__()
|