Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 2, 2023
1 parent ecf0836 commit 7015345
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 1 addition & 3 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ def _f(**kwargs: Any) -> Config:
platform_api=platform_api_config,
platform_config=platform_config,
s3=s3_config,
logs=LogsConfig(
storage_type=LogsStorageType.S3, cleanup_interval_sec=0.5
),
logs=LogsConfig(storage_type=LogsStorageType.S3, cleanup_interval_sec=0.5),
kube=kube_config,
registry=registry_config,
container_runtime=container_runtime_config,
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/conftest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ async def _wait_for_platform_api_config(
) -> None:
while True:
import warnings

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
try:
async with create_platform_api_client(
platform_api_config.url, platform_api_config.token
platform_api_config.url, platform_api_config.token
):
return
except Exception:
Expand Down
1 change: 0 additions & 1 deletion tests/integration/conftest_kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@


class MyKubeClient(KubeClient):

# TODO (A Yushkovskiy, 30-May-2019) delete pods automatically

async def create_pod(self, job_pod_descriptor: dict[str, Any]) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ async def test_attach_forbidden(
async with client.ws_connect(url):
pass
except WSServerHandshakeError as e:
assert e.headers and e.headers.get("X-Error")
assert e.headers
assert e.headers.get("X-Error")
assert e.message == "Invalid response status"
assert e.status == HTTPUnauthorized.status_code

Expand Down Expand Up @@ -1401,7 +1402,6 @@ async def test_kill(
jobs_client: JobsClient,
infinite_job: str,
) -> None:

headers = jobs_client.headers

url = monitoring_api.generate_kill_url(infinite_job)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_jobs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ async def test_save_commit_fails_with_exception(

async def test_get_available_jobs_count(self, jobs_service: JobsService) -> None:
result = await jobs_service.get_available_jobs_counts()
assert result and "cpu-small" in result
assert result
assert "cpu-small" in result

async def test_mark_logs_dropped(
self,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from contextlib import AbstractAsyncContextManager
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any, Union
from typing import Any
from unittest import mock
from uuid import uuid4

Expand Down Expand Up @@ -1189,7 +1189,7 @@ async def stop_func() -> bool:
def run_log_reader(
name: str, delay: float = 0, timeout_s: float = 60.0
) -> None:
async def coro() -> Union[bytes, Exception]:
async def coro() -> bytes | Exception:
await asyncio.sleep(delay)
try:
async with timeout(timeout_s):
Expand Down Expand Up @@ -1271,7 +1271,7 @@ async def stop_func() -> bool:
def run_log_reader(
name: str, delay: float = 0, timeout_s: float = 60.0
) -> None:
async def coro() -> Union[bytes, Exception]:
async def coro() -> bytes | Exception:
await asyncio.sleep(delay)
try:
async with timeout(timeout_s):
Expand Down Expand Up @@ -1358,7 +1358,7 @@ async def stop_func() -> bool:
def run_log_reader(
name: str, delay: float = 0, timeout_s: float = 60.0
) -> None:
async def coro() -> Union[bytes, Exception]:
async def coro() -> bytes | Exception:
await asyncio.sleep(delay)
try:
async with timeout(timeout_s):
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_logs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from collections.abc import AsyncIterator, Callable, Sequence
from datetime import datetime, timezone, timedelta
from datetime import datetime, timedelta, timezone
from typing import Any
from unittest import mock

Expand Down Expand Up @@ -37,19 +37,19 @@ def setup_s3_key_content(
s3_client: mock.Mock,
) -> Callable[[dict[str, list[str]]], None]:
def _setup(content: dict[str, list[str]]) -> None:
async def get_object(
Key: str, *args: Any, **kwargs: Any
) -> dict[str, Any]:
async def get_object(Key: str, *args: Any, **kwargs: Any) -> dict[str, Any]:
async def _iter() -> AsyncIterator[str]:
for line in content[Key]:
yield line

body = mock.AsyncMock()
body.iter_lines = mock.MagicMock()
body.iter_lines.return_value = mock.AsyncMock()
body.iter_lines.return_value.__aiter__.side_effect = _iter
return {"ContentType": "", "Body": body}

s3_client.get_object = get_object

return _setup

@pytest.fixture
Expand Down Expand Up @@ -100,6 +100,7 @@ async def test_iterate_log_chunks(

def later_iso(sec: int = 0) -> str:
return (now + timedelta(seconds=sec)).isoformat()

stored_lines = []
for i, line in enumerate(log_lines):
stored_line = {"time": later_iso(i)}
Expand Down

0 comments on commit 7015345

Please sign in to comment.