Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Dedden committed Apr 3, 2024
1 parent 93fe171 commit 180aed7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions dask_kubernetes/operator/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from contextlib import suppress
from datetime import datetime
from uuid import uuid4
from typing import Final, Any

import aiohttp
import dask.config
Expand All @@ -26,18 +27,18 @@
)
from dask_kubernetes.operator.networking import get_scheduler_address

_ANNOTATION_NAMESPACES_TO_IGNORE = (
_ANNOTATION_NAMESPACES_TO_IGNORE: Final[tuple[str, ...]] = (
"kopf.zalando.org",
"kubectl.kubernetes.io",
)
_LABEL_NAMESPACES_TO_IGNORE = ()
_LABEL_NAMESPACES_TO_IGNORE: Final[tuple[str, ...]] = ()

KUBERNETES_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
KUBERNETES_DATETIME_FORMAT: Final[str] = "%Y-%m-%dT%H:%M:%SZ"

DASK_AUTOSCALER_COOLDOWN_UNTIL_ANNOTATION = "kubernetes.dask.org/cooldown-until"
DASK_AUTOSCALER_COOLDOWN_UNTIL_ANNOTATION: Final[str] = "kubernetes.dask.org/cooldown-until"

# Load operator plugins from other packages
PLUGINS = []
PLUGINS: list[Any] = []
for ep in entry_points(group="dask_operator_plugin"):
with suppress(AttributeError, ImportError):
PLUGINS.append(ep.load())
Expand All @@ -47,7 +48,7 @@ class SchedulerCommError(Exception):
"""Raised when unable to communicate with a scheduler."""


def _get_annotations(meta):
def _get_annotations(meta) -> dict[str, str]:
return {
annotation_key: annotation_value
for annotation_key, annotation_value in meta.annotations.items()
Expand Down
9 changes: 5 additions & 4 deletions dask_kubernetes/operator/controller/tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pathlib
from contextlib import asynccontextmanager
from datetime import datetime, timedelta
from typing import Final

import dask.config
import pytest
Expand All @@ -18,11 +19,11 @@
get_job_runner_pod_name,
)

DIR = pathlib.Path(__file__).parent.absolute()
DIR: Final[pathlib.Path] = pathlib.Path(__file__).parent.absolute()

_EXPECTED_ANNOTATIONS = {"test-annotation": "annotation-value"}
_EXPECTED_LABELS = {"test-label": "label-value"}
DEFAULT_CLUSTER_NAME = "simple"
_EXPECTED_ANNOTATIONS: Final[dict[str, str]] = {"test-annotation": "annotation-value"}
_EXPECTED_LABELS: Final[dict[str, str]] = {"test-label": "label-value"}
DEFAULT_CLUSTER_NAME: Final[str] = "simple"


@pytest.fixture()
Expand Down

0 comments on commit 180aed7

Please sign in to comment.