Unverified Commit edcb3ac5 authored by Boris Dayma's avatar Boris Dayma Committed by GitHub
Browse files

refactor(wandb): consolidate import (#5044)

parent 9e033649
...@@ -21,7 +21,7 @@ from tqdm.auto import tqdm, trange ...@@ -21,7 +21,7 @@ from tqdm.auto import tqdm, trange
from .data.data_collator import DataCollator, default_data_collator from .data.data_collator import DataCollator, default_data_collator
from .modeling_utils import PreTrainedModel from .modeling_utils import PreTrainedModel
from .optimization import AdamW, get_linear_schedule_with_warmup from .optimization import AdamW, get_linear_schedule_with_warmup
from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, PredictionOutput, TrainOutput from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, PredictionOutput, TrainOutput, is_wandb_available
from .training_args import TrainingArguments, is_torch_tpu_available from .training_args import TrainingArguments, is_torch_tpu_available
...@@ -59,22 +59,9 @@ def is_tensorboard_available(): ...@@ -59,22 +59,9 @@ def is_tensorboard_available():
return _has_tensorboard return _has_tensorboard
try: if is_wandb_available():
import wandb import wandb
wandb.ensure_configured()
if wandb.api.api_key is None:
_has_wandb = False
wandb.termwarn("W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable.")
else:
_has_wandb = False if os.getenv("WANDB_DISABLED") else True
except (ImportError, AttributeError):
_has_wandb = False
def is_wandb_available():
return _has_wandb
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
...@@ -10,26 +10,13 @@ import tensorflow as tf ...@@ -10,26 +10,13 @@ import tensorflow as tf
from .modeling_tf_utils import TFPreTrainedModel from .modeling_tf_utils import TFPreTrainedModel
from .optimization_tf import GradientAccumulator, create_optimizer from .optimization_tf import GradientAccumulator, create_optimizer
from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, PredictionOutput from .trainer_utils import PREFIX_CHECKPOINT_DIR, EvalPrediction, PredictionOutput, is_wandb_available
from .training_args_tf import TFTrainingArguments from .training_args_tf import TFTrainingArguments
try: if is_wandb_available():
import wandb import wandb
wandb.ensure_configured()
if wandb.api.api_key is None:
_has_wandb = False
wandb.termwarn("W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable.")
else:
_has_wandb = False if os.getenv("WANDB_DISABLED") else True
except (ImportError, AttributeError):
_has_wandb = False
def is_wandb_available():
return _has_wandb
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
import os
from typing import Dict, NamedTuple, Optional from typing import Dict, NamedTuple, Optional
import numpy as np import numpy as np
try:
import wandb
wandb.ensure_configured()
if wandb.api.api_key is None:
_has_wandb = False
wandb.termwarn("W&B installed but not logged in. Run `wandb login` or set the WANDB_API_KEY env variable.")
else:
_has_wandb = False if os.getenv("WANDB_DISABLED") else True
except (ImportError, AttributeError):
_has_wandb = False
def is_wandb_available():
return _has_wandb
class EvalPrediction(NamedTuple): class EvalPrediction(NamedTuple):
""" """
Evaluation output (always contains labels), to be used Evaluation output (always contains labels), to be used
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment