Skip to content

Commit

Permalink
mypy error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailKardash committed Mar 26, 2024
1 parent 72c7b52 commit b2a9771
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
10 changes: 4 additions & 6 deletions harness/determined/cli/proxy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations # noqa: I2041

import contextlib
import dataclasses
import io
Expand Down Expand Up @@ -185,7 +183,7 @@ def http_tunnel_listener(


@contextlib.contextmanager
def _tunnel_task(sess: api.Session, task_id: str, port_map: dict[int, int]) -> Iterator[None]:
def _tunnel_task(sess: api.Session, task_id: str, port_map: "dict[int, int]") -> Iterator[None]:
# Args:
# port_map: dict of local port => task port.
# task_id: tunneled task_id.
Expand All @@ -200,7 +198,7 @@ def _tunnel_task(sess: api.Session, task_id: str, port_map: dict[int, int]) -> I


@contextlib.contextmanager
def _tunnel_trial(sess: api.Session, trial_id: int, port_map: dict[int, int]) -> Iterator[None]:
def _tunnel_trial(sess: api.Session, trial_id: int, port_map: "dict[int, int]") -> Iterator[None]:
# TODO(DET-9000): perhaps the tunnel should be able to probe master for service status,
# instead of us explicitly polling for task/trial status.
while True:
Expand All @@ -227,7 +225,7 @@ def _tunnel_trial(sess: api.Session, trial_id: int, port_map: dict[int, int]) ->

@contextlib.contextmanager
def tunnel_experiment(
sess: api.Session, experiment_id: int, port_map: dict[int, int]
sess: api.Session, experiment_id: int, port_map: "dict[int, int]"
) -> Iterator[None]:
while True:
trials = bindings.get_GetExperimentTrials(sess, experimentId=experiment_id).trials
Expand All @@ -242,7 +240,7 @@ def tunnel_experiment(
yield


def parse_port_map_flag(publish_arg: list[str]) -> dict[int, int]:
def parse_port_map_flag(publish_arg: "list[str]") -> "dict[int, int]":
result = {} # type: dict[int, int]

for e in publish_arg:
Expand Down
2 changes: 1 addition & 1 deletion harness/determined/lightning/experimental.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# type: ignore
# type: ignore
from typing import Optional

from lightning.pytorch import utilities as ptl_utilities
Expand Down
4 changes: 2 additions & 2 deletions harness/determined/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,9 @@ def make_labels(
def convert_to_timestamp_str(timestamp: datetime.datetime) -> str:
"""
Convert a datetime.datetime object to the string format expected by the API. All timestamps
must be datetime.timezone-aware datetime.datetime.datetime.datetimes in UTC.
must be datetime.timezone-aware datetime.datetimes in UTC.
"""
# https://docs.python.org/3/library/datetime.datetime.html#determining-if-an-object-is-aware-or-naive
# https://docs.python.org/3/library/datetime.html#determining-if-an-object-is-aware-or-naive
assert (
timestamp.tzinfo is not None and timestamp.tzinfo.utcoffset(timestamp) is not None
), "All datetime.datetime objects to be serialized must be datetime.timezone aware"
Expand Down
2 changes: 1 addition & 1 deletion harness/tests/experiment/keras/test_keras_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# type: ignore
# type: ignore
from typing import Tuple

import numpy as np
Expand Down
5 changes: 1 addition & 4 deletions harness/tests/experiment/pytorch/test_pytorch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,7 @@ def test_to_device_warnings(dedup_between_calls: bool) -> None:
handler = handlers.QueueHandler(q)
logger.addHandler(handler)
try:
if dedup_between_calls:
warned_types = set() # type: ignore
else:
warned_types = None
warned_types = set() if dedup_between_calls else None # type: ignore
pytorch.to_device(["string_data", "string_data"], "cpu", warned_types) # type: ignore
pytorch.to_device(["string_data", "string_data"], "cpu", warned_types) # type: ignore

Expand Down

0 comments on commit b2a9771

Please sign in to comment.