/usr/local/lib/python3.6/site-packages/datasets/__pycache__
NameSizeModeActions
arrow_dataset.cpython-36.pyc1898500644editdlrm
arrow_reader.cpython-36.pyc224830644editdlrm
arrow_writer.cpython-36.pyc221100644editdlrm
builder.cpython-36.pyc527790644editdlrm
combine.cpython-36.pyc55080644editdlrm
config.cpython-36.pyc51810644editdlrm
dataset_dict.cpython-36.pyc833190644editdlrm
data_files.cpython-36.pyc301530644editdlrm
fingerprint.cpython-36.pyc189790644editdlrm
info.cpython-36.pyc173590644editdlrm
inspect.cpython-36.pyc185830644editdlrm
iterable_dataset.cpython-36.pyc629320644editdlrm
keyhash.cpython-36.pyc33410644editdlrm
load.cpython-36.pyc629220644editdlrm
metric.cpython-36.pyc232170644editdlrm
naming.cpython-36.pyc25710644editdlrm
search.cpython-36.pyc313390644editdlrm
splits.cpython-36.pyc225220644editdlrm
streaming.cpython-36.pyc41190644editdlrm
table.cpython-36.pyc796120644editdlrm
__init__.cpython-36.pyc22820644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/datasets/__pycache__/fingerprint.cpython-36.pyc (18979B)
3 <%EgW@s8UddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZddlZddlZddlZddlmZddlmZddlmZmZmZmZdd l m!Z!dd l"m#Z#dd l$m%Z%m&Z&e rdd l'm(Z(e#e)Z*d a+da,ed,da-eej.-GdddZ/ddZ0ddZ1ddZ2ddZ3e!de4dddZ5e4dddZ6e7ddd Z8d!d"Z9Gd#d$d$Z:e9ejeeeed%d&Z;e9ed'd(Zd7e7dd,d-Z?d.d/Z@d8e7d0d1d2ZAd9e4eee7eee7eee7e4ee7d4d5d6ZBdS):N)wraps)Path) TYPE_CHECKINGAnyDictListOptionalUnion) DatasetInfo)"INVALID_WINDOWS_CHARACTERS_IN_PATH)ConcatenationTable InMemoryTableMemoryMappedTableTable) deprecated) get_logger)asdictdumps)DatasetT_TempDirWithCustomCleanupc@s*eZdZdZd ddZddZddZdS) rz A temporary directory with a custom cleanup function. We need a custom temporary directory cleanup in order to delete the dataset objects that have cache files in the temporary directory before deleting the dorectory itself. NcOs0tj|_tj||j|_||_||_||_ dS)N) tempfilemkdtempnameweakreffinalize_cleanup _finalizer _cleanup_func_cleanup_func_args_cleanup_func_kwargs)self cleanup_funcZcleanup_func_argsZcleanup_func_kwargsr#>/usr/local/lib/python3.6/site-packages/datasets/fingerprint.py__init__8s  z"_TempDirWithCustomCleanup.__init__cCs.|j|j|jtjj|jr*tj|jdS)N) rrr ospathexistsrshutilrmtree)r!r#r#r$r?sz"_TempDirWithCustomCleanup._cleanupcCs|jjr|jdS)N)rdetachr)r!r#r#r$cleanupDs z!_TempDirWithCustomCleanup.cleanup)N)__name__ __module__ __qualname____doc__r%rr,r#r#r#r$r1s cCs>tdkr dStdkrtjatdd|jDr:tj|dS)a This function registers the datasets that have cache files in _TEMP_DIR_FOR_TEMP_CACHE_FILES in order to properly delete them before deleting the temporary directory. The temporary directory _TEMP_DIR_FOR_TEMP_CACHE_FILES is used when caching is disabled. Ncss&|]}ttjt|djkVqdS)filenameN)r_TEMP_DIR_FOR_TEMP_CACHE_FILESrparents).0 cache_filer#r#r$ Vsz?maybe_register_dataset_for_temp_dir_deletion..)r2 _DATASETS_WITH_TABLE_IN_TEMP_DIRrWeakSetany cache_filesadd)datasetr#r#r$,maybe_register_dataset_for_temp_dir_deletionIs r=cCstdk rttSgS)N)r7listr#r#r#r$(get_datasets_with_cache_file_in_temp_dir\sr?cCsdadS)a When applying transforms on a dataset, the data are stored in cache files. The caching mechanism allows to reload an existing cache file if it's already been computed. Reloading a dataset is possible since the cache files are named using the dataset fingerprint, which is updated after each transform. If disabled, the library will no longer reload cached datasets files when applying transforms to the datasets. More precisely, if the caching is disabled: - cache files are always recreated - cache files are written to a temporary directory that is deleted when session closes - cache files are named using a random hash instead of the dataset fingerprint - use :func:`datasets.Dataset.save_to_disk` to save a transformed dataset or it will be deleted when session closes - caching doesn't affect :func:`datasets.load_dataset`. If you want to regenerate a dataset from scratch you should use the ``download_mode`` parameter in :func:`datasets.load_dataset`. TN)_CACHING_ENABLEDr#r#r#r$enable_caching`srAcCsdadS)a When applying transforms on a dataset, the data are stored in cache files. The caching mechanism allows to reload an existing cache file if it's already been computed. Reloading a dataset is possible since the cache files are named using the dataset fingerprint, which is updated after each transform. If disabled, the library will no longer reload cached datasets files when applying transforms to the datasets. More precisely, if the caching is disabled: - cache files are always recreated - cache files are written to a temporary directory that is deleted when session closes - cache files are named using a random hash instead of the dataset fingerprint - use :func:`datasets.Dataset.save_to_disk` to save a transformed dataset or it will be deleted when session closes - caching doesn't affect :func:`datasets.load_dataset`. If you want to regenerate a dataset from scratch you should use the ``download_mode`` parameter in :func:`datasets.load_dataset`. FN)r@r#r#r#r$disable_cachingusrBzUse datasets.enable_caching() or datasets.disable_caching() instead. This function will be removed in a future version of datasets.)booleancCs t|adS)a When applying transforms on a dataset, the data are stored in cache files. The caching mechanism allows to reload an existing cache file if it's already been computed. Reloading a dataset is possible since the cache files are named using the dataset fingerprint, which is updated after each transform. If disabled, the library will no longer reload cached datasets files when applying transforms to the datasets. More precisely, if the caching is disabled: - cache files are always recreated - cache files are written to a temporary directory that is deleted when session closes - cache files are named using a random hash instead of the dataset fingerprint - use :func:`datasets.Dataset.save_to_disk` to save a transformed dataset or it will be deleted when session closes - caching doesn't affect :func:`datasets.load_dataset`. If you want to regenerate a dataset from scratch you should use the ``download_mode`` parameter in :func:`datasets.load_dataset`. N)boolr@)rCr#r#r$set_caching_enabledsrE)returncCsttS)a When applying transforms on a dataset, the data are stored in cache files. The caching mechanism allows to reload an existing cache file if it's already been computed. Reloading a dataset is possible since the cache files are named using the dataset fingerprint, which is updated after each transform. If disabled, the library will no longer reload cached datasets files when applying transforms to the datasets. More precisely, if the caching is disabled: - cache files are always recreated - cache files are written to a temporary directory that is deleted when session closes - cache files are named using a random hash instead of the dataset fingerprint - use :func:`datasets.Dataset.save_to_disk` to save a transformed dataset or it will be deleted when session closes - caching doesn't affect :func:`datasets.load_dataset`. If you want to regenerate a dataset from scratch you should use the ``download_mode`` parameter in :func:`datasets.load_dataset`. )rDr@r#r#r#r$is_caching_enabledsrGcCs tdkrdd}t|datjS)z7Return a directory that is deleted when session closes.NcSsxtD] }|jqWdS)N)r?__del__)Zdsetr#r#r$r"s z9get_temporary_cache_files_directory..cleanup_func)r")r2rr)r"r#r#r$#get_temporary_cache_files_directorys rIcsfdd}|S)NcsxD]}|tj|<qW|S)N)Hasherdispatch)funct)typesr#r$proxys zhashregister..proxyr#)rNrOr#)rNr$ hashregisters rPc@seZdZUdZiZeddZeee e e fe dddZ ee e dddZee e dd d Ze d dd d Ze dddZd S)rJz-Hasher that accepts python objects as inputs.cCstj|_dS)N)xxhashxxh64m)r!r#r#r$r%szHasher.__init__)valuerFcCs<t|tr|gn|}tj}x|D]}|j|q"W|jS)N) isinstancebytesrQrRupdate hexdigest)clsrTrSxr#r#r$ hash_bytess  zHasher.hash_bytescCs|jt|S)N)r[r)rYrTr#r#r$ hash_defaultszHasher.hash_defaultcCs0t||jkr"|jt|||S|j|SdS)N)typerKr\)rYrTr#r#r$hashsz Hasher.hashNcCsBdt|d}|j|}|jj|jd|jj|jddS)Nz==utf8zutf-8)r]r^rSrWencode)r!rTZheader_for_updateZvalue_for_updater#r#r$rWs z Hasher.update)rFcCs |jjS)N)rSrX)r!r#r#r$rXszHasher.hexdigest)r-r.r/r0rKrr% classmethodr rVrstrr[rr\r^rWrXr#r#r#r$rJs rJcs<fdddjfddtjDjjdS)Ncs:t|tjr"jdd|jDSj|jjdSdS)Ncss|]}|jjdVqdS)zutf-8N) to_stringr`)r4cr#r#r$r6sz9_hash_pa_table.._hash_pa_array..zutf-8)rUpaZ ChunkedArrayr[chunksrcr`)rT)hasherr#r$_hash_pa_arrays z&_hash_pa_table.._hash_pa_array-c3s"|]}|d|VqdS)riNr#)r4col)rhrTr#r$r6sz!_hash_pa_table..zutf-8)joinsortedZ column_namesr[r`)rgrTr#)rhrgrTr$_hash_pa_tables  rmcCs|jtjt|ddjdS)NT) sort_keyszutf-8)r[jsonrrr`)rgrTr#r#r$_hash_dataset_info srpcCsn|j}t}x2t|D]&}|dkr$q|j||j||qWx$|jD]}|jtjj|dqHW|jS)N _fingerprintr1) __dict__rJrlrWr:r&r'getmtimerX)r<statergkeyr5r#r#r$generate_fingerprints  rv@cCstj|d|ddS)N0rZ)random getrandbits)nbitsr#r#r$generate_random_fingerprint%sr}cCsFt}|j|y|j|Wn^trftjddsRtjd|ddtd<qxtjd|dntjd|dtSxt |D]}|j|y|j||Wqtrtjddstjd|d ||d |ddtd<n"tjd|d ||d |dn"tjd|d ||d |dtSqW|j S) NZ(update_fingerprint_transform_hash_failedFz Transform a couldn't be hashed properly, a random hash was used instead. Make sure your transforms and parameters are serializable with pickle or dill for the dataset fingerprinting and caching to work. If you reuse this transform, the caching mechanism will consider it to be different from the previous calls and recompute everything. This warning is only showed once. Subsequent hashing failures won't be showed.Tz= couldn't be hashed properly, a random hash was used instead.zn couldn't be hashed properly, a random hash was used instead. This doesn't affect caching since it's disabled.z Parameter 'z'=z of the transform ) rJrWr@fingerprint_warningsgetloggerwarninginfor}rlrX) fingerprint transformZtransform_argsrgrur#r#r$update_fingerprint)s<        r)rcCs~t|t s| r"td|dx*tD]"}||kr(tdtd|dq(Wt||krztd|d|dt|d d S) z Make sure the fingerprint is a non-empty string that is not longer that max_length=64 by default, so that the fingerprint can be used to name cache files without issues. zInvalid fingerprint 'z#': it should be a non-empty string.z5Invalid fingerprint. Bad characters from black list 'z ' found in 'z6'. They could create issues when creating cache files.z&Invalid fingerprint. Maximum lenth is z but 'z ' has length z2.It could create issues when creating cache files.N)rUrb ValueErrorr len)r max_lengthZ invalid_charr#r#r$validate_fingerprint[s  rF)inplace use_kwargs ignore_kwargsfingerprint_namesrandomized_functionversioncsdk r&tt r&tdtdk rLtt rLtdtr\r\tddk rhndgfdd}|S)a Wrapper for dataset transforms to update the dataset fingerprint using ``update_fingerprint`` Args: inplace (:obj:`bool`): If inplace is True, the fingerprint of the dataset is updated inplace. Otherwise, a parameter "new_fingerprint" is passed to the wrapped method that should take care of setting the fingerprint of the returned Dataset. use_kwargs (:obj:`List[str]`, optional): optional white list of argument names to take into account to update the fingerprint to the wrapped method that should take care of setting the fingerprint of the returned Dataset. By default all the arguments are used. ignore_kwargs (:obj:`List[str]`, optional): optional black list of argument names to take into account to update the fingerprint. Note that ignore_kwargs prevails on use_kwargs. fingerprint_names (:obj:`List[str]`, optional, defaults to ["new_fingerprint"]): If the dataset transforms is not inplace and returns a DatasetDict, then it can require several fingerprints (one per dataset in the DatasetDict). By specifying fingerprint_names, one fingerprint named after each element of fingerprint_names is going to be passed. randomized_function (:obj:`bool`, defaults to False): If the dataset transform is random and has optional parameters "seed" and "generator", then you can set randomized_function to True. This way, even if users set "seed" and "generator" to None, then the fingerprint is going to be randomly generated depending on numpy's current state. In this case, the generator is set to np.random.default_rng(np.random.get_state()[1][0]). version (:obj:`str`, optional): version of the transform. The version is taken into account when computing the fingerprint. If a datase transform changes (or at least if the output data that are cached changes), then one should increase the version. If the version stays the same, then old cached data could be reused that are not compatible with the new transform. It should be in the format "MAJOR.MINOR.PATCH". Nz)use_kwargs is supposed to be a list, not z,ignore_kwargs is supposed to be a list, not z5fingerprint_names are only used when inplace is Falsenew_fingerprintcs r&tfddD r&tdrbdjjkrFtdddjjkrbtddjd jdk rd 7tfd d }d |_|S)Nc3s|]}|jjkVqdS)N)__code__ co_varnames)r4r)rLr#r$r6sz>fingerprint_transform.._fingerprint..zFfunction {func} is missing parameters {fingerprint_names} in signatureseedz'seed' must be in z 's signature generatorz'generator' must be in .@cs|j}|rXddtjjjD}|d}|dd}|dd}|jt||n |jd}r|fdd|jD}rfdd|jD}r|j d dkr|j d dkrt j j ^}}}}|d kr||n|d}t j j ||d <d dtjjjD}x8|jD],\} } | |kr|| | kr|j| qWrZt|j|} nHxFD]>} |j | dkr| |d <t|j||| <n t|| q`W|f||} r| |_| S)NcSsg|]}||jkr|jqSr#) VAR_KEYWORDr)r4pr#r#r$ szPfingerprint_transform.._fingerprint..wrapper..rr r!csi|]\}}|kr||qSr#r#)r4kv)rr#r$ szPfingerprint_transform.._fingerprint..wrapper..csi|]\}}|kr||qSr#r#)r4rr)rr#r$rsrripcSs"i|]}|jtjkr|j|jqSr#)defaultinspect_emptyr)r4rr#r#r$rsfingerprint_name)copyr signature parametersvaluesrWzippopitemsrnprzZ get_stateZ default_rngrrqr)argskwargsZkwargs_for_fingerprintparamsr!_rposdefault_valuesZdefault_varname default_valuerrout)rrLrrrrrr#r$wrappersF     z._fingerprint..wrapperr)allrrrr.r/rZ_decorator_name_)rLr)rrrrrr)rLrr$rqs   <z+fingerprint_transform.._fingerprint)rUr>rr])rrrrrrrqr#)rrrrrrr$fingerprint_transformos$Nr)rw)rw)NNNFN)Crror&rzr)rr functoolsrpathlibrtypingrrrrrr ZnumpyrZpyarrowrerQrr Znamingr tabler rrrZutils.deprecation_utilsrZ utils.loggingrZutils.py_utilsrrZ arrow_datasetrr-rr@r2r7r8rr=r?rArBrDrErGrbrIrPrJrmrpr~rvr}rrrr#r#r#r$sb          *  2