Repository: huggingface/transformers

Issue:
WANDB_DISABLED env variable not working as expected
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.2.1
- Platform: Linux-5.4.34-1-pve-x86_64-with-glibc2.10
- Python version: 3.8.5
- PyTorch version (GPU?): 1.7.0 (False)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@sgugger
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

 albert, bert, GPT2, XLM: @LysandreJik
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Speed and Memory Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 TextGeneration: @TevenLeScao
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten @TevenLeScao
 Blenderbot: @patrickvonplaten
 Bart: @patrickvonplaten
 Marian: @patrickvonplaten
 Pegasus: @patrickvonplaten
 mBART: @patrickvonplaten
 T5: @patrickvonplaten
 Longformer/Reformer: @patrickvonplaten
 TransfoXL/XLNet: @TevenLeScao
 RAG: @patrickvonplaten, @lhoestq
 FSMT: @stas00
 examples/seq2seq: @patil-suraj
 examples/bert-loses-patience: @JetRunner
 ray/raytune: @richardliaw @amogkam
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->

## Information

Model I am using (Bert, XLNet ...): Bert

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

I'm using modified scripts, but the error is related to a specific function in the `integrations.py` module, as explained below.

The tasks I am working on is:
* [x] an official GLUE/SQUaD task: SQUaD
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Make sure that `wandb` is installed on your system and set the environment variable `WANDB_DISABLED` to "true", which should entirely disable `wandb` logging
2. Create an instance of the `Trainer` class
3. Observe that the Trainer always reports the error "WandbCallback requires wandb to be installed. Run `pip install wandb`."

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

I would have expected to disable `wandb`, but instead setting the `WANDB_DISABLED` environment variable completely prevents the user from using `wandb`.

After a bit of digging in the source code, I discovered that the `Trainer` uses the `WandbCallback` class (in `integrations.py`) to handle `wandb` logging. In that class, the `__init__` method has the following lines:

```python
has_wandb = is_wandb_available()
assert has_wandb, "WandbCallback requires wandb to be installed. Run `pip install wandb`."
```

In particular, by checking the `is_wandb_available()` function, we can see that it performs the following check:
```python
if os.getenv("WANDB_DISABLED"):
        return False
```

That if statement does not seem to be correct, since environment variables are stored as strings and the truth value of a string depends on whether it is empty or not. So, for example, by not setting the `WANDB_DISABLED` variable at all, then `wandb` would be enabled, but setting it to any value would entirely disable `wandb`.


Discussion:

Resolving patch:
diff --git a/src/transformers/integrations.py b/src/transformers/integrations.py
--- a/src/transformers/integrations.py
+++ b/src/transformers/integrations.py
@@ -54,7 +54,7 @@
 
 # Integration functions:
 def is_wandb_available():
-    if os.getenv("WANDB_DISABLED"):
+    if os.getenv("WANDB_DISABLED", "").upper() in ENV_VARS_TRUE_VALUES:
         return False
     return importlib.util.find_spec("wandb") is not None
 
diff --git a/src/transformers/training_args.py b/src/transformers/training_args.py
--- a/src/transformers/training_args.py
+++ b/src/transformers/training_args.py
@@ -106,7 +106,7 @@ class TrainingArguments:
         learning_rate (:obj:`float`, `optional`, defaults to 5e-5):
             The initial learning rate for :class:`~transformers.AdamW` optimizer.
         weight_decay (:obj:`float`, `optional`, defaults to 0):
-            The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in 
+            The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in
             :class:`~transformers.AdamW` optimizer.
         adam_beta1 (:obj:`float`, `optional`, defaults to 0.9):
             The beta1 hyperparameter for the :class:`~transformers.AdamW` optimizer.


Test patch: