/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__/parallel.cpython-36.pyc (32416B)
3 Egb@sdZddlmZddlZddlZddlmZddlZddlZddl Z ddl Z ddl m Z ddl mZddlZddlZddlmZdd lmZmZdd lmZdd lmZmZmZmZmZdd lmZm Z dd l!m"Z"ddl#m$Z$ddlm%Z%ddlm&Z&eeeedZ'da(dZ)dZ*e j+Z,d3Z-d4Z.ddZ/de/iZ0d5ddZ1Gddde2Z3dZ4e5edrej6j7dd j8prdZ9e9dk rej:e9d!Z4Gd"d#d#e2Z;d6d%d&ZGd+d,d,e2Z?d7d-d.Z@d9d/d0ZAGd1d2d2eZBdS):z+ Helpers for embarrassingly parallel code. )divisionN)sqrt)uuid4)Integral)mp)Loggershort_format_time)memstr_to_bytes)FallbackToBackendMultiprocessingBackendThreadingBackendSequentialBackend LokyBackend)dumpsloads)loky) eval_expr)AutoBatchingMixin)ParallelBackendBase)multiprocessing threading sequentialrrr processesthreads sharedmemcCsPyddlm}td|Wn0tk rJ}zd}t||WYdd}~XnXdS)z? Register Dask Backend if called with parallel_backend("dask") r)DaskDistributedBackenddaskzTo use the dask.distributed backend you must install both the `dask` and distributed modules. See https://dask.pydata.org/en/latest/install.html for more information.N)Z_daskrregister_parallel_backend ImportError)remsgr"9/usr/local/lib/python3.6/site-packages/joblib/parallel.py_register_dask;s  r$rc Cs|tkrtd|tf|tkr0td|tf|dkrH|dkrHtdttdd}|dk r|\}}|j}t|dd }|dkr| rtt|d }|d krtd |j j |j j f|t fS|Stt d d }t|dd }t|dd } |dkr| s|dkr| rttd d }|t fS)z!Return the active default backendz9prefer=%r is not a valid backend hint, expected one of %rz@require=%r is not a valid backend constraint, expected one of %rrrzJprefer == 'processes' and require == 'sharedmem' are inconsistent settingsbackend_and_jobsNsupports_sharedmemF) nesting_level ziUsing %s as joblib.Parallel backend instead of %s as the latter does not provide shared memory semantics.r uses_threadsr) VALID_BACKEND_HINTS ValueErrorVALID_BACKEND_CONSTRAINTSgetattr_backendr'BACKENDSDEFAULT_THREAD_BACKENDprint __class____name__DEFAULT_N_JOBSDEFAULT_BACKEND) preferrequireverboser%backendn_jobsr'r&Zsharedmem_backendr)r"r"r#get_active_backendMs:      r;c@s2eZdZdZd ddZddZdd Zd d ZdS)parallel_backenda Change the default backend used by Parallel inside a with block. If ``backend`` is a string it must match a previously registered implementation using the ``register_parallel_backend`` function. By default the following backends are available: - 'loky': single-host, process-based parallelism (used by default), - 'threading': single-host, thread-based parallelism, - 'multiprocessing': legacy single-host, process-based parallelism. 'loky' is recommended to run functions that manipulate Python objects. 'threading' is a low-overhead alternative that is most efficient for functions that release the Global Interpreter Lock: e.g. I/O-bound code or CPU-bound code in a few calls to native code that explicitly releases the GIL. In addition, if the `dask` and `distributed` Python packages are installed, it is possible to use the 'dask' backend for better scheduling of nested parallel calls without over-subscription and potentially distribute parallel calls over a networked cluster of several hosts. It is also possible to use the distributed 'ray' backend for distributing the workload to a cluster of nodes. To use the 'ray' joblib backend add the following lines:: >>> from ray.util.joblib import register_ray # doctest: +SKIP >>> register_ray() # doctest: +SKIP >>> with parallel_backend("ray"): # doctest: +SKIP ... print(Parallel()(delayed(neg)(i + 1) for i in range(5))) [-1, -2, -3, -4, -5] Alternatively the backend can be passed directly as an instance. By default all available workers will be used (``n_jobs=-1``) unless the caller passes an explicit value for the ``n_jobs`` parameter. This is an alternative to passing a ``backend='backend_name'`` argument to the ``Parallel`` class constructor. It is particularly useful when calling into library code that uses joblib internally but does not expose the backend argument in its own API. >>> from operator import neg >>> with parallel_backend('threading'): ... print(Parallel()(delayed(neg)(i + 1) for i in range(5))) ... [-1, -2, -3, -4, -5] Warning: this function is experimental and subject to change in a future version of joblib. Joblib also tries to limit the oversubscription by limiting the number of threads usable in some third-party library threadpools like OpenBLAS, MKL or OpenMP. The default limit in each worker is set to ``max(cpu_count() // effective_n_jobs, 1)`` but this limit can be overwritten with the ``inner_max_num_threads`` argument which will be used to set this limit in the child processes. .. versionadded:: 0.10 rNc Kst|tr6|tkr(|tkr(t|}|t|f|}|dk r`dj|jj}|jsZt|||_ t t dd}|j dkr|dkrd}n |dj }||_ ||_ ||f|_||ft _dS)Nz>{} does not accept setting the inner_max_num_threads argument.r%r) isinstancestrr/EXTERNAL_BACKENDSformatr2r3Zsupports_inner_max_num_threadsAssertionErrorinner_max_num_threadsr-r.r'old_backend_and_jobsnew_backend_and_jobsr%) selfr9r:rBZbackend_paramsregisterr!Zcurrent_backend_and_jobsr'r"r"r#__init__s&      zparallel_backend.__init__cCs|jS)N)rD)rEr"r"r# __enter__szparallel_backend.__enter__cCs |jdS)N) unregister)rEtypevalue tracebackr"r"r#__exit__szparallel_backend.__exit__cCs,|jdkr ttdddk r(t`n|jt_dS)Nr%)rCr-r.r%)rEr"r"r#rIs zparallel_backend.unregister)rNN)r3 __module__ __qualname____doc__rGrHrMrIr"r"r"r#r<{s = r< get_contextZJOBLIB_START_METHOD)methodc@s2eZdZdZd ddZddZddZd d ZdS) BatchedCallszCWrap a sequence of (func, args, kwargs) tuples as a single callableNcCsXt||_t|j|_||_t|tr4|\|_|_n|d|_|_|dk rN|ni|_ dS)N) listitemslen_size_reducer_callbackr=tupler._n_jobs _pickle_cache)rEZiterator_slicer%Zreducer_callbackZ pickle_cacher"r"r#rGs   zBatchedCalls.__init__c Cs,t|j|jddd|jDSQRXdS)N)r:cSsg|]\}}}|||qSr"r").0funcargskwargsr"r"r# sz)BatchedCalls.__call__..)r<r.r\rW)rEr"r"r#__call__szBatchedCalls.__call__cCs.|jdk r|jt|j|j|jfd|jffS)N)rZrUrWr.r\r])rEr"r"r# __reduce__ s  zBatchedCalls.__reduce__cCs|jS)N)rY)rEr"r"r#__len__szBatchedCalls.__len__)NN)r3rOrPrQrGrcrdrer"r"r"r#rUs   rUFcCstdkr dStj|dS)aReturn the number of CPUs. This delegates to loky.cpu_count that takes into account additional constraints such as Linux CFS scheduler quotas (typically set by container runtimes such as docker) and CPU affinity (for instance using the taskset command on Linux). If only_physical_cores is True, do not take hyperthreading / SMT logical cores into account. Nr)only_physical_cores)rr cpu_count)rfr"r"r#rgs rgcCs\|sdS|dkrdS|dkr dSdd|d}t||}t|d|}t|t|kS) z Returns False for indices increasingly apart, the distance depending on the value of verbose. We use a lag increasing as the square of index Tr(Frg? r)rint)indexr8ZscaleZ next_scaler"r"r#_verbosity_filter/s rlc s8fdd}ytj|}Wntk r2YnX|S)z6Decorator used to capture the arguments of a function.cs ||fS)Nr")r`ra)functionr"r#delayed_functionEsz!delayed..delayed_function) functoolswrapsAttributeError)rmrnr")rmr#delayedBs  rrc@s eZdZdZddZddZdS)BatchCompletionCallBacka_Callback used by joblib.Parallel's multiprocessing backend. This callable is executed by the parent process whenever a worker process has returned the results of a batch of tasks. It is used for progress reporting, to update estimate of the batch processing duration and to schedule the next batch of tasks to be processed. cCs||_||_||_dS)N)dispatch_timestamp batch_sizeparallel)rErtrurvr"r"r#rGZsz BatchCompletionCallBack.__init__c Csj|jj|j7_tj|j}|jjj|j||jj|jj|jj dk r\|jj WdQRXdS)N) rvn_completed_tasksrutimertr.Zbatch_completedprint_progress_lock_original_iterator dispatch_next)rEoutZthis_batch_durationr"r"r#rc_s    z BatchCompletionCallBack.__call__N)r3rOrPrQrGrcr"r"r"r#rsOs rscCs|t|<|r|adS)aRegister a new Parallel backend factory. The new backend can then be selected by passing its name as the backend argument to the Parallel class. Moreover, the default backend can be overwritten globally by setting make_default=True. The factory can be any callable that takes no argument and return an instance of ``ParallelBackendBase``. Warning: this function is experimental and subject to change in a future version of joblib. .. versionadded:: 0.10 N)r/r5)namefactoryZ make_defaultr"r"r#rlsrcCs"t\}}|dkr|}|j|dS)afDetermine the number of jobs that can actually run in parallel n_jobs is the number of workers requested by the callers. Passing n_jobs=-1 means requesting all available workers for instance matching the number of CPU cores on the worker host(s). This method should return a guesstimate of the number of workers that can actually perform work concurrently with the currently enabled default backend. The primary use case is to make it possible for the caller to know in how many chunks to slice the work. In general working on larger data chunks is more efficient (less scheduling overhead and better use of CPU cache prefetching heuristics) as long as all the workers have enough work to do. Warning: this function is experimental and subject to change in a future version of joblib. .. versionadded:: 0.10 N)r:)r;effective_n_jobs)r:r9Zbackend_n_jobsr"r"r#rs rc @seZdZdZd$dd Zd d Zd d ZddZddZddZ ddZ ddZ ddZ ddZ ddZddZd d!Zd"d#ZdS)%Parallela, Helper class for readable parallel mapping. Read more in the :ref:`User Guide `. Parameters ----------- n_jobs: int, default: None The maximum number of concurrently running jobs, such as the number of Python worker processes when backend="multiprocessing" or the size of the thread-pool when backend="threading". If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. For n_jobs below -1, (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used. None is a marker for 'unset' that will be interpreted as n_jobs=1 (sequential execution) unless the call is performed under a parallel_backend context manager that sets another value for n_jobs. backend: str, ParallelBackendBase instance or None, default: 'loky' Specify the parallelization backend implementation. Supported backends are: - "loky" used by default, can induce some communication and memory overhead when exchanging input and output data with the worker Python processes. - "multiprocessing" previous process-based backend based on `multiprocessing.Pool`. Less robust than `loky`. - "threading" is a very low-overhead backend but it suffers from the Python Global Interpreter Lock if the called function relies a lot on Python objects. "threading" is mostly useful when the execution bottleneck is a compiled extension that explicitly releases the GIL (for instance a Cython loop wrapped in a "with nogil" block or an expensive call to a library such as NumPy). - finally, you can register backends by calling register_parallel_backend. This will allow you to implement a backend of your liking. It is not recommended to hard-code the backend name in a call to Parallel in a library. Instead it is recommended to set soft hints (prefer) or hard constraints (require) so as to make it possible for library users to change the backend from the outside using the parallel_backend context manager. prefer: str in {'processes', 'threads'} or None, default: None Soft hint to choose the default backend if no specific backend was selected with the parallel_backend context manager. The default process-based backend is 'loky' and the default thread-based backend is 'threading'. Ignored if the ``backend`` parameter is specified. require: 'sharedmem' or None, default None Hard constraint to select the backend. If set to 'sharedmem', the selected backend will be single-host and thread-based even if the user asked for a non-thread based backend with parallel_backend. verbose: int, optional The verbosity level: if non zero, progress messages are printed. Above 50, the output is sent to stdout. The frequency of the messages increases with the verbosity level. If it more than 10, all iterations are reported. timeout: float, optional Timeout limit for each task to complete. If any task takes longer a TimeOutError will be raised. Only applied when n_jobs != 1 pre_dispatch: {'all', integer, or expression, as in '3*n_jobs'} The number of batches (of tasks) to be pre-dispatched. Default is '2*n_jobs'. When batch_size="auto" this is reasonable default and the workers should never starve. Note that only basic arithmetics are allowed here and no modules can be used in this expression. batch_size: int or 'auto', default: 'auto' The number of atomic tasks to dispatch at once to each worker. When individual evaluations are very fast, dispatching calls to workers can be slower than sequential computation because of the overhead. Batching fast computations together can mitigate this. The ``'auto'`` strategy keeps track of the time it takes for a batch to complete, and dynamically adjusts the batch size to keep the time on the order of half a second, using a heuristic. The initial batch size is 1. ``batch_size="auto"`` with ``backend="threading"`` will dispatch batches of a single task at a time as the threading backend has very little overhead and using larger batch size has not proved to bring any gain in that case. temp_folder: str, optional Folder to be used by the pool for memmapping large arrays for sharing memory with worker processes. If None, this will try in order: - a folder pointed by the JOBLIB_TEMP_FOLDER environment variable, - /dev/shm if the folder exists and is writable: this is a RAM disk filesystem available by default on modern Linux distributions, - the default system temporary folder that can be overridden with TMP, TMPDIR or TEMP environment variables, typically /tmp under Unix operating systems. Only active when backend="loky" or "multiprocessing". max_nbytes int, str, or None, optional, 1M by default Threshold on the size of arrays passed to the workers that triggers automated memory mapping in temp_folder. Can be an int in Bytes, or a human-readable string, e.g., '1M' for 1 megabyte. Use None to disable memmapping of large arrays. Only active when backend="loky" or "multiprocessing". mmap_mode: {None, 'r+', 'r', 'w+', 'c'}, default: 'r' Memmapping mode for numpy arrays passed to workers. None will disable memmapping, other modes defined in the numpy.memmap doc: https://numpy.org/doc/stable/reference/generated/numpy.memmap.html Also, see 'max_nbytes' parameter documentation for more details. Notes ----- This object uses workers to compute in parallel the application of a function to many different arguments. The main functionality it brings in addition to using the raw multiprocessing or concurrent.futures API are (see examples for details): * More readable code, in particular since it avoids constructing list of arguments. * Easier debugging: - informative tracebacks even when the error happens on the client side - using 'n_jobs=1' enables to turn off parallel computing for debugging without changing the codepath - early capture of pickling errors * An optional progress meter. * Interruption of multiprocesses jobs with 'Ctrl-C' * Flexible pickling control for the communication to and from the worker processes. * Ability to use shared memory efficiently with worker processes for large numpy-based datastructures. Examples -------- A simple example: >>> from math import sqrt >>> from joblib import Parallel, delayed >>> Parallel(n_jobs=1)(delayed(sqrt)(i**2) for i in range(10)) [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] Reshaping the output when the function has several return values: >>> from math import modf >>> from joblib import Parallel, delayed >>> r = Parallel(n_jobs=1)(delayed(modf)(i/2.) for i in range(10)) >>> res, i = zip(*r) >>> res (0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5) >>> i (0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0) The progress meter: the higher the value of `verbose`, the more messages: >>> from time import sleep >>> from joblib import Parallel, delayed >>> r = Parallel(n_jobs=2, verbose=10)(delayed(sleep)(.2) for _ in range(10)) #doctest: +SKIP [Parallel(n_jobs=2)]: Done 1 tasks | elapsed: 0.6s [Parallel(n_jobs=2)]: Done 4 tasks | elapsed: 0.8s [Parallel(n_jobs=2)]: Done 10 out of 10 | elapsed: 1.4s finished Traceback example, note how the line of the error is indicated as well as the values of the parameter passed to the function that triggered the exception, even though the traceback happens in the child process: >>> from heapq import nlargest >>> from joblib import Parallel, delayed >>> Parallel(n_jobs=2)(delayed(nlargest)(2, n) for n in (range(4), 'abcde', 3)) #doctest: +SKIP #... --------------------------------------------------------------------------- Sub-process traceback: --------------------------------------------------------------------------- TypeError Mon Nov 12 11:37:46 2012 PID: 12934 Python 2.7.3: /usr/bin/python ........................................................................... /usr/lib/python2.7/heapq.pyc in nlargest(n=2, iterable=3, key=None) 419 if n >= size: 420 return sorted(iterable, key=key, reverse=True)[:n] 421 422 # When key is none, use simpler decoration 423 if key is None: --> 424 it = izip(iterable, count(0,-1)) # decorate 425 result = _nlargest(n, it) 426 return map(itemgetter(0), result) # undecorate 427 428 # General case, slowest method TypeError: izip argument #1 must support iteration ___________________________________________________________________________ Using pre_dispatch in a producer/consumer situation, where the data is generated on the fly. Note how the producer is first called 3 times before the parallel loop is initiated, and then called to generate new data on the fly: >>> from math import sqrt >>> from joblib import Parallel, delayed >>> def producer(): ... for i in range(6): ... print('Produced %s' % i) ... yield i >>> out = Parallel(n_jobs=2, verbose=100, pre_dispatch='1.5*n_jobs')( ... delayed(sqrt)(i) for i in producer()) #doctest: +SKIP Produced 0 Produced 1 Produced 2 [Parallel(n_jobs=2)]: Done 1 jobs | elapsed: 0.0s Produced 3 [Parallel(n_jobs=2)]: Done 2 jobs | elapsed: 0.0s Produced 4 [Parallel(n_jobs=2)]: Done 3 jobs | elapsed: 0.0s Produced 5 [Parallel(n_jobs=2)]: Done 4 jobs | elapsed: 0.0s [Parallel(n_jobs=2)]: Done 6 out of 6 | elapsed: 0.0s remaining: 0.0s [Parallel(n_jobs=2)]: Done 6 out of 6 | elapsed: 0.0s finished Nr 2 * n_jobsauto1Mrc Cst| | |d\} } | j}|dkr,|dkr,| }|dkr8d}||_||_||_||_tj|_t j |_ d|_ t |tr|t|}t|| || | td|jdd|_tdk rt|jd<nttdrtj|jd<|dkr| }nt |tr|jdkr||_nt|dr"t|d r"||jd<t|d }nVy t|}Wn>tk rl}z td |ttjf|WYdd}~XnX||d }| d krt|d d rtd||dkst |tr|dkr||_ n td|||_!d|_"t#|_$d|_%t&j'|_(dS)N)r6r7r8rr2) max_nbytes mmap_mode temp_folderr6r7r8contextrRPoolLock)r'z'Invalid backend: %s, expected one of %rrr&Fz)Backend %s does not support shared memoryrz8batch_size must be 'auto' or a positive integer, got: %r))r;r'r:r8timeout pre_dispatchqueueQueue_ready_batchesrhex_idrZr=r>r dictmax _backend_argsDEFAULT_MP_CONTEXThasattrrrRrr r/KeyErrorr+sortedkeysr-rrur._outputrV_jobs_managed_backendrRLockrz)rEr:r9r8rrrurrrr6r7Zactive_backendZcontext_n_jobsr'Zbackend_factoryr r"r"r#rGsp          (   zParallel.__init__cCsd|_|j|S)NT)r_initialize_backend)rEr"r"r#rHszParallel.__enter__cCs|jd|_dS)NF)_terminate_backendr)rEexc_type exc_valuerLr"r"r#rMszParallel.__exit__cCsyN|jjf|j|d|j}|jdk rL|jj rLtjdj|jj j |jWn2t k r}z|j |_|j }WYdd}~XnX|S)z?Build a process or thread pool and return the number of workers)r:rvNzThe backend class {!r} does not support timeout. You have set 'timeout={}' in Parallel but the 'timeout' parameter will not be used.)r. configurer:rrsupports_timeoutwarningswarnr@r2r3r r9r)rEr:r r"r"r#rs zParallel._initialize_backendcCs|jr|jj|jSdS)Nr)r.rr:)rEr"r"r#_effective_n_jobsszParallel._effective_n_jobscCs|jdk r|jjdS)N)r. terminate)rEr"r"r#rs zParallel._terminate_backendc Cs|jr dS|jt|7_|jd7_tj}t|t||}|j.t|j}|jj ||d}|jj ||WdQRXdS)zQueue the batch for computing, with or without multiprocessing WARNING: this method is not thread-safe: it should be only called indirectly via dispatch_one_batch. Nr)callback) _abortingn_dispatched_tasksrXn_dispatched_batchesrxrsrzrr.Z apply_asyncinsert)rEbatchrtcbZjob_idxjobr"r"r# _dispatchs zParallel._dispatchcCs|j|jsd|_d|_dS)aDispatch more data for parallel processing This method is meant to be called concurrently by the multiprocessing callback. We rely on the thread-safety of dispatch_one_batch to protect against concurrent consumption of the unprotected iterator. FN)dispatch_one_batchr{ _iterating)rEr"r"r#r|s zParallel.dispatch_nextc CsF|jdkr|jj}n|j}|jy|jjdd}Wntjk r|j}||}t t j ||}t |dkrzdS||j krt ||krtdt |d|}ntdt ||}xHtdt ||D]4}t|||||jj|j|j}|jj|qW|jjdd}YnXt |dkr*dS|j|dSWdQRXdS) aTPrefetch the tasks for the next batch and dispatch them. The effective size of the batch is computed here. If there are no more jobs to dispatch, return False, else return True. The iterator consumption and dispatching is protected by the same lock so calling this function should be thread safe. rF)blockrrr(TN)rur.Zcompute_batch_sizerzrgetrEmpty_cached_effective_n_jobsrV itertoolsislicerXr{rrangerUZget_nested_backendrZr]putr) rEiteratorrutasksr:Zbig_batch_sizerZfinal_batch_sizeir"r"r#r!s6       zParallel.dispatch_one_batchcCsB|js dS|jdkrtjj}ntjj}||}|d||fdS)z=Display the message on stout or stderr depending on verbosityNrz [%s]: %s )r8sysstderrwritestdout)rEr!Zmsg_argswriterr"r"r#_printcs  zParallel._printcCs|js dStj|j}|jdk rLt|j|jr4dS|jd|jt|fn|j}|j }|dks||d|j }||jd}|d|k}|s||rdS|||j |d}|jd||t|t|fdS)zvDisplay the process of the parallel execution only a fraction of time, controlled by self.verbose. Nz!Done %3i tasks | elapsed: %srrg?z/Done %3i out of %3i | elapsed: %s remaining: %s) r8rx _start_timer{rlrrrwr r_pre_dispatch_amount)rE elapsed_timerkZ total_taskscursorZ frequencyZ is_last_itemZremaining_timer"r"r#ryps2    zParallel.print_progresscCst|_x|jst|jdkrt|jdkr8tjdq |j|jjd}WdQRXy:t |j ddr~|jj |j |j dn|jj |j Wq tk r}z8d|_|j }|dk rt|dr|j}|j|dWYdd}~Xq Xq WdS) Nrg{Gz?rF)rTabort_everything) ensure_ready)rVrrrXrrxsleeprzpopr-r.extendrr BaseExceptionrrrr)rEr exceptionr9rr"r"r#retrieves&   zParallel.retrievec s jrtdd_js$j}nj}tjtrJfdd}|_ |_ jj j }|dkrnt d|jd||ftjdrjjt|}j}|d ks|d krd_d_n@|_t|d rt|jd t|}t|_}tj|j}tj_d_d_d_t _!zd_"j#|rDjdk _"xj#|rVqFW|d ksl|d krrd_"jj$j%WdQRXtjj}jd t&j't&j't(|fWdtjdr܈jj)jsj*t+_d_!Xj'}d_'|S)Nz)This Parallel instance is already runningFcsjjjjjdS)N)r.Z_workersZ_temp_folder_managerZset_current_contextrr")rEr"r#_batched_calls_reducer_callbacks z:Parallel.__call__.._batched_calls_reducer_callbackrz%s has no active worker.z,Using backend %s with %d concurrent workers. start_callallrendswithr:z*Done %3i out of %3i | elapsed: %s finished stop_call),rr+rrrrr=r.rrZrr2r3 RuntimeErrorrrriterrr{rrreplacer>rjrrrxrrrrwrr]rrZretrieval_contextrrXrr rrrV) rEiterabler:r backend_namerrroutputr")rEr#rcsp              zParallel.__call__cCsd|jj|jfS)Nz %s(n_jobs=%s))r2r3r:)rEr"r"r#__repr__6szParallel.__repr__) NNrNrrNrrNN)r3rOrPrQrGrHrMrrrrr|rrryrrcrr"r"r"r#rs&c Q B +(sr)rrN)rN)NNr)F)FrN)rN)CrQ __future__rosrmathrrorxrruuidrZnumbersrrrZ_multiprocessing_helpersrloggerrr Zdiskr Z_parallel_backendsr r r rrZexternals.cloudpicklerrZ externalsr_utilsrrrr/r5r4r0localr.r*r,r$r?r;objectr<rrenvironrstriprTrRrUrgrlrrrsrrrr"r"r"r#s`           .q   (