Skip to content

Commit a115947

Browse files
committed
incremental fixes
1 parent 0745d0d commit a115947

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ select = [
182182
"C90", # mccabe
183183
"UP", # pyupgrade
184184
"T20", # flake8-print
185+
"TC004", # flake8-type-checking
186+
"TC005", # flake8-type-checking
185187
"RUF100", # unused-noqa
186188

187189
# tryceratops

wandb/apis/public/jobs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ def create(
743743
template_variables: Optional dictionary for template variables
744744
used in the resource configuration.
745745
"""
746+
from wandb.apis.public import Api
747+
746748
public_api = Api()
747749
return public_api.create_run_queue(
748750
name, resource, entity, prioritization_mode, config, template_variables

wandb/automations/_filters/run_states.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class StateFilter(GQLBase): # from: RunStateFilter
3535

3636
@property
3737
def event_type(self) -> EventType:
38+
from wandb.automations import EventType
39+
3840
return EventType.RUN_STATE
3941

4042
@field_validator("states", mode="after")

wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def load_file(
130130
closed when the artifact download completes. If this is `None`,
131131
download the file serially.
132132
"""
133+
from requests import HTTPError
134+
133135
if dest_path is not None:
134136
self._cache._override_cache_path = dest_path
135137

@@ -172,7 +174,7 @@ def fetch_fresh_url() -> str:
172174
# Serial download
173175
try:
174176
response = self._session.get(url, stream=True)
175-
except requests.HTTPError:
177+
except HTTPError:
176178
# Signed URL might have expired, fall back to fetching it one by one.
177179
manifest_entry._download_url = None
178180

wandb/sdk/lib/gitlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Repo,
1717
)
1818
except ImportError:
19-
Repo = None # type: ignore
19+
pass
2020

2121
if TYPE_CHECKING:
2222
from git import Repo
@@ -45,7 +45,9 @@ def __init__(
4545

4646
def _init_repo(self) -> Repo | None:
4747
self._repo_initialized = True
48-
if Repo is None:
48+
try:
49+
from git import Repo
50+
except ImportError:
4951
return None
5052
if self.remote_name is None:
5153
return None

wandb/sdk/wandb_init.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import tempfile
2323
import time
2424
from collections.abc import Iterable, Iterator, Sequence
25-
from typing import TYPE_CHECKING
2625

2726
from typing_extensions import Any, Literal, Protocol, Self
2827

@@ -49,9 +48,6 @@
4948
from .wandb_run import Run, TeardownHook, TeardownStage
5049
from .wandb_settings import Settings
5150

52-
if TYPE_CHECKING:
53-
import wandb.jupyter
54-
5551

5652
def _huggingface_version() -> str | None:
5753
if "transformers" in sys.modules:

wandb/sdk/wandb_run.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@
9696

9797
import torch # type: ignore [import-not-found]
9898

99-
import wandb.sdk.backend.backend
100-
import wandb.sdk.interface.interface_queue
10199
from wandb.apis.public import Api as PublicApi
102100
from wandb.proto.wandb_internal_pb2 import (
103101
GetSummaryResponse,
104102
InternalMessagesResponse,
105103
SampledHistoryResponse,
106104
)
107-
from wandb.sdk.artifacts.artifact import Artifact
108105

106+
from .artifacts.artifact import Artifact
107+
from .backend.backend import Backend
108+
from .interface.interface_queue import InterfaceQueue
109109
from .wandb_settings import Settings
110110

111111
class GitSourceDict(TypedDict):
@@ -526,8 +526,8 @@ class Run:
526526

527527
_teardown_hooks: list[TeardownHook]
528528

529-
_backend: wandb.sdk.backend.backend.Backend | None
530-
_internal_run_interface: wandb.sdk.interface.interface_queue.InterfaceQueue | None
529+
_backend: Backend | None
530+
_internal_run_interface: InterfaceQueue | None
531531
_wl: _WandbSetup | None
532532

533533
_out_redir: redirect.RedirectBase | None
@@ -1619,13 +1619,10 @@ def _tensorboard_callback(
16191619
def _set_library(self, library: _WandbSetup) -> None:
16201620
self._wl = library
16211621

1622-
def _set_backend(self, backend: wandb.sdk.backend.backend.Backend) -> None:
1622+
def _set_backend(self, backend: Backend) -> None:
16231623
self._backend = backend
16241624

1625-
def _set_internal_run_interface(
1626-
self,
1627-
interface: wandb.sdk.interface.interface_queue.InterfaceQueue,
1628-
) -> None:
1625+
def _set_internal_run_interface(self, interface: InterfaceQueue) -> None:
16291626
self._internal_run_interface = interface
16301627

16311628
def _set_teardown_hooks(self, hooks: list[TeardownHook]) -> None:

0 commit comments

Comments
 (0)