Skip to content

Commit a618b62

Browse files
committed
chore: simplification and lint
1 parent 88b7867 commit a618b62

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

cognite/extractorutils/unstable/core/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,13 @@ def _setup_logging(self) -> None:
220220
case LogConsoleHandlerConfig() as console_handler:
221221
sh = logging.StreamHandler()
222222
sh.setFormatter(fmt)
223-
level_for_handler = _resolve_log_level(
224-
self.log_level_override if self.log_level_override else console_handler.level.value
225-
)
223+
level_for_handler = _resolve_log_level(self.log_level_override or console_handler.level.value)
226224
sh.setLevel(level_for_handler)
227225

228226
root.addHandler(sh)
229227

230228
case LogFileHandlerConfig() as file_handler:
231-
level_for_handler = _resolve_log_level(
232-
self.log_level_override if self.log_level_override else file_handler.level.value
233-
)
229+
level_for_handler = _resolve_log_level(self.log_level_override or file_handler.level.value)
234230
try:
235231
fh = RobustFileHandler(
236232
filename=file_handler.path,

cognite/extractorutils/unstable/core/runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def main() -> None:
3838
from typing import Any, Generic, TypeVar
3939
from uuid import uuid4
4040

41-
from requests.exceptions import ConnectionError as RequestsConnectionError
42-
from typing_extensions import assert_never
43-
4441
from cognite.client import CogniteClient
4542
from cognite.client.exceptions import (
4643
CogniteAPIError,
4744
CogniteAuthError,
4845
CogniteConnectionError,
4946
)
47+
from requests.exceptions import ConnectionError as RequestsConnectionError
48+
from typing_extensions import assert_never
49+
5050
from cognite.extractorutils.threading import CancellationToken
5151
from cognite.extractorutils.unstable.configuration.exceptions import InvalidArgumentError, InvalidConfigError
5252
from cognite.extractorutils.unstable.configuration.loaders import (
@@ -180,8 +180,8 @@ def _create_argparser(self) -> ArgumentParser:
180180
choices=["debug", "info", "warning", "error", "critical"],
181181
type=str,
182182
required=False,
183-
default="info",
184-
help="Set the logging level for the runtime. Default is 'info'.",
183+
default=None,
184+
help="Set the logging level for the runtime.",
185185
)
186186
argparser.add_argument(
187187
"--skip-init-checks",

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from enum import Enum
66

77
import pytest
8-
98
from cognite.client import CogniteClient
109
from cognite.client.config import ClientConfig
1110
from cognite.client.credentials import OAuthClientCredentials

tests/test_unstable/conftest.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import gzip
22
import json
33
import os
4+
from pathlib import Path
5+
import shutil
46
from collections.abc import Callable, Generator, Iterator
7+
import tempfile
58
from threading import RLock
69
from time import sleep, time
710
from typing import Any
811
from uuid import uuid4
912

1013
import pytest
1114
import requests_mock
12-
1315
from cognite.client import CogniteClient
1416
from cognite.client.config import ClientConfig
1517
from cognite.client.credentials import OAuthClientCredentials
18+
1619
from cognite.extractorutils.unstable.configuration.models import (
1720
ConnectionConfig,
1821
ExtractorConfig,
@@ -37,9 +40,29 @@ def reset_singleton() -> Iterator[None]:
3740

3841

3942
@pytest.fixture(autouse=True)
40-
def reset_environment() -> Generator[None, None, None]:
43+
def reset_environment(test_dirs: list[str]) -> Generator[None, None, None]:
4144
yield
4245
os.chdir(working_dir)
46+
# if len(test_dirs) > 0:
47+
# for tmp_dir in test_dirs:
48+
# os.chown(tmp_dir, os.getuid(), os.getgid())
49+
# shutil.rmtree(tmp_dir)
50+
51+
52+
@pytest.fixture
53+
def test_dirs() -> list[str]: # list[tuple[Path, int, int]]:
54+
return []
55+
# tmp_dir = Path(f"{tempfile.gettempdir()}/{str(uuid4())!s}")
56+
# os.mkdir(tmp_dir)
57+
# stats = os.stat(tmp_dir)
58+
# original_uid = stats.st_uid
59+
# original_gid = stats.st_gid
60+
# os.chown(tmp_dir, os.getuid(), os.getgid())
61+
#
62+
# yield (tmp_dir, original_uid, original_gid)
63+
#
64+
# os.chown(tmp_dir, original_uid, original_gid)
65+
# shutil.rmtree(tmp_dir)
4366

4467

4568
@pytest.fixture

tests/test_unstable/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from pathlib import Path
77

88
import pytest
9-
109
from cognite.client import CogniteClient
1110
from cognite.client.exceptions import CogniteNotFoundError
11+
1212
from cognite.extractorutils.statestore.watermark import LocalStateStore, RawStateStore
1313
from cognite.extractorutils.unstable.configuration.models import (
1414
ConnectionConfig,
@@ -163,7 +163,7 @@ def test_local_state_store_integration(local_state_file: Path, connection_config
163163

164164

165165
@pytest.fixture(scope="function")
166-
def raw_db_table_name() -> str:
166+
def raw_db_table_name() -> tuple[str, str]:
167167
"""Provides a unique database name for a single test function run."""
168168
test_id = random.randint(0, int(1e9))
169169
return f"test_db_{test_id}", f"test_table_{test_id}"

0 commit comments

Comments
 (0)