Closed trvadams closed 2 months ago
Thanks for trying out Koina. The code snippet you posted above is working for me. Can you share the full traceback that you see?
Hi, yes the full traceback is here:
>>> predictions = model.predict(inputs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages/koinapy/grpc.py", line 522, in predict
return self.__predict_async(data, debug=debug)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages/koinapy/grpc.py", line 547, in __predict_async
for i, data_batch in enumerate(self.__slice_dict(data, self.batchsize)):
File "/home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages/koinapy/grpc.py", line 330, in __slice_dict
len_inputs = list(data.values())[0].shape[0]
^^^^^^^^^^^^^
TypeError: 'numpy.ndarray' object is not callable
Python 3.12.4 Package versions: koinapy 0.0.1 numpy 1.26.4 pandas 2.2.2
I can see this error when I provide, a NumPy array as input instead of a Pandas Dataframe t o model.predict
.
Can you check the datatype and structure of inputs
right before calling model.predict
?
If that is the case I will improve error handling to display a more user-friendly error message.
On my end, inputs
appears to be a Pandas Dataframe:
>>> inputs
peptide_sequences precursor_charges collision_energies
0 AAAAAKAK 1 25
1 AAAAAKAK 2 25
>>> inputs.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2 entries, 0 to 1
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 peptide_sequences 2 non-null object
1 precursor_charges 2 non-null int64
2 collision_energies 2 non-null int64
dtypes: int64(2), object(1)
memory usage: 180.0+ bytes
Dataframe support was added in version 0.0.2. Is there a reason you use version 0.0.1 instead of the latest 0.0.6?
Aha, now I see the issue. I installed it via pip install koinapy
yesterday, and now I see it seems like pip still defaults to 0.0.1:
pip install koinapy
Collecting koinapy
Using cached koinapy-0.0.1-py3-none-any.whl.metadata (612 bytes)
Requirement already satisfied: tqdm<5.0.0,>=4.66.2 in /home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages (from koinapy) (4.66.4)
Requirement already satisfied: tritonclient<3.0.0,>=2.42.0 in /home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages (from koinapy) (2.46.0)
Requirement already satisfied: numpy>=1.19.1 in /home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages (from tritonclient<3.0.0,>=2.42.0->koinapy) (1.26.4)
Requirement already satisfied: python-rapidjson>=0.9.1 in /home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages (from tritonclient<3.0.0,>=2.42.0->koinapy) (1.17)
Requirement already satisfied: urllib3>=2.0.7 in /home/tadams/miniconda3/envs/ms/lib/python3.12/site-packages (from tritonclient<3.0.0,>=2.42.0->koinapy) (2.2.2)
Using cached koinapy-0.0.1-py3-none-any.whl (8.1 kB)
Installing collected packages: koinapy
Successfully installed koinapy-0.0.1
When specifying the latest version of koinapy, it doesn't recognize Python 3.12 as a valid version:
python -m pip install koinapy==0.0.6
ERROR: Ignored the following versions that require a different python version: 0.0.2 Requires-Python >=3.8,<3.11; 0.0.3 Requires-Python >=3.8,<3.11; 0.0.4 Requires-Python <3.11,>=3.8; 0.0.5 Requires-Python <3.11,>=3.8; 0.0.6 Requires-Python <3.11,>=3.8
ERROR: Could not find a version that satisfies the requirement koinapy==0.0.6 (from versions: 0.0.1)
ERROR: No matching distribution found for koinapy==0.0.6
I get the same error when trying to use the latest version of Python 3.11. However, when I use Python 3.10, pip installs 0.0.6 successfully:
python -m pip install koinapy
Collecting koinapy
Downloading koinapy-0.0.6-py3-none-any.whl.metadata (963 bytes)
The code snippet in the initial issue now works as expected:
>>> predictions = model.predict(inputs)
Prosit_2019_intensity:: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 1.98it/s
So it seems like it was a problem on my end with PyPi version control and newer versions of Python. Is this intentional, or could the PyPi be updated to support current Python versions?
Thanks for making me aware of this! This isn't intentional! I will look into this and update koinapy to be work with all current python version.
Great, thanks for helping me figure it out. This tool is very cool, looking forward to incorporating it into some of my mass spec workflows 😎
This should be solved with the latest release for python versions up to 3.12.
I am trying to use Prosit via koinapy to predict peptide CID fragments. I tried the sample python script under "Prosit_2020_intensity_CID": https://koina.wilhelmlab.org/docs#post-/Prosit_2020_intensity_TMT/infer
This returns the error message when calling model.predict(inputs):
I get the same problem when trying to use other models.