o
    Uݢg                     @  s\   d Z ddlmZ ddlZddlZddlZdej dgZdd Z	dd Z
e
ejjej_dS )	zA wrapper to avoid importing tables directly.

We need to monkey patch it on the fly to avoid issues with it changing thread
usage under the hood. See CELLRANGER-2936
    )annotationsNFc                  C  s   t d sFt d  d7  < z%ddl} |  }|t d< |tj_dt d< tjdt d  d W t d S    tjdt d  d Y t d S t d S )	zUMemoized function to query martian for thread usage,.

    assuming it's loaded.
    r         NTz%Martian runtime detected. Try Num. = 
z1Warning: No martian runtime detected. Try Num. = )	_CACHED_MARTIAN_STATUSmartianget_threads_allocationtables
parametersMAX_NUMEXPR_THREADSsysstdoutwrite)r   	n_threads r   h/oak/stanford/groups/akundaje/marinovg/programs/cellranger-9.0.1/lib/python/cellranger/wrapped_tables.py_get_n_threads   s   r   c                   s    fdd}|S )zuA decorator around the initialization function.

    to make sure it doesn't set the threads above what we want.
    c                    s$   t  }||d< ||d<  | i |S )Nr   ZMAX_BLOSC_THREADS)r   )argskwargsr   functionr   r   wrapper1   s   z)file_constructor_wrapper.<locals>.wrapperr   )r   r   r   r   r   file_constructor_wrapper+   s   r   )__doc__
__future__r   r   Znumexprr	   utilsZdetect_number_of_coresr   r   r   File__init__r   r   r   r   <module>   s   