Commit 242d4d1a authored by Boris Dayma's avatar Boris Dayma
Browse files

fix(wandb): use is_wandb_available function in callbacks

parent 006929eb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@ Callback functions that can be invoked while fitting a KerasModel.
import tensorflow as tf
import sys

from deepchem.models.keras_model import is_wandb_available
if is_wandb_available():
  import wandb


class ValidationCallback(object):
  """Performs validation while training a KerasModel.
+5 −2
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@ try:
except (ImportError, AttributeError):
  _has_wandb = False

def is_wandb_available():
  return _has_wandb

class KerasModel(Model):
  """This is a DeepChem model implemented by a Keras model.

@@ -166,12 +169,12 @@ class KerasModel(Model):
    self.tensorboard = tensorboard

    # W&B logging
    if wandb and not _has_wandb:
    if wandb and not is_wandb_available():
      logger.warning(
        "You set wandb to True but W&B is not installed. To use wandb logging, "
        "run `pip install wandb; wandb login` see https://docs.wandb.com/huggingface."
      )
    self.wandb = wandb and _has_wandb
    self.wandb = wandb and is_wandb_available()
    
    # Backwards compatibility
    if "tensorboard_log_frequency" in kwargs: