Repository: holoviz/hvplot

Issue:
sample_data try/except import wrapper fails
#### ALL software version info
hvplot: 0.7.3

#### Description of expected behavior and the observed behavior
The following import fails, despite the all-catching `except` in the code?? (Honestly stumped)

```python
from hvplot.sample_data import us_crime, airline_flights
```
```python
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_3185062/1788543639.py in <module>
----> 1 from hvplot.sample_data import us_crime, airline_flights

~/miniconda3/envs/py39/lib/python3.9/site-packages/hvplot/sample_data.py in <module>
     23 # Add catalogue entries to namespace
     24 for _c in catalogue:
---> 25     globals()[_c] = catalogue[_c]

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/base.py in __getitem__(self, key)
    398             if e.container == 'catalog':
    399                 return e(name=key)
--> 400             return e()
    401         if isinstance(key, str) and '.' in key:
    402             key = key.split('.')

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/entry.py in __call__(self, persist, **kwargs)
     75             raise ValueError('Persist value (%s) not understood' % persist)
     76         persist = persist or self._pmode
---> 77         s = self.get(**kwargs)
     78         if persist != 'never' and isinstance(s, PersistMixin) and s.has_been_persisted:
     79             from ..container.persist import store

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/local.py in get(self, **user_parameters)
    287             return self._default_source
    288 
--> 289         plugin, open_args = self._create_open_args(user_parameters)
    290         data_source = plugin(**open_args)
    291         data_source.catalog_object = self._catalog

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/local.py in _create_open_args(self, user_parameters)
    261 
    262         if len(self._plugin) == 0:
--> 263             raise ValueError('No plugins loaded for this entry: %s\n'
    264                              'A listing of installable plugins can be found '
    265                              'at https://intake.readthedocs.io/en/latest/plugin'

ValueError: No plugins loaded for this entry: parquet
A listing of installable plugins can be found at https://intake.readthedocs.io/en/latest/plugin-directory.html .
```
For reference, this is the code in 0.7.3:
```python
import os

try:
    from intake import open_catalog
except:
    raise ImportError('Loading hvPlot sample data requires intake '
                      'and intake-parquet. Install it using conda or '
                      'pip before loading data.')
```
How can intake throw a ValueError??

#### Complete, minimal, self-contained example code that reproduces the issue

* Have only the package `intake` installed, no other intake-subpackages.
* Execute : `from hvplot.sample_data import us_crime, airline_flights`

```
# code goes here between backticks
from hvplot.sample_data import us_crime, airline_flights
```

#### Stack traceback and/or browser JavaScript console output
```python
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_3185062/1788543639.py in <module>
----> 1 from hvplot.sample_data import us_crime, airline_flights

~/miniconda3/envs/py39/lib/python3.9/site-packages/hvplot/sample_data.py in <module>
     23 # Add catalogue entries to namespace
     24 for _c in catalogue:
---> 25     globals()[_c] = catalogue[_c]

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/base.py in __getitem__(self, key)
    398             if e.container == 'catalog':
    399                 return e(name=key)
--> 400             return e()
    401         if isinstance(key, str) and '.' in key:
    402             key = key.split('.')

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/entry.py in __call__(self, persist, **kwargs)
     75             raise ValueError('Persist value (%s) not understood' % persist)
     76         persist = persist or self._pmode
---> 77         s = self.get(**kwargs)
     78         if persist != 'never' and isinstance(s, PersistMixin) and s.has_been_persisted:
     79             from ..container.persist import store

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/local.py in get(self, **user_parameters)
    287             return self._default_source
    288 
--> 289         plugin, open_args = self._create_open_args(user_parameters)
    290         data_source = plugin(**open_args)
    291         data_source.catalog_object = self._catalog

~/miniconda3/envs/py39/lib/python3.9/site-packages/intake/catalog/local.py in _create_open_args(self, user_parameters)
    261 
    262         if len(self._plugin) == 0:
--> 263             raise ValueError('No plugins loaded for this entry: %s\n'
    264                              'A listing of installable plugins can be found '
    265                              'at https://intake.readthedocs.io/en/latest/plugin'

ValueError: No plugins loaded for this entry: parquet
A listing of installable plugins can be found at https://intake.readthedocs.io/en/latest/plugin-directory.html .
```
#### Additional info
The list of required package is now this:

* intake-parquet
* intake-xarray
* s3fs




Discussion:
Ah, *doh*, it's not the import fails, but the code after the import:

```python
24 for _c in catalogue:
---> 25     globals()[_c] = catalogue[_c]
```
I'm having a hard time reproducing this in a notebook due to the usage of `__file__`, would it be okay for a PR to use `importlib.resources` to find the path to the `datasets.yaml` file?
Maybe add `import intake_parquet` within the `try` section to be sure to raise the exception when that plugin is not installed?
yes, but if that trial import is acceptable (wasn't sure about performance), then I'd add intake-xarray, and s3fs as well, as those are also required? (Which makes this bug annoying as one needs to try it 3 times, before learning all those 3 missing packages.. . ;)
I would have thought those would be recursive  subdependencies, but if not, then yes, import all those in the `try` block as well. To make it fail more quickly when it will fail, the first import should be the one most likely to fail (i.e. least likely to be installed in a typical environment), which I'd guess here would be `intake_parquet`.
They seem to be independent packages:

```bash
❯ mamba info intake-xarray=0.5

intake-xarray 0.5.0 pyhd8ed1ab_0
--------------------------------
file name   : intake-xarray-0.5.0-pyhd8ed1ab_0.tar.bz2
name        : intake-xarray
version     : 0.5.0
build string: pyhd8ed1ab_0
build number: 0
channel     : https://conda.anaconda.org/conda-forge/noarch
size        : 1.4 MB
arch        : None
constrains  : ()
license     : BSD-2-Clause
license_family: BSD
md5         : 43d9d1c90da0b2b28cc16e58a52a0f2b
noarch      : python
package_type: noarch_python
platform    : None
sha256      : 91a388e5eb015b192bc17de04c55b102576d1c1b08571a80a1a9a1bc6c878f91
subdir      : noarch
timestamp   : 1616085245631
url         : https://conda.anaconda.org/conda-forge/noarch/intake-xarray-0.5.0-pyhd8ed1ab_0.tar.bz2
dependencies:
    dask >=2.2
    intake >=0.5.2
    netcdf4
    python >=3.5
    xarray >=0.12.0
    zarr
WARNING: 'conda info package_name' is deprecated.
          Use 'conda search package_name --info'.

site-packages/hvplot/examples via 🐍 v3.9.9 via 🅒 py39 took 5s 
❯ mamba search intake-parquet
Loading channels: done
# Name                       Version           Build  Channel             
intake-parquet                 0.2.1            py_0  conda-forge         
intake-parquet                 0.2.2            py_0  conda-forge         
intake-parquet                 0.2.3            py_0  conda-forge         

site-packages/hvplot/examples via 🐍 v3.9.9 via 🅒 py39 took 5s 
❯ mamba info intake-parquet=0.2.3

intake-parquet 0.2.3 py_0
-------------------------
file name   : intake-parquet-0.2.3-py_0.tar.bz2
name        : intake-parquet
version     : 0.2.3
build string: py_0
build number: 0
channel     : https://conda.anaconda.org/conda-forge/noarch
size        : 10 KB
arch        : None
constrains  : ()
license     : BSD-2-Clause
license_family: BSD
md5         : b7d04be2fb7b43946cf06dc5f7f04ad1
noarch      : python
package_type: noarch_python
platform    : None
sha256      : 2981d0998aa3e30713c6b2012a4557e77b70ed6e04778f9365c4fdeb593576ca
subdir      : noarch
timestamp   : 1573509119874
url         : https://conda.anaconda.org/conda-forge/noarch/intake-parquet-0.2.3-py_0.tar.bz2
dependencies:
    dask
    fastparquet
    intake >=0.3
    jinja2
    pandas
    pyarrow
    python >=3.5
WARNING: 'conda info package_name' is deprecated.
          Use 'conda search package_name --info'.
```
and s3fs is obviously unrelated. Will play with it and then submit a PR.
Saw the same thing in #562. 

I still feel like it is a lot to install just to run the second page in a [user guide](https://hvplot.holoviz.org/user_guide/Plotting.html). Why not just download the data with request or urllib like e.g. [bokeh](https://github.com/bokeh/bokeh/blob/branch-3.0/bokeh/util/sampledata.py) does?

Resolving patch:
diff --git a/hvplot/sample_data.py b/hvplot/sample_data.py
--- a/hvplot/sample_data.py
+++ b/hvplot/sample_data.py
@@ -6,10 +6,18 @@
 
 try:
     from intake import open_catalog
+    import intake_parquet  # noqa
+    import intake_xarray   # noqa
+    import s3fs  # noqa
 except:
-    raise ImportError('Loading hvPlot sample data requires intake '
-                      'and intake-parquet. Install it using conda or '
-                      'pip before loading data.')
+    raise ImportError(
+        """Loading hvPlot sample data requires:
+                * intake
+                * intake-parquet
+                * intake-xarray
+                * s3fs
+             Install these using conda or pip before loading data."""
+    )
 
 _file_path = os.path.dirname(__file__)
 if os.path.isdir(os.path.join(_file_path, 'examples')):


Test patch: