Repository: pykeen/pykeen
Issue: TypeError: missing required positional argument when using `CoreTriplesFactory.from_path_binary()`
Root cause: Interface Contract Mismatch

### Describe the bug

According to the [document](https://pykeen.readthedocs.io/en/stable/api/pykeen.pipeline.PipelineResult.html#pykeen.pipeline.PipelineResult.save_to_directory) about saving pipeline result to directory, it said:
> training_triples contains the training triples factory, including label-to-id mappings, if used. It has been saved via [pykeen.triples.CoreTriplesFactory.to_path_binary()](https://pykeen.readthedocs.io/en/stable/reference/triples.html#pykeen.triples.CoreTriplesFactory.to_path_binary), and can re-loaded via [pykeen.triples.CoreTriplesFactory.from_path_binary()](https://pykeen.readthedocs.io/en/stable/reference/triples.html#pykeen.triples.CoreTriplesFactory.from_path_binary).

But error occurred when I want to load the `triplets_factory` from the pipeline result saved before.

```python
triplets_factory = CoreTriplesFactory.from_path_binary('RESCAL_FB15k237/training_triples')
```

```
Traceback (most recent call last):
  File "/home/tzuwei/developing/kge-loss/main.py", line 32, in <module>
    triplets_factory = CoreTriplesFactory.from_path_binary(f'{save_path}/training_triples')
  File "/home/tzuwei/.pyenv/versions/loss/lib/python3.9/site-packages/pykeen/triples/triples_factory.py", line 816, in from_path_binary
    return cls(**cls._from_path_binary(path=path))
TypeError: __init__() missing 2 required positional arguments: 'num_entities' and 'num_relations'
```

Seems like the data return by `cls._from_path_binary` does not contain `num_entities` and `num_relations` at line 816.

https://github.com/pykeen/pykeen/blob/313055e8c846a52a35901f2746a43e5efdae1e3e/src/pykeen/triples/triples_factory.py#L793-L824

### How to reproduce

The following code can reproduce the problem on my machine

```python
from pykeen.pipeline import pipeline
from pykeen.models import RESCAL
from pykeen.datasets import FB15k237
from pykeen.triples import CoreTriplesFactory

result = pipeline(
    model=RESCAL,
    dataset=FB15k237,
)
result.save_to_directory('RESCAL_FB15k237')

triplets_factory = CoreTriplesFactory.from_path_binary('RESCAL_FB15k237/training_triples')
```

### Environment

Unable to handle parameter in CooccurrenceFilteredModel: base
| Key             | Value                    |
|-----------------|--------------------------|
| OS              | posix                    |
| Platform        | Linux                    |
| Release         | 5.15.0-52-generic        |
| Time            | Wed Dec  7 18:02:29 2022 |
| Python          | 3.9.14                   |
| PyKEEN          | 1.9.0                    |
| PyKEEN Hash     | 1f526edb                 |
| PyKEEN Branch   | master                   |
| PyTorch         | 1.13.0+cu117             |
| CUDA Available? | true                     |
| CUDA Version    | 11.7                     |
| cuDNN Version   | 8500                     |


### Additional information

Thank you for providing this open source project. Your work is very helpful to me. :smile: 


### 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

Hi @uier ,

thanks for reporting the issue. I could locally reproduce the error with the code you provided, and extract a test case from it for #1185 using a reduced setting.

@uier this seems to be resolved in #1185 now - if you already want to try it out, you can install PyKEEN from the given branch (cf. [here](https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch/24811490#24811490)):

```console
pip install https://github.com/pykeen/pykeen/archive/fix-from-path-binary.zip
```

Note that after #1185 has been merged, you would need to update to
```console
pip install git+https://github.com/pykeen/pykeen.git
```
(as explained in the repo's README).

Hi @mberr 

Thanks for fixing the bug and providing a patch. I tested it and it works for me too.

Thanks for your hard work!

@mberr 
when I make the same to load the saved train tripletfactory I get  this error. I preferred to write it here as it might be related.

```python 
Traceback (most recent call last):
  File "/home/bio/groupshare/kshalaby/drug_repurposing/pykeen/NP_RotatE/NP_RotatE_Prediction_wwl_ns.py", line 60, in <module>
    pred = predict_target(
           ^^^^^^^^^^^^^^^
  File "/home/bio/groupshare/kshalaby/drep/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/bio/groupshare/kshalaby/drep/lib/python3.11/site-packages/pykeen/predict.py", line 1077, in predict_target
    target, batch, other_col_ids = _get_input_batch(factory=triples_factory, head=head, relation=relation, tail=tail)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bio/groupshare/kshalaby/drep/lib/python3.11/site-packages/pykeen/predict.py", line 563, in _get_input_batch
    head = factory.entity_to_id[head]
           ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'CoreTriplesFactory' object has no attribute 'entity_to_id'. Did you mean: 'entities_to_ids'?
```

my code:
```python
tf = CoreTriplesFactory.from_path_binary(
    "./NP_RotatE_model_results_wwl_ns/training_triples"
)
my_model = torch.load("./NP_RotatE_model_results_wwl_ns/trained_model.pkl")
pred = predict_target(
        model=my_model, head=str(head), tail=str(tail), triples_factory=tf
    )
```




@Karimsaber1 , would you mind sharing on which PyKEEN version your code runs (and with which version you wrote the training factory into a file)? You can get this via
```bash
python -m pykeen version 
```