Skip to content

Bug: Linux/Python 3.13: DataFrame/NumPy path crashes with numpy_type.cpp UNREACHABLE_CODE #566

Description

@ahgh0

Ladybug version

v0.17.1

What operating system are you using?

Ubuntu 22.04.5 LTS

What happened?

Hi LadybugDB team,
we hit a native assertion in Ladybug when running a graph validation workload on Linux with Python 3.13.

Environment:

  • OS: Ubuntu 22.04.5 LTS
  • Python: 3.13 and 3.11
  • Ladybug: observed with 0.16.1 and 0.17.1
  • NumPy: same version as a Windows environment where the workload works
  • Workload: in-memory graph, loading node/rel tables and evaluating Cypher queries
    (The same python code from me (and same versions of numpy, ladybug etc) works on a Windows machine, so this is a linux-related bug in Ladybug)

Failure:
RuntimeError: Assertion failed in file "/project/scripts/pip-package/cibw-source/sdist/ladybug-source/tools/python_api/src_cpp/numpy/numpy_type.cpp" on line 86: UNREACHABLE_CODE

Initial failing code path:

df = pandas.DataFrame(data, columns=cols)
conn.execute(f"COPY {table} FROM df")

Stack excerpt:
File ".../test.py", line 1438, in copy_df
    conn.execute(f"COPY {table} FROM df")
File ".../site-packages/ladybug/connection.py", line 328, in execute
    query_result_internal = self._execute_with_pybind(query, parameters)
File ".../site-packages/ladybug/connection.py", line 258, in _execute_with_pybind
    return py_connection.execute(prepared, parameters)
RuntimeError: Assertion failed in file ".../numpy_type.cpp" on line 86: UNREACHABLE_CODE

We also saw similar failures when using query-side DataFrame input such as:
LOAD FROM ab_df

Workarounds tested:
- Avoiding pandas/DataFrame usage completely works.
- Avoiding get_as_df() and using rows_as_dict().get_all() works.
- Literal UNWIND [...] input works but is much slower.
- A hybrid approach works best for now: CSV COPY for large graph load, no pandas/DataFrame for rule/query rows, and rows_as_dict() for results.


Expected behavior:   Ladybug should either:
- support the pandas/NumPy dtype combination on Linux/Python 3.13, or
- raise a Python-level error that identifies the unsupported dtype/column instead of hitting native UNREACHABLE_CODE.

Could you please check the NumPy dtype handling around numpy_type.cpp:86, especially for pandas DataFrame inputs with mixed string/int/float/null columns on Linux/Python 3.13?


### Are there known steps to reproduce?

1. Create a Linux Python 3.13 virtual environment.
2. Install dependencies:   pip install ladybug==0.16.1 pandas numpy
3. Start Python and run:

import ladybug as lb
import pandas as pd
conn = lb.Connection(lb.Database(":memory:"))
conn.execute("CREATE NODE TABLE T(id STRING PRIMARY KEY, name STRING, n INT64, v DOUBLE)")

df = pd.DataFrame([
    {"id": "a", "name": "x", "n": 1, "v": 1.5},
    {"id": "b", "name": "y", "n": 2, "v": None},
])
conn.execute("COPY T FROM df")

4. On the affected Linux host this crashes with:

RuntimeError: Assertion failed in file ".../numpy_type.cpp" on line 86: UNREACHABLE_CODE

(the same error also appears with query-side DataFrame input:
ab_df = pd.DataFrame([...])
conn.execute("LOAD FROM ab_df RETURN *")

Workaround: avoiding pandas/DataFrame input and avoiding get_as_df() prevents the crash.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions