Teichlab / MultiMAP

MultiMAP for integration of single cell multi-omics
MIT License
53 stars 12 forks source link

'Module' object has no attribute 'get_or_insert_function' #6

Closed Telogen closed 2 years ago

Telogen commented 2 years ago

Hi developer, I tried to run MultiMAP in a new python3.8 conda environment, but I got the following errors. Could you please help me figure it out? Many thanks!

import scanpy as sc
import anndata
import MultiMAP

sc.settings.set_figure_params(dpi=80)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
    234         """
--> 235         Create CPython wrapper(s) around this function (or generator).
    236         """

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_inst(self, inst)
    379 
--> 380         elif isinstance(inst, ir.SetItem):
    381             signature = self.fndesc.calltypes[inst]

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_assign(self, ty, inst)
    581 
--> 582         def cast_result(res):
    583             return self.context.cast(self.builder, res,

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in incref(self, typ, val)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/runtime/context.py in incref(self, builder, typ, value)
    217         """
--> 218         self._call_incref_decref(builder, typ, value, "NRT_incref")
    219 

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/runtime/context.py in _call_incref_decref(self, builder, typ, value, funcname)
    206             mod = builder.module
--> 207             fn = mod.get_or_insert_function(incref_decref_ty, name=funcname)
    208             # XXX "nonnull" causes a crash in test_dyn_array: can this

AttributeError: 'Module' object has no attribute 'get_or_insert_function'

During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)
/tmp/ipykernel_10470/978325731.py in <module>
      1 import scanpy as sc
      2 import anndata
----> 3 import MultiMAP
      4 
      5 sc.settings.set_figure_params(dpi=80)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/MultiMAP/__init__.py in <module>
      1 import scipy
      2 import numpy as np
----> 3 from MultiMAP.matrix import MultiMAP, tfidf
      4 #you don't need these if going for MultiMAP.matrix functions
      5 try:

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/MultiMAP/matrix.py in <module>
   1017 
   1018 @numba.njit("i4(i8[:])")
-> 1019 def tau_rand_int(state):
   1020 
   1021     state[0] = (

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/decorators.py in wrapper(func)
    224 
    225     return wrapper
--> 226 
    227 
    228 def generated_jit(function=None, target='cpu', cache=False,

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, sig)
    977     def _reduce_extras(self):
    978         """
--> 979         NOTE: sub-class can override to add extra states
    980         """
    981         return {}

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, args, return_type)
    139         impl = self.py_func(*args, **kws)
    140         # Check the generating function and implementation signatures are
--> 141         # compatible, otherwise compiling would fail later.
    142         pysig = utils.pysignature(self.py_func)
    143         implsig = utils.pysignature(impl)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_cached(self, args, return_type)
    153                      implparam.default != pyparam.default)):
    154                     ok = False
--> 155         if not ok:
    156             raise TypeError("generated implementation %s should be compatible "
    157                             "with signature '%s', but has signature '%s'"

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_core(self, args, return_type)
    166 
    167 class _CompilingCounter(object):
--> 168     """
    169     A simple counter that increment in __enter__ and decrement in __exit__.
    170     """

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(self, func)
    426     """
    427 
--> 428     def define_pipelines(self):
    429         # this maintains the objmode fallback behaviour
    430         pms = []

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler.py in _compile_bytecode(self)
    490 
    491         # strip phis
--> 492         pm.add_pass(PreLowerStripPhis, "remove phis nodes")
    493 
    494         # optimisation

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
    469 
    470     @staticmethod
--> 471     def define_nopython_lowering_pipeline(state, name='nopython_lowering'):
    472         pm = PassManager(name)
    473         # legalise

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
    460 
    461         typed_passes = dpb.define_typed_pipeline(state)
--> 462         pm.passes.extend(typed_passes.passes)
    463 
    464         lowering_passes = dpb.define_nopython_lowering_pipeline(state)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
    341     def dependency_analysis(self):
    342         """
--> 343         Computes dependency analysis
    344         """
    345         deps = dict()

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
    332                     raise BaseException("Legacy pass in use")
    333             except _EarlyPipelineCompletion as e:
--> 334                 raise e
    335             except Exception as e:
    336                 msg = "Failed in %s mode pipeline (step: %s)" % \

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     33         return _acquire_compile_lock
     34 
---> 35     def _is_owned(self):
     36         # This method is borrowed from threading.Condition.
     37         # Return True if lock is owned by current_thread.

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler_machinery.py in _runPass(self, index, pss, internal_state)
    287             mutated |= check(pss.run_initialization, internal_state)
    288         with SimpleTimer() as pass_time:
--> 289             mutated |= check(pss.run_pass, internal_state)
    290         with SimpleTimer() as finalize_time:
    291             mutated |= check(pss.run_finalizer, internal_state)

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/compiler_machinery.py in check(func, compiler_state)
    260 
    261         def check(func, compiler_state):
--> 262             mangled = func(compiler_state)
    263             if mangled not in (True, False):
    264                 msg = ("CompilerPass implementations should return True/False. "

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/typed_passes.py in run_pass(self, state)
    394             from numba.core.compiler import _LowerResult  # TODO: move this
    395             if flags.no_compile:
--> 396                 state['cr'] = _LowerResult(fndesc, call_helper,
    397                                            cfunc=None, env=env)
    398             else:

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower(self)
    136             self.lower_normal_function(self.fndesc)
    137         else:
--> 138             self.genlower = self.GeneratorLower(self)
    139             self.gentype = self.genlower.gentype
    140 

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_normal_function(self, fndesc)
    190         entry_block_tail = self.lower_function_body()
    191 
--> 192         # Close tail of entry block
    193         self.builder.position_at_end(entry_block_tail)
    194         self.builder.branch(self.blkmap[self.firstblk])

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_function_body(self)
    219 
    220     def lower_block(self, block):
--> 221         """
    222         Lower the given block.
    223         """

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
    233     def create_cpython_wrapper(self, release_gil=False):
    234         """
--> 235         Create CPython wrapper(s) around this function (or generator).
    236         """
    237         if self.genlower:

~/anaconda3/envs/singlecell/lib/python3.8/contextlib.py in __exit__(self, type, value, traceback)
    129                 value = type()
    130             try:
--> 131                 self.gen.throw(type, value, traceback)
    132             except StopIteration as exc:
    133                 # Suppress StopIteration *unless* it's the same exception that

~/anaconda3/envs/singlecell/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)

LoweringError: Failed in nopython mode pipeline (step: native lowering)
'Module' object has no attribute 'get_or_insert_function'

File "../anaconda3/envs/singlecell/lib/python3.8/site-packages/MultiMAP/matrix.py", line 1022:
def tau_rand_int(state):
    <source elided>
    state[0] = (
        ((state[0] & 4294967294) << 12) & 0xFFFFFFFF
        ^

During: lowering "state = arg(0, name=state)" at /home/txm/anaconda3/envs/singlecell/lib/python3.8/site-packages/MultiMAP/matrix.py (1022)
ktpolanski commented 2 years ago

Seems it's a numba thing. I thought we caught the version incompatibility and put it in the setup file. Try installing different versions of numba, no higher than 0.52.0, and see if this persists.

Telogen commented 2 years ago

After I install numba 0.51, the errors disappear. Thanks for your help!