Repository: sktime/sktime

Issue:
[BUG] Unrelated tests failing for no reason [test_load_solar]
**Describe the bug**

In #3375 I noticed tests are failing unrelated to any code changes I made. Obviously this is a bad idea to test code that relies on external services being up and running. This has little to do with sktime and should probably be removed. 

```
FAILED sktime/datasets/tests/test_data_io.py::test_load_solar[False] - urllib.error.HTTPError: HTTP Error 504: Gateway Time-out
FAILED sktime/datasets/tests/test_data_io.py::test_load_solar[True] - urllib.error.HTTPError: HTTP Error 504: Gateway Time-out
```

see https://github.com/sktime/sktime/actions/runs/3437085117/jobs/5733604844 for more details

**To Reproduce**
<!--
Add a Minimal, Complete, and Verifiable example (for more details, see e.g. https://stackoverflow.com/help/mcve

If the code is too long, feel free to put it in a public gist and link it in the issue: https://gist.github.com
-->

```python
<Paste your code here>
```

**Expected behavior**
<!--
A clear and concise description of what you expected to happen.
-->

**Additional context**
<!--
Add any other context about the problem here.
-->

**Versions**
<details>

<!--
Please run the following code snippet and paste the output here:
 
from sktime import show_versions; show_versions()
-->

</details>

<!-- Thanks for contributing! -->



Discussion:
@ciaran-g :point_up: it seems that you've added the offending test. Any change you could refactor to not fetch from an external service and maybe use locally available data? Otherwise I would recommend removing the test entirely.
Related #3663
An option to load a local version was added in #3652, this test should probably be removed however as its only functionality is to test the external loading I think.
yes, I think we should not include this in the regular test suite, this can lead to request bombing through anyone who on a fork runs the test suite.

We could move it into a "once in a while" test or a permanent diagnostic?
I will have a look to change it today, just wondering how you would change it to a once in a while test? Are there any examples in the package already? 

Also happy to remove it since we have the local version as a backup
we removed tests based on external websites, specifically tests of load_from_ucr_tsv_to_dataframe for this very reason. I am in favour of just removing these tests. 

Resolving patch:
diff --git a/sktime/datasets/_single_problem_loaders.py b/sktime/datasets/_single_problem_loaders.py
--- a/sktime/datasets/_single_problem_loaders.py
+++ b/sktime/datasets/_single_problem_loaders.py
@@ -42,7 +42,8 @@
 ]
 
 import os
-from urllib.error import HTTPError
+from urllib.error import HTTPError, URLError
+from warnings import warn
 
 import numpy as np
 import pandas as pd
@@ -1160,23 +1161,15 @@ def load_solar(
     >>> from sktime.datasets import load_solar  # doctest: +SKIP
     >>> y = load_solar()  # doctest: +SKIP
     """
+    name = "solar"
+    fname = name + ".csv"
+    path = os.path.join(MODULE, DIRNAME, name, fname)
+    y = pd.read_csv(path, index_col=0, parse_dates=["datetime_gmt"], dtype={1: float})
+    y = y.asfreq("30T")
+    y = y.squeeze("columns")
     if api_version is None:
-        name = "solar"
-        fname = name + ".csv"
-        path = os.path.join(MODULE, DIRNAME, name, fname)
-        y = pd.read_csv(
-            path, index_col=0, parse_dates=["datetime_gmt"], dtype={1: float}
-        )
-        y = y.asfreq("30T")
-        return y.squeeze("columns")
-
-    from sktime.utils.validation._dependencies import _check_soft_dependencies
-
-    _check_soft_dependencies("backoff")
+        return y
 
-    import backoff
-
-    @backoff.on_exception(wait_gen=backoff.expo, exception=HTTPError, max_tries=5)
     def _load_solar(
         start="2021-05-01",
         end="2021-09-01",
@@ -1211,13 +1204,28 @@ def _load_solar(
             else:
                 return df["generation_mw"].rename("solar_gen")
 
-    return _load_solar(
-        start=start,
-        end=end,
-        normalise=normalise,
-        return_full_df=return_full_df,
-        api_version=api_version,
-    )
+    tries = 5
+    for i in range(tries):
+        try:
+            return _load_solar(
+                start=start,
+                end=end,
+                normalise=normalise,
+                return_full_df=return_full_df,
+                api_version=api_version,
+            )
+        except (URLError, HTTPError):
+            if i < tries - 1:
+                continue
+            else:
+                warn(
+                    """
+                    Error detected using API. Check connection, input arguments, and
+                    API status here https://www.solar.sheffield.ac.uk/pvlive/api/.
+                    Loading stored sample data instead.
+                    """
+                )
+                return y
 
 
 def load_covid_3month(split=None, return_X_y=True):


Test patch:
diff --git a/sktime/datasets/tests/test_data_io.py b/sktime/datasets/tests/test_data_io.py
--- a/sktime/datasets/tests/test_data_io.py
+++ b/sktime/datasets/tests/test_data_io.py
@@ -21,7 +21,6 @@
     load_from_long_to_dataframe,
     load_from_tsfile,
     load_from_tsfile_to_dataframe,
-    load_solar,
     load_tsf_to_dataframe,
     load_UCR_UEA_dataset,
     load_uschange,
@@ -34,7 +33,6 @@
     _load_provided_dataset,
 )
 from sktime.datatypes import MTYPE_LIST_PANEL, check_is_mtype
-from sktime.utils.validation._dependencies import _check_soft_dependencies
 
 # Disabling test for these mtypes since they don't support certain functionality yet
 _TO_DISABLE = ["pd-long", "pd-wide", "numpyflat"]
@@ -1478,23 +1476,3 @@ def test_convert_tsf_to_multiindex(freq):
         _convert_tsf_to_hierarchical(input_df, metadata, freq=freq),
         check_dtype=False,
     )
-
-
-@pytest.mark.skipif(
-    not _check_soft_dependencies("backoff", severity="none"),
-    reason="load_solar requires backoff in the environment",
-)
-@pytest.mark.parametrize("return_df", [False, True])
-def test_load_solar(return_df):
-    """Test function for loading solar data through the Sheffiled Solar API."""
-    # get static dataset
-    test_equals = load_solar(api_version=None).to_numpy()
-    # get matching data from API
-    y = load_solar(start="2021-05-01", end="2021-05-07", return_full_df=return_df)
-
-    if return_df:
-        assert isinstance(y, pd.DataFrame)
-    else:
-        assert isinstance(y, pd.Series)
-        y = y.round(5).to_numpy()
-        assert np.all(y == test_equals)