Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robustness to incorrect types; numpy.int64 cannot be converted #115

Open
ndevenish opened this issue Jan 22, 2021 · 1 comment
Open

Robustness to incorrect types; numpy.int64 cannot be converted #115

ndevenish opened this issue Jan 22, 2021 · 1 comment

Comments

@ndevenish
Copy link
Collaborator

Spent some time tracking down an annoying calling error:

Traceback (most recent call last):
File "i24ssx_Chip_Collect_py3v1.py", line 293, in create_dcid
    dcid = conn.mx_acquisition.upsert_data_collection(list(dc_params.values()))
File ".../site-packages/ispyb/sp/acquisition.py", line 166, in upsert_data_collection
    return self.get_connection().call_sp_write("upsert_dc", values)
File ".../site-packages/ispyb/connector/mysqlsp/main.py", line 88, in call_sp_write
    result_args = cursor.callproc(procname=procname, args=args)
File ".../site-packages/mysql/connector/cursor_cext.py", line 466, in callproc
    "Failed calling stored routine; {0}".format(err))
mysql.connector.errors.InterfaceError: Failed calling stored routine; Python type numpy.int64 cannot be converted

Calling API had provided a numpy.int64 instead of an int. This looks like an int in __str__ and __repr__ so took an annoyingly long time to track down. I wonder if it'd be possible to tell which value caused this error, at least.

@thomasmfish
Copy link

thomasmfish commented Jan 25, 2021

I had this issue with the B24 pipeline. My fix was running values to be submitted to ISPyB though this:

def numpy_to_finite_native_type(value):
    if isinstance(value, npgeneric):
        value = value.item()
    if isinstance(value, Number) and isinf(value):
        value = None
    return value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants