usc-isi-i2 / kgtk-notebooks

Tutorial and hands-on notebook on using the Knowledge Graph Toolkit (KGTK)
MIT License
78 stars 25 forks source link

graph-embeddings Error! #12

Open ArenSafar opened 1 year ago

ArenSafar commented 1 year ago

Hello I'm new to KGTK and I want to use this tool to run the graph embeddings, I think there's some sort of unhandled type error. Is there a way to update notebooks or a workaround to run the embeddings function? Thanks.

Error output:

`Exception in thread background thread for pid 4793: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, *self._kwargs) File "/usr/local/lib/python3.8/dist-packages/sh.py", line 1654, in wrap fn(rgs, **kwargs) File "/usr/local/lib/python3.8/dist-packages/sh.py", line 2656, in background_thread handle_exit_code(exit_code) File "/usr/local/lib/python3.8/dist-packages/sh.py", line 2347, in fn return self.command.handle_command_exit_code(exit_code) File "/usr/local/lib/python3.8/dist-packages/sh.py", line 838, in handle_command_exit_code raise exc sh.ErrorReturnCode_1:

RAN: /usr/bin/bash -c 'kgtk --debug graph-embeddings -op ComplEx --dimension 10 -ot kgtk --retain_temporary_data True -T $TEMP -i /root/isi-kgtk-tutorial/tutorial-graph-embeddings_input/converted_nonVpn.tsv -o /tmp/projects/tutorial-graph-embeddings/arnold.embeddings.augmented.100.tsv --log $TEMP/ge.log.txt '

STDOUT:

STDERR:

Starting 'graph-embeddings' on pid 4793. In Processing, Please go to /tmp/projects/tutorial-graph-embeddings/temp.tutorial-graph-embeddings/ge.log.txt to check details Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/kgtk/graph_embeddings/graph_embeddings.py", line 365, in process train(config, subprocess_init=subprocessinit) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/train.py", line 938, in train for in train_and_report_stats(config, model, trainer, evaluator, rank, subprocess_init): File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/train.py", line 472, in train_and_report_stats checkpoint_manager.register_metadata_provider(ConfigMetadataProvider(config)) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/checkpoint_manager.py", line 193, in init self.json_config_dict = json.dumps(config.to_dict(), indent=4) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/schema.py", line 331, in to_dict return Dumper().map_with_type(self, type(self)) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/schema.py", line 162, in map_with_type return self.mapschema(data, type) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/schema.py", line 243, in map_schema result[key] = self.map_with_type(getattr(data, key), field.type) File "/usr/local/lib/python3.8/dist-packages/torchbiggraph/schema.py", line 163, in map_withtype raise NotImplementedError("Unknown type: %s" % type) NotImplementedError: Unknown type: typing.Union[float, NoneType]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/kgtk/exceptions.py", line 70, in call return_code = func(*args, **kwargs) or 0 File "/usr/local/lib/python3.8/dist-packages/kgtk/cli/graph_embeddings.py", line 182, in run cge.process() File "/usr/local/lib/python3.8/dist-packages/kgtk/graph_embeddings/graph_embeddings.py", line 408, in process raise KGTKException(str(e)) kgtk.exceptions.KGTKException: Unknown type: typing.Union[float, NoneType] Unknown type: typing.Union[float, NoneType]`

dgarijo commented 1 year ago

Please note that the recommended Python version for kgtk is 3.9. You seem to be using 3.8

ArenSafar commented 1 year ago

I installed kgtk locally on my Linux environment with python3.9 and still got the same type error:

`Starting 'graph-embeddings' on pid 24214. In Processing, Please go to /tmp/projects/tutorial-graph-embeddings/temp.tutorial-graph-embeddings/ge.log.txt to check details Traceback (most recent call last): File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/kgtk/graph_embeddings/graph_embeddings.py", line 365, in process train(config, subprocess_init=subprocessinit) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/train.py", line 938, in train for in train_and_report_stats(config, model, trainer, evaluator, rank, subprocess_init): File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/train.py", line 472, in train_and_report_stats checkpoint_manager.register_metadata_provider(ConfigMetadataProvider(config)) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/checkpoint_manager.py", line 193, in init self.json_config_dict = json.dumps(config.to_dict(), indent=4) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/schema.py", line 331, in to_dict return Dumper().map_with_type(self, type(self)) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/schema.py", line 162, in map_with_type return self.mapschema(data, type) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/schema.py", line 243, in map_schema result[key] = self.map_with_type(getattr(data, key), field.type) File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/torchbiggraph/schema.py", line 163, in map_withtype raise NotImplementedError("Unknown type: %s" % type) NotImplementedError: Unknown type: typing.Optional[float]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/kgtk/exceptions.py", line 70, in call return_code = func(*args, **kwargs) or 0 File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/kgtk/cli/graph_embeddings.py", line 182, in run cge.process() File "/home/arens/miniconda3/envs/kgtk-env/lib/python3.9/site-packages/kgtk/graph_embeddings/graph_embeddings.py", line 408, in process raise KGTKException(str(e)) kgtk.exceptions.KGTKException: Unknown type: typing.Optional[float] Unknown type: typing.Optional[float]`

filievski commented 1 year ago

Thank you for the update @ArenSafar. @saggu @CraigMiloRogers can one of you help with this issue?

ArenSafar commented 1 year ago

I debugged the code and probably this is a python version issue but the fix I did was on PyTorch-BigGraph code: on here I moved line 142 to after line 136. And also took lines 140-141 out of the else statement.