Repository: deepchecks/deepchecks

Issue:
[BUG][CV] example code is not tested on gpu
**Describe the bug**
Example code is tested only on cpu. If it was tested on gpu, we would have noticed that the line:
`result = suite.run(training_data, val_data, model, device)
`
In plot_detection_tutorial places the device in the wrong place / without a keyname.

**To Reproduce**
Run plot_detection_tutorial  on gpu



Discussion:
imo it's not that the examples should run on the GPU, but the suites tests should run on GPU. 
I think @JKL98ISR has already fixed that. correct?

Resolving patch:
diff --git a/docs/source/tutorials/vision/plot_classification_tutorial.py b/docs/source/tutorials/vision/plot_classification_tutorial.py
--- a/docs/source/tutorials/vision/plot_classification_tutorial.py
+++ b/docs/source/tutorials/vision/plot_classification_tutorial.py
@@ -262,7 +262,7 @@ def infer_on_batch(self, batch, model, device):
 from deepchecks.vision.suites import full_suite
 
 suite = full_suite()
-result = suite.run(training_data, val_data, model, device)
+result = suite.run(training_data, val_data, model, device=device)
 
 #%%
 # Observing the results:
diff --git a/docs/source/tutorials/vision/plot_detection_tutorial.py b/docs/source/tutorials/vision/plot_detection_tutorial.py
--- a/docs/source/tutorials/vision/plot_detection_tutorial.py
+++ b/docs/source/tutorials/vision/plot_detection_tutorial.py
@@ -320,8 +320,8 @@ def infer_on_batch(self, batch, model, device):
 training_data = TomatoData(data_loader=train_loader, label_map=LABEL_MAP)
 val_data = TomatoData(data_loader=val_loader, label_map=LABEL_MAP)
 
-training_data.validate_format(model)
-val_data.validate_format(model)
+training_data.validate_format(model, device=device)
+val_data.validate_format(model, device=device)
 
 # And observe the output:
 
@@ -334,7 +334,7 @@ def infer_on_batch(self, batch, model, device):
 from deepchecks.vision.suites import full_suite
 
 suite = full_suite()
-result = suite.run(training_data, val_data, model, device)
+result = suite.run(training_data, val_data, model, device=device)
 
 #%%
 # Observing the results:


Test patch:
diff --git a/tests/vision/docs/test_plots.py b/tests/vision/docs/test_plots.py
new file mode 100644
--- /dev/null
+++ b/tests/vision/docs/test_plots.py
@@ -0,0 +1,34 @@
+# ----------------------------------------------------------------------------
+# Copyright (C) 2021 Deepchecks (https://www.deepchecks.com)
+#
+# This file is part of Deepchecks.
+# Deepchecks is distributed under the terms of the GNU Affero General
+# Public License (version 3 or later).
+# You should have received a copy of the GNU Affero General Public License
+# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
+# ----------------------------------------------------------------------------
+#
+from pathlib import Path
+from runpy import run_path
+
+import torch
+import wandb
+
+# Since we have a plot that's calling `wandb.login` we need to setup first
+wandb.setup(wandb.Settings(mode="disabled", program=__name__, program_relpath=__name__, disable_code=True))
+
+DOCS_COMPILED_DIR = 'examples'
+
+
+def test_plots_on_gpu():
+    """If there is GPU available running all the docs plot files. Only makes sure the plots don't crash, and not \
+    testing any other display or functionality."""
+    if torch.cuda.is_available():
+        path = Path(__file__).parent.parent.parent.parent / "docs" / "source"
+
+        # Take only source file and excluding compiled files
+        source_files = set(path.glob("**/plot_*.py")) - set(path.glob(f"**/{DOCS_COMPILED_DIR}/plot_*.py"))
+        if not source_files:
+            raise ValueError("No plots found in docs/source")
+        for file in source_files:
+            run_path(str(file))