Skip to content

Commit 109723c

Browse files
committed
dynamic imports for log and struc
1 parent 0bfd79d commit 109723c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

chebai/loggers/custom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from datetime import datetime
33
from typing import List, Literal, Optional, Union
44

5-
import wandb
65
from lightning.fabric.utilities.types import _PATH
76
from lightning.pytorch.callbacks import ModelCheckpoint
87
from lightning.pytorch.loggers import WandbLogger
@@ -105,6 +104,8 @@ def set_fold(self, fold: int) -> None:
105104
Args:
106105
fold (int): Cross-validation fold number.
107106
"""
107+
import wandb
108+
108109
if fold != self._fold:
109110
self._fold = fold
110111
# Start new experiment

chebai/preprocessing/structures.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from typing import Any, Tuple, Union
1+
from typing import TYPE_CHECKING, Any, Tuple, Union
22

3-
import networkx as nx
43
import torch
54

5+
if TYPE_CHECKING:
6+
import networkx as nx
7+
68

79
class XYData(torch.utils.data.Dataset):
810
"""
@@ -129,6 +131,8 @@ def to_x(self, device: torch.device) -> Tuple[nx.Graph, ...]:
129131
Returns:
130132
A tuple of molecular graphs with node attributes on the specified device.
131133
"""
134+
import networkx as nx
135+
132136
l_ = []
133137
for g in self.x:
134138
graph = g.copy()

0 commit comments

Comments
 (0)