/usr/local/lib/python3.6/site-packages/joblib/__pycache__
NameSizeModeActions
backports.cpython-36.pyc25550644editdlrm
compressor.cpython-36.pyc166160644editdlrm
disk.cpython-36.pyc30500644editdlrm
executor.cpython-36.pyc31660644editdlrm
format_stack.cpython-36.pyc8440644editdlrm
func_inspect.cpython-36.pyc87290644editdlrm
hashing.cpython-36.pyc62650644editdlrm
logger.cpython-36.pyc39600644editdlrm
memory.cpython-36.pyc288340644editdlrm
my_exceptions.cpython-36.pyc11300644editdlrm
numpy_pickle.cpython-36.pyc155640644editdlrm
numpy_pickle_compat.cpython-36.pyc70520644editdlrm
numpy_pickle_utils.cpython-36.pyc65160644editdlrm
parallel.cpython-36.pyc324160644editdlrm
pool.cpython-36.pyc124350644editdlrm
testing.cpython-36.pyc20370644editdlrm
_cloudpickle_wrapper.cpython-36.pyc5430644editdlrm
_dask.cpython-36.pyc105280644editdlrm
_deprecated_format_stack.cpython-36.pyc82160644editdlrm
_deprecated_my_exceptions.cpython-36.pyc27510644editdlrm
_memmapping_reducer.cpython-36.pyc161240644editdlrm
_multiprocessing_helpers.cpython-36.pyc12100644editdlrm
_parallel_backends.cpython-36.pyc196710644editdlrm
_store_backends.cpython-36.pyc139460644editdlrm
_utils.cpython-36.pyc11260644editdlrm
__init__.cpython-36.pyc45380644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/joblib/__pycache__/memory.cpython-36.pyc (28834B)
3 Eg1@stdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZmZmZddlmZdd lmZdd lmZmZmZdd lmZmZd Zd dZ Gddde!Z"deiZ#ddZ$d&ddZ%ddZ&ddZ'd'ddZ(e j)Z*GdddeZ+Gddde,Z-Gd d!d!e,Z.Gd"d#d#eZ/Gd$d%d%eZ0dS)(zo A context object for caching a function's return value each time it is called with the same input arguments. )with_statementN)open)hashing) get_func_code get_func_name filter_args) format_call)format_signature)Logger format_timepformat)StoreBackendBaseFileSystemStoreBackendz # first line:cCsL|jtr@|jd}t|dttd}dj|dd}nd}||fS)zZ Extract the first line information from the function code text if available.  rNr) startswithFIRST_LINE_TEXTsplitintlenjoin) func_code first_liner7/usr/local/lib/python3.6/site-packages/joblib/memory.pyextract_first_line2s   rc@seZdZdZdS)JobLibCollisionWarningzF Warn that there might be a collision between names of functions. N)__name__ __module__ __qualname____doc__rrrrr?srlocalcCsFt|tstdj||dks,t|t r:tdj||t|<dS)aExtend available store backends. The Memory, MemorizeResult and MemorizeFunc objects are designed to be agnostic to the type of store used behind. By default, the local file system is used but this function gives the possibility to extend joblib's memory pattern with other types of storage such as cloud storage (S3, GCS, OpenStack, HadoopFS, etc) or blob DBs. Parameters ---------- backend_name: str The name identifying the store backend being registered. For example, 'local' is used with FileSystemStoreBackend. backend: StoreBackendBase subclass The name of a class that implements the StoreBackendBase interface. z3Store backend name should be a string, '{0}' given.Nz;Store backend should inherit StoreBackendBase, '{0}' given.) isinstancestr ValueErrorformat issubclassr_STORE_BACKENDS) backend_namebackendrrrregister_store_backendGs r+cCs|dkr i}t|tjr t|}t|tr.|St|trd}tjj|}x"tj D]\}}||krR|}qRW|dkrt dj |||j |||d|S|dk rt jdj |jjtdS)z7Return the correct store object for the given location.Nz#Unknown location {0} or backend {1})verbosebackend_optionszdInstanciating a backend using a {} as a location is not supported by joblib. Returning None instead.)r#pathlibPathr$rospath expanduserr(items TypeErrorr& configurewarningswarn __class__r UserWarning)r*locationr,r-objZ backend_keyZ backend_objrrr_store_backend_factoryds.      r<cCs"t|\}}|j|tjj|S)z4Compute the part of part associated with a function.)rappendr0r1r)funcmodulesfuncnamerrr_get_func_fullnames  rAcCs4g}t|tr|j|n|jt|tjj|S)z:Build a roughly unique identifier for the cached function.)r#r$r=rAr0r1r)r>partsrrr_build_func_identifiers   rCc Csd}yJ|dk r@djdd|djD}dtjj||f}n tjj|}Wntk rbYnX|dk rdjttj|}nd}d j|t |S) zE Helper function to format the message when loading the results. Nz, cSsg|]\}}d||fqS)z%s=%sr).0namevaluerrr sz$_format_load_msg.. input_argsz%s(%s)z{0: <16}z[Memory]{0}: Loading {1}) rr3r0r1basenameKeyErrorr&r timer$)func_idargs_id timestampmetadata signatureargsZ ts_stringrrr_format_load_msgs rSc@sFeZdZdZdddZeddZd d Zd d Zd dZ ddZ dS)MemorizedResultalObject representing a cached value. Attributes ---------- location: str The location of joblib cache. Depends on the store backend used. func: function or str function whose output is cached. The string case is intended only for instanciation based on the output of repr() on another instance. (namely eval(repr(memorized_instance)) works). argument_hash: str hash of the function arguments. backend: str Type of store backend for reading/writing cache files. Default is 'local'. mmap_mode: {None, 'r+', 'r', 'w+', 'c'} The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the different values. verbose: int verbosity level (0 means no message). timestamp, metadata: string for internal use only. r"Nrc Cstj|t||_t|tr&||_n|j|_||_t|||d|_ ||_ |dk rZ||_ n|j j |j|jg|_ |j j dd|_||_||_dS)N)r,duration)r __init__rCrMr#r$r>rNr< store_backend mmap_moderP get_metadatagetrUr,rO) selfr:r>rNr*rXr,rOrPrrrrVs     zMemorizedResult.__init__cCstjdtdd|jS)NzThe 'argument_hash' attribute has been deprecated in version 0.12 and will be removed in version 0.14. Use `args_id` attribute instead.) stacklevel)r6r7DeprecationWarningrN)r[rrr argument_hashs zMemorizedResult.argument_hashcCs|jr t|j|j|j|jd}nd}y|jj|j|jg||jdStk r}z.t dj t j j |jj|j|j}||WYdd}~XnXdS)z$Read value from cache and return it.)rOrPN)msgr,zaError while trying to load a MemorizedResult's value. It seems that this folder is corrupted : {})r,rSrMrNrOrPrW load_itemr%rKr&r0r1rr:)r[r`excnew_excrrrrZs    zMemorizedResult.getcCs|jj|j|jgdS)zClear value from cacheN)rWZ clear_itemrMrN)r[rrrclearszMemorizedResult.clearcCsdj|jj|jj|j|jdS)NzG{class_name}(location="{location}", func="{func}", args_id="{args_id}")) class_namer:r>rN)r&r8rrWr:r>rN)r[rrr__repr__s zMemorizedResult.__repr__cCs|jj}d|d<|S)NrO)__dict__copy)r[staterrr __getstate__s zMemorizedResult.__getstate__)r"NrNN) rrr r!rVpropertyr_rZrdrfrjrrrrrTs   rTc@sDeZdZdZdZddZddZdd Zd d Zd d Z ddZ dS)NotMemorizedResultzxClass representing an arbitrary value. This class is a replacement for MemorizedResult when there is no cache. rGvalidcCs||_d|_dS)NT)rGrm)r[rGrrrrV+szNotMemorizedResult.__init__cCs|jr |jStddS)NzNo value stored.)rmrGrK)r[rrrrZ/szNotMemorizedResult.getcCsd|_d|_dS)NF)rmrG)r[rrrrd5szNotMemorizedResult.clearcCs.|jrdj|jjt|jdS|jjdSdS)Nz{class_name}({value}))rerGz with no value)rmr&r8rr rG)r[rrrrf9s zNotMemorizedResult.__repr__cCs|j|jdS)N)rmrG)rmrG)r[rrrrjBszNotMemorizedResult.__getstate__cCs|d|_|d|_dS)NrmrG)rmrG)r[rirrr __setstate__Es zNotMemorizedResult.__setstate__N)rGrm) rrr r! __slots__rVrZrdrfrjrnrrrrrl$s rlc@sJeZdZdZddZddZddZdd Zdd d Zd dZ ddZ dS)NotMemorizedFuncaNo-op object decorating a function. This class replaces MemorizedFunc when there is no cache. It provides an identical API but does not write anything on disk. Attributes ---------- func: callable Original undecorated function. cCs ||_dS)N)r>)r[r>rrrrVYszNotMemorizedFunc.__init__cOs |j||S)N)r>)r[rRkwargsrrr__call__\szNotMemorizedFunc.__call__cOst|j||S)N)rlr>)r[rRrqrrrcall_and_shelve_sz NotMemorizedFunc.call_and_shelvecCsdj|jj|jS)Nz {0}(func={1}))r&r8rr>)r[rrrrfbszNotMemorizedFunc.__repr__TcCsdS)Nr)r[r7rrrrdeszNotMemorizedFunc.clearcOs |j||S)N)r>)r[rRrqrrrcalliszNotMemorizedFunc.callcOsdS)NFr)r[rRrqrrrcheck_call_in_cachelsz$NotMemorizedFunc.check_call_in_cacheN)T) rrr r!rVrrrsrfrdrtrurrrrrpMs  rpc@seZdZdZd)ddZd*dd Zed d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZd+ddZd,d d!Zd"d#Zd-d%d&Zd'd(ZdS). MemorizedFuncaCallable object decorating a function for caching its return value each time it is called. Methods are provided to inspect the cache or clean it. Attributes ---------- func: callable The original, undecorated, function. location: string The location of joblib cache. Depends on the store backend used. backend: str Type of store backend for reading/writing cache files. Default is 'local', in which case the location is the path to a disk storage. ignore: list or None List of variable names to ignore when choosing whether to recompute. mmap_mode: {None, 'r+', 'r', 'w+', 'c'} The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the different values. compress: boolean, or integer Whether to zip the stored data on disk. If an integer is given, it should be between 1 and 9, and sets the amount of compression. Note that compressed arrays cannot be read by memmapping. verbose: int, optional The verbosity flag, controls messages that are issued as the function is evaluated. r"NFrc Cstj|||_||_||_|dkr(g}||_||_t|||t||dd|_ |j dk rl|j j t |jg|dkr|t j }||_ ytj||Wn YnXtj|rtjj|} | jddd} tjdd| } n|j} d| |_d|_d|_dS) N)compressrX)r,r-rz rz.rDzMemoized version of %s)r rVrXrwr>ignore_verboser<dictrWstore_cached_func_coderCrLrO functoolsupdate_wrapperinspect isfunctionpydocZTextDocdocumentreplaceresubr!_func_code_info _func_code_id) r[r>r:r*rxrXrwr,rOdocrrrrVs>    zMemorizedFunc.__init__cCs|j||\}}d}d}d}|jddo6|jj||gsx|jdkrrt|j\} } |jdj| ||jj |gdd}nyt j } |jrt |||j |d }|s|jj ||g||jd } nd} |jdkrt j | } t|j\} } d | t| f}ttd d t|d|WnFtk rXt|jf||\} }|jdj|tjd}YnX|r|j||\} }|jdk r|jrt |||j |d }|jj ||g||jd } | ||fS)aCall wrapped function and cache result, or read cache if available. This function returns the wrapped function output and some metadata. Arguments: ---------- args, kwargs: list and dict input arguments for wrapped function shelving: bool True when called via the call_and_shelve function. Returns ------- output: value or tuple or None Output of the wrapped function. If shelving is True and the call has been already cached, output is None. argument_hash: string Hash of function arguments. metadata: dict Some metadata about wrapped function call (see _persist_input()). NF)r] z5Computing func {0}, argument hash {1} in location {2}r:T)rOrP)r`r,z%s cache loaded - %srP_z*Exception while loading results for {} {})_get_output_identifiers_check_previous_func_coderW contains_itemryrr>r7r&Zget_cached_func_inforLrSrOrar printmaxr Exceptionr traceback format_excrtrX)r[rRrqshelvingrMrNrPr`Z must_callrrFt0outtrQrrr _cached_callsZ     "   zMemorizedFunc._cached_callcCsZt|jdr>|jdkr&t|jj|_nt|jj|jkr>d|_|jdkrTt|j|_|jS)N__code__)hasattrr>ridrrr)r[rrrfunc_code_info&s   zMemorizedFunc.func_code_infocOs6|j||dd\}}}t|j|j|||jd|jdS)a\Call wrapped function, cache result and return a reference. This method returns a reference to the cached result instead of the result itself. The reference object is small and pickeable, allowing to send or store it easily. Call .get() on reference object to get result. Returns ------- cached_result: MemorizedResult or NotMemorizedResult reference to the value returned by the wrapped function. The class "NotMemorizedResult" is used when there is no cache activated (e.g. location=None in Memory). T)rr)rPr,rO)rrTrWr>ryrO)r[rRrqrrNrPrrrrs=s  zMemorizedFunc.call_and_shelvecOs|j||dS)Nr)r)r[rRrqrrrrrQszMemorizedFunc.__call__cCs$|j}|jj}d|d<d|d<|S)NrOr)rrgrh)r[rrirrrrjTs  zMemorizedFunc.__getstate__cOs |j||\}}|jj||fS)a\Check if function call is in the memory cache. Does not call the function or do any work besides func inspection and arg hashing. Returns ------- is_call_in_cache: bool Whether or not the result of the function has been cached for the input arguments that have been passed. )rrWr)r[rRrqrMrNrrrruds z!MemorizedFunc.check_call_in_cachecOs"tjt|j|j|||jdk dS)N)Z coerce_mmap)rhashrr>rxrX)r[rRrqrrr_get_argument_hashwsz MemorizedFunc._get_argument_hashcOst|j}|j||}||fS)z@Return the func identifier and input parameter hash of a result.)rCr>r)r[rRrqrMr_rrrr{s  z%MemorizedFunc._get_output_identifierscCs(tt|jdd}t|jt|j|fS)z'Hash a function to key the online cacherN)rgetattrr>r)r[Z func_code_hrrr _hash_funcszMemorizedFunc._hash_funcc Csxt|j}dt||f}|jj|g|d}t|jdoB|jjdk}|rt|j}y|t|j<Wnt k rrYnXdS)z= Write the function code and the filename to a file. z%s %i %sFrzN) rCr>rrWr{rrr_FUNCTION_HASHESr4)r[rrrMZis_named_callable func_hashrrr_write_func_codes   zMemorizedFunc._write_func_coder\c Csy(|jtkr&|j}|t|jkr&dSWntk r<YnX|j\}}}t|j}yt|jj|g\}}Wn$t t fk r|j ||dSX||krdSt |jddd\} } ||kodkns| dkr |dksdj | ||} n| } tjtdj | |d||k r|d k rd} tjj|rt |jdd \} } t|jd } t|&}|j|d|d| d}Wd QRXd j|}|j|jk} n |jd } | rtjtd| ||| ||f|d|jdkrt |jdd \} } |jdj | ||jdddS)z stacklevel is the depth a which this function is called, to issue useful warnings to the user. TF) resolv_aliasZwin_charactersrzz {0} ({1}:{2})z0Cannot detect name collisions for function '{0}')r]N)rrrDz rrr4rrCrrWZget_cached_func_codeIOErrorOSErrorrrr&r6r7rr0r1existsrropen_py_source readlinesrrstriprryrd)r[r]rrZ source_filerrMZ old_func_codeZold_first_liner func_nameZfunc_descriptionZpossible_collisionZ num_linesfZon_disk_func_coderrrrsh      " $       z'MemorizedFunc._check_previous_func_codeTcCsPt|j}|jdkr&|r&|jd||jj|g|j\}}}|j||dS)zEmpty the function's cache.rz(Clearing function cache identified by %sN)rCr>ryr7rWZ clear_pathrr)r[r7rMrrrrrrrds   zMemorizedFunc.clearc Ostj}|j||\}}|jdkr4tt|j|||j||}|jj||g||jdtj|}|j|||}|jdkrt |j\} } d| t |f} tt ddt | d| ||fS)zq Force the execution of the function with the given arguments and persist the output values. r)r,z%s - %srr) rLrryrr r>rWZ dump_item_persist_inputrr rr) r[rRrq start_timerMrNoutputrUrPrrFr`rrrrts    zMemorizedFunc.call?c Cstj}t|j|j||}tdd|jD}||d}|j||\} } |jj| | g|tj|} | |krt j d| dd|S)a% Save a small summary of the call using json format in the output directory. output_dir: string directory where to write metadata. duration: float time taken by hashing input arguments, calling the wrapped function and persisting its output. args, kwargs: list and dict input arguments for wrapped function this_duration_limit: float Max execution time for this function before issuing a warning. css|]\}}|t|fVqdS)N)repr)rEkvrrr -sz/MemorizedFunc._persist_input..)rUrIa~Persisting input arguments took %.2fs to run. If this happens often in your code, it can cause performance problems (results will be correct in all cases). The reason for this is probably some large input arguments for a wrapped function (e.g. large strings). THIS IS A JOBLIB ISSUE. If you can, kindly provide the joblib's team with an example so that they can fix the problem.)r]) rLrr>rxrzr3rrWZstore_metadatar6r7) r[rUrRrqZthis_duration_limitrZ argument_dictZ input_reprrPrMrNZ this_durationrrrrs    zMemorizedFunc._persist_inputcCsdj|jj|j|jjdS)Nz.{class_name}(func={func}, location={location}))rer>r:)r&r8rr>rWr:)r[rrrrfNszMemorizedFunc.__repr__)r"NNFrN)F)r\)T)r)rrr r!rVrrkrrsrrrjrurrrrrrdrtrrfrrrrrvss$% , \  X  6rvc@sZeZdZdZdddZedd Zdd d Zdd dZddZ ddZ ddZ ddZ dS)Memorya A context object for caching a function's return value each time it is called with the same input arguments. All values are cached on the filesystem, in a deep directory structure. Read more in the :ref:`User Guide `. Parameters ---------- location: str, pathlib.Path or None The path of the base directory to use as a data store or None. If None is given, no caching is done and the Memory object is completely transparent. This option replaces cachedir since version 0.12. backend: str, optional Type of store backend for reading/writing cache files. Default: 'local'. The 'local' backend is using regular filesystem operations to manipulate data (open, mv, etc) in the backend. cachedir: str or None, optional .. deprecated: 0.12 'cachedir' has been deprecated in 0.12 and will be removed in 0.14. Use the 'location' parameter instead. mmap_mode: {None, 'r+', 'r', 'w+', 'c'}, optional The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the arguments. compress: boolean, or integer, optional Whether to zip the stored data on disk. If an integer is given, it should be between 1 and 9, and sets the amount of compression. Note that compressed arrays cannot be read by memmapping. verbose: int, optional Verbosity flag, controls the debug messages that are issued as functions are evaluated. bytes_limit: int, optional Limit in bytes of the size of the cache. By default, the size of the cache is unlimited. When reducing the size of the cache, ``joblib`` keeps the most recently accessed items first. **Note:** You need to call :meth:`joblib.Memory.reduce_size` to actually reduce the cache size to be less than ``bytes_limit``. backend_options: dict, optional Contains a dictionnary of named parameters used to configure the store backend. Nr"Frc Cstj|||_||_tj|_||_||_||_|dkr>i}||_ |r^|dk r^t j ddd|dk r|dk r~t dj ||t j dj |tdd|}||_t|trtjj|d}t|||jtf||d|d|_dS) Nz&Compressed results cannot be memmappedr\)r]zYou set both "location={0!r} and "cachedir={1!r}". 'cachedir' has been deprecated in version 0.12 and will be removed in version 0.14. Please only set "location={0!r}"zThe 'cachedir' parameter has been deprecated in version 0.12 and will be removed in version 0.14. You provided "cachedir={0!r}", use "location={0!r}" instead.joblib)rwrX)r,r-)r rVryrXrLrO bytes_limitr*rwr-r6r7r%r&r^r:r#r$r0r1rr<rzrW) r[r:r*cachedirrXrwr,rr-rrrrVs<       zMemory.__init__cCs.tjdtdd|jdkrdStjj|jdS)NzThe 'cachedir' attribute has been deprecated in version 0.12 and will be removed in version 0.14. Use os.path.join(memory.location, 'joblib') attribute instead.r\)r]r)r6r7r^r:r0r1r)r[rrrrs   zMemory.cachedirc Csz|dkrtj|j|||dS|jdkr.t|S|dkr<|j}|dkrJ|j}t|trZ|j }t||j|j |||j ||j dS)a{ Decorates the given function func to only compute its return value for input arguments not cached on disk. Parameters ---------- func: callable, optional The function to be decorated ignore: list of strings A list of arguments name to ignore in the hashing verbose: integer, optional The verbosity mode of the function. By default that of the memory object is used. mmap_mode: {None, 'r+', 'r', 'w+', 'c'}, optional The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the arguments. By default that of the memory object is used. Returns ------- decorated_func: MemorizedFunc object The returned object is a MemorizedFunc object, that is callable (behaves like a function), but offers extra methods for cache lookup and management. See the documentation for :class:`joblib.memory.MemorizedFunc`. N)rxr,rXF)r:r*rxrXrwr,rO) r|partialcacherWrpryrXr#rvr>r*rwrO)r[r>rxr,rXrrrrs     z Memory.cacheTcCs&|r|jd|jdk r"|jjdS)z- Erase the complete cache directory. zFlushing completely the cacheN)r7rWrd)r[r7rrrrds  z Memory.clearcCs&|jdk r"|jdk r"|jj|jdS)z@Remove cache elements to make cache size fit in ``bytes_limit``.N)rrWZreduce_store_size)r[rrr reduce_sizeszMemory.reduce_sizecOs$|jdkr|||S|j|||S)a Eval function func with arguments `*args` and `**kwargs`, in the context of the memory. This method works similarly to the builtin `apply`, except that the function is called only if the cache is not up to date. N)rWr)r[r>rRrqrrrevals  z Memory.evalcCs$dj|jj|jdkrdn|jjdS)Nz!{class_name}(location={location}))rer:)r&r8rrWr:)r[rrrrfszMemory.__repr__cCs|jj}d|d<|S)zf We don't store the timestamp when pickling, to avoid the hash depending from it. NrO)rgrh)r[rirrrrjs zMemory.__getstate__)Nr"NNFrNN)NNNF)T) rrr r!rVrkrrrdrrrfrjrrrrrXs7 * - r)rN)NN)1r! __future__rr0rLr.rrr|rr6r~weakreftokenizerrrDrZ func_inspectrrrr r loggerr r r Z_store_backendsrrrrr9rr(r+r<rArCrSWeakKeyDictionaryrrTobjectrlrprvrrrrrsH       ( g)&h