clj-python / clj-python/libpython-clj
Error when using `require-python` from a required namespace (specifically numba)
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.2k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to create a namespace that initializes the python connection, and goes on to define some analytic functions which can then be required from other namespaces. If I evaluate this namespace in the REPL, everything works fine. However, when I try to require this namespace from another I get TypeError: must be real number, not Float.
Click for stacktrace details
Caused by: java.lang.Exception: TypeError: must be real number, not Float
at libpython_clj2.python.ffi$check_error_throw.invokeStatic(ffi.clj:703)
at libpython_clj2.python.ffi$check_error_throw.invoke(ffi.clj:701)
at libpython_clj2.python.fn$call_py_fn.invokeStatic(fn.clj:179)
at libpython_clj2.python.fn$call_py_fn.invoke(fn.clj:177)
at libpython_clj2.python.bridge_as_jvm$call_impl_fn.invokeStatic(bridge_as_jvm.clj:246)
at libpython_clj2.python.bridge_as_jvm$call_impl_fn.invoke(bridge_as_jvm.clj:241)
at libpython_clj2.python.bridge_as_jvm$make_instance_pycall$fn__27409.doInvoke(bridge_as_jvm.clj:269)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at libpython_clj2.python.bridge_as_jvm$generic_python_as_map$reify__27414.get(bridge_as_jvm.clj:295)
at libpython_clj2.python.bridge_as_jvm$generic_python_as_map$reify__27414$fn__27419.invoke(bridge_as_jvm.clj:324)
at clojure.core$map$fn__5935.invoke(core.clj:2770)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:51)
at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
at clojure.lang.ChunkedCons.next(ChunkedCons.java:43)
at clojure.lang.RT.next(RT.java:713)
at clojure.lang.SeqIterator.hasNext(SeqIterator.java:41)
at clojure.core.protocols$iter_reduce.invokeStatic(protocols.clj:48)
at clojure.core.protocols$fn__8230.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__8230.invoke(protocols.clj:75)
at clojure.core.protocols$fn__8178$G__8173__8191.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6886)
at clojure.core$into.invokeStatic(core.clj:6958)
at clojure.core$into.invoke(core.clj:6950)
at libpython_clj2.metadata$datafy_module_or_class.invokeStatic(metadata.clj:236)
at libpython_clj2.metadata$datafy_module_or_class.invoke(metadata.clj:230)
at libpython_clj2.metadata$eval31858$fn__31859.invoke(metadata.clj:261)
at clojure.lang.MultiFn.invoke(MultiFn.java:229)
at libpython_clj2.python.bridge_as_jvm$generic_pyobject$reify__27599.datafy(bridge_as_jvm.clj:436)
at clojure.datafy$datafy.invokeStatic(datafy.clj:23)
at clojure.datafy$datafy.invoke(datafy.clj:15)
at libpython_clj2.require$do_require_python.invokeStatic(require.clj:130)
at libpython_clj2.require$do_require_python.invoke(require.clj:86)
at libpython_clj2.require$require_python$fn__31971.invoke(require.clj:273)
at libpython_clj2.require$require_python.invokeStatic(require.clj:265)
at libpython_clj2.require$require_python.invoke(require.clj:173)
at libpython_clj2.require$require_python.invokeStatic(require.clj:278)
at libpython_clj2.require$require_python.doInvoke(require.clj:173)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at libpython_clj2.require$require_python.invokeStatic(require.clj:280)
at libpython_clj2.require$require_python.doInvoke(require.clj:173)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at libpython_clj2.require$require_python.invokeStatic(require.clj:280)
at libpython_clj2.require$require_python.doInvoke(require.clj:173)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at libpython_clj2.require$require_python.invokeStatic(require.clj:280)
at libpython_clj2.require$require_python.doInvoke(require.clj:173)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at libpython_clj2.require$require_python.invokeStatic(require.clj:280)
at libpython_clj2.require$require_python.doInvoke(require.clj:173)
at clojure.lang.RestFn.invoke(RestFn.java:628)
at libpython_test.core$eval32052.invokeStatic(core.clj:29)
at libpython_test.core$eval32052.invoke(core.clj:29)
at clojure.lang.Compiler.eval(Compiler.java:7194)
at clojure.lang.Compiler.load(Compiler.java:7653)
... 50 more
I set up a basic reproduction of this error at https://github.com/metasoarous/libpython-require-error in the require-init-bug branch (you'll note that this is the same repo as I put together for #212, only I switched to jdk-8 to get baseline functionality working again).
Any idea why I'm seeing this behavior, and if so how I might avoid it?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure from the require-init-bug branch of metasoarous/libpython-require-error. Trace the require path through libpython_clj2/require.clj, metadata.clj, and bridge_as_jvm.clj, starting at do_require_python and the datafy call shown in the stack trace. Done means requiring the namespace no longer raises the TypeError with the numba example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100