Repository: yt-project/yt

Issue:
load_sample: can't deal with wildcards (as yt.load)
### Bug report

This was originally reported by @chummels on Slack

**Bug summary**

Currently one isn't able to load a dataset series from yt.load_sample via wildcards (`?*`...) though arguably, it *should* be supported, by virtue of the fact `yt.load_sample` is documented as a "thin wrapper" (my own wording here) around `yt.load`

**Code for reproduction**
```python
>>> import yt
>>> yt.load_sample("enzo_tiny_cosmology/DD????/DD????")
```

**Actual outcome**

```
yt : [INFO     ] 2021-06-05 12:52:22,935 'enzo_tiny_cosmology/DD????/DD????' is not available locally. Looking up online.
yt : [INFO     ] 2021-06-05 12:52:22,935 Downloading from https://yt-project.org/data/enzo_tiny_cosmology.tar.gz
100%|███████████████████████████████████████| 439M/439M [00:00<00:00, 1.46TB/s]
yt : [INFO     ] 2021-06-05 12:53:00,224 Untaring downloaded file to '/Users/robcleme/dev/yt-project/test-data-dir'
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ <ipython-input-2-1e241a9fd52d>:1 in <module>                                                     │
│                                                                                                  │
│ /Users/robcleme/dev/yt-project/yt/yt/loaders.py:1445 in load_sample                              │
│                                                                                                  │
│   1442 │   │   loadable_path = loadable_path.joinpath(load_name, specific_file)                  │
│   1443 │                                                                                         │
│   1444 │   if specific_file and not loadable_path.exists():                                      │
│ ❱ 1445 │   │   raise ValueError(f"Could not find file '{loadable_path}'.")                       │
│   1446 │                                                                                         │
│   1447 │   return load(loadable_path, **kwargs)                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Could not find file '/Users/robcleme/dev/yt-project/test-data-dir/enzo_tiny_cosmology/DD????/DD????'.
```

**Expected outcome**
Since the downloading part isn't faulty, it is already possible to load the data series on the main branch as
```python
>>> import yt
>>> yt.load_sample("enzo_tiny_cosmology")
>>> yt.load("enzo_tiny_cosmology/DD????/DD????")
<yt.data_objects.time_series.DatasetSeries object at 0x102c29f10>
```
The output should be the same by just running `yt.load_sample`.
I expect the fix to be pretty simple, but I'm sitting on multiple cucurrent patches for load_sample right now so  figured I'd better report and come back later with the actual fix.


Discussion:

Resolving patch:
diff --git a/yt/loaders.py b/yt/loaders.py
--- a/yt/loaders.py
+++ b/yt/loaders.py
@@ -1387,11 +1387,7 @@ def load_sample(
     except IndexError as err:
         raise KeyError(f"Could not find '{fn}' in the registry.") from err
 
-    load_name = specific_file or specs["load_name"]
-    if not load_name:
-        raise ValueError(
-            "Missing a 'load_name' entry for this dataset. This may be fixed by requesting the full path of the loadable file."
-        )
+    load_name = specific_file or specs["load_name"] or ""
 
     if not isinstance(specs["load_kwargs"], dict):
         raise ValueError(
@@ -1406,12 +1402,11 @@ def load_sample(
     save_dir = _get_test_data_dir_path()
 
     data_path = save_dir.joinpath(fn)
-    if data_path.exists():
+    if save_dir.joinpath(topdir).exists():
         # if the data is already available locally, `load_sample`
         # only acts as a thin wrapper around `load`
-        appendum = specific_file or specs["load_name"]
-        if appendum not in str(data_path):
-            data_path = data_path.joinpath(appendum)
+        if load_name not in str(data_path):
+            data_path = data_path.joinpath(load_name)
         mylog.info("Sample dataset found in '%s'", data_path)
         if timeout is not None:
             mylog.info("Ignoring the `timeout` keyword argument received.")
@@ -1443,10 +1438,7 @@ def load_sample(
         os.replace(tmp_file, save_dir)
 
     loadable_path = Path.joinpath(save_dir, fn)
-    if not specs["load_name"] in str(loadable_path):
-        loadable_path = loadable_path.joinpath(specs["load_name"], specific_file)
-
-    if specific_file and not loadable_path.exists():
-        raise ValueError(f"Could not find file '{loadable_path}'.")
+    if load_name not in str(loadable_path):
+        loadable_path = loadable_path.joinpath(load_name, specific_file)
 
     return load(loadable_path, **kwargs)


Test patch: