Repository: pykeen/pykeen
Issue: UnpicklingError with PyTorch 2.6+ due to PosixPath
Root cause: External Dependency Breakage

### Describe the bug

It looks like in PyKEEN 1.11.0 the cached datasets have a pickled `PosixPath`, which causes an `UnpicklingError`. (See the repro.) If I allow `PosixPath`, the dataset gets loaded fine:
```python
from pykeen.datasets.utils import get_dataset
import pathlib
import torch
with torch.serialization.safe_globals([pathlib.PosixPath]):
    dataset = get_dataset(dataset="Nations")
dataset
```
I expect the PosixPath could be relatively easily replaced with a plain string to avoid this issue. This would be safer than setting `weights_only=False`.

I've tried a few datasets and had the same issue with them all.

### How to reproduce

```python
from pykeen.datasets.utils import get_dataset
dataset = get_dataset(dataset="Nations")
```
This works the first time, when the dataset is not cached. It fails the second time:
```python-console
>>> from pykeen.datasets.utils import get_dataset
>>> dataset = get_dataset(dataset="Nations")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "python3.11/site-packages/pykeen/datasets/utils.py", line 136, in get_dataset
    return _cached_get_dataset(dataset, dataset_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/pykeen/datasets/utils.py", line 223, in _cached_get_dataset
    dataset_cls.from_directory_binary(path),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/pykeen/datasets/base.py", line 259, in from_directory_binary
    tfs[key] = cls.triples_factory_cls.from_path_binary(path=tf_path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/pykeen/triples/triples_factory.py", line 732, in from_path_binary
    return cls(**cls._from_path_binary(path=path))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/pykeen/triples/triples_factory.py", line 1023, in _from_path_binary
    data = super()._from_path_binary(path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/pykeen/triples/triples_factory.py", line 740, in _from_path_binary
    data = dict(torch.load(path.joinpath(cls.base_file_name)))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "python3.11/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL pathlib.PosixPath was not an allowed global by default. Please use `torch.serialization.add_safe_globals([PosixPath])` or the `torch.serialization.safe_globals([PosixPath])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.
```

### Environment

| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Linux                    |
| Release         | 6.8.0-52-generic         |
| Time            | Tue Apr  8 09:57:16 2025 |
| Python          | 3.11.10                  |
| PyKEEN          | 1.11.0                   |
| PyKEEN Hash     | 2bb2d1d3                 |
| PyTorch         | 2.6.0+cu124              |
| CUDA Available? | true                     |
| CUDA Version    | 12.4                     |
| cuDNN Version   | 90100                    |

### Additional information

_No response_

### Issue Template Checks

- [x] This is not a feature request (use a different issue template if it is)
- [x] This is not a question (use the [discussions](https://github.com/pykeen/pykeen/discussions/new) forum instead)
- [x] I've read the text explaining why including environment information is important and understand if I omit this information that my issue will be dismissed

Hey @darabos , thanks for your report.

This should be "fixed" by (the yet unreleased) https://github.com/pykeen/pykeen/pull/1494, using `weights_only=False`. Until our next release, you can install from source, cf. https://github.com/pykeen/pykeen?tab=readme-ov-file#installation--

We also currently support user-provided metadata dictionaries, and have so far allowed arbitrary Python dictionaries (as long as they are `torch.save`able). We are also considering restricting the metadata to a JSON-compliant dictionary, rather than allowing arbitrary Python dictionaries. This would allow it to be stored in JSON format, which makes it easier to inspect as a file.

@darabos we've released a new version of PyKEEN v1.11.1 that includes the fix Max mentioned above, can you confirm it addresses your issue?

> [@darabos](https://github.com/darabos) we've releases a new version of PyKEEN v1.11.1 that includes the fix Max mentioned above, can you confirm it addresses your issue?

Confirmed! It's all good on 1.11.1. Thank you!!!