/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__/info.cpython-36.pyc (17359B)
3 <%Eg$E@sJdZddlZddlZddlZddlZddlmZmZddlmZm Z m Z m Z ddl m Z ddlmZmZddlmZdd lmZmZdd lmZdd lmZdd lmZmZeeZeGd ddZeGdddZ Gddde!Z"Gddde!Z#eGdddZ$eGdddZ%Gdddee&e%fZ'eGdddZ(dS)a DatasetInfo and MetricInfo record information we know about a dataset and a metric. This includes things that we know about the dataset statically, i.e.: - description - canonical location - does it have validation and tests splits - size - etc. This also includes the things that can and should be computed once we've processed the dataset as well: - number of examples (in each split) - etc. N) dataclassfield)DictListOptionalUnion)config)FeaturesValue) SplitDict) TaskTemplatetask_template_from_dict)Version) get_logger)asdict unique_valuesc@seZdZUdZedZedS)SupervisedKeysDataN)__name__ __module__ __qualname__inputstroutputrr7/usr/local/lib/python3.6/site-packages/datasets/info.pyr2s rc@seZdZUdZedZedS)DownloadChecksumsEntryDatarN)rrrkeyrvaluerrrrr8s rc@seZdZdZdS)MissingCachedSizesConfigErrorz;The expected cached sizes of the download file are missing.N)rrr__doc__rrrrr >sr c@seZdZdZdS)NonMatchingCachedSizesErrorz/The prepared split doesn't have expected sizes.N)rrrr!rrrrr"Bsr"c@sBeZdZUdZeedZeeddZe eddddZ dS)PostProcessedInfoNcCs*|jdk r&t|jt r&tj|j|_dS)N)features isinstancer from_dict)selfrrr __post_init__KszPostProcessedInfo.__post_init__)post_processed_info_dictreturncs0ddtj|D|ffdd|jDS)NcSsh|] }|jqSr)name).0frrr Rsz.PostProcessedInfo.from_dict..csi|]\}}|kr||qSrr)r,kv) field_namesrr Ssz/PostProcessedInfo.from_dict..) dataclassesfieldsitems)clsr)r)r1rr&PszPostProcessedInfo.from_dict) rrrr$rr Zresources_checksumsdictr( classmethodr&rrrrr#Fs   r#c@szeZdZUdZeedZeeedZeeedZeeedZ e dZ e e  dZ e e dZe edZe eedZe edZe edZe eeefdZe edZe edZe edZe edZe edZ e e ddZ!ddZ"dd d Z#d d d Z$d dZ%e&eddddZ'e&eddddZ(e&eddddZ)d!ddddZ*ddddZ+dS)" DatasetInfoa Information about a dataset. `DatasetInfo` documents datasets, including its name, version, and features. See the constructor arguments and properties for a full list. Note: Not all fields are known on construction and may be updated later. Attributes: description (str): A description of the dataset. citation (str): A BibTeX citation of the dataset. homepage (str): A URL to the official homepage for the dataset. license (str): The dataset's license. It can be the name of the license or a paragraph containing the terms of the license. features (Features, optional): The features used to specify the dataset's column types. post_processed (PostProcessedInfo, optional): Information regarding the resources of a possible post-processing of a dataset. For example, it can contain the information of an index. supervised_keys (SupervisedKeysData, optional): Specifies the input feature and the label for supervised learning if applicable for the dataset (legacy from TFDS). builder_name (str, optional): The name of the :class:`GeneratorBasedBuilder` subclass used to create the dataset. Usually matched to the corresponding script name. It is also the snake_case version of the dataset builder class name. config_name (str, optional): The name of the configuration derived from :class:`BuilderConfig` version (str or Version, optional): The version of the dataset. splits (dict, optional): The mapping between split name and metadata. download_checksums (dict, optional): The mapping between the URL to download the dataset's checksums and corresponding metadata. download_size (int, optional): The size of the files to download to generate the dataset, in bytes. post_processing_size (int, optional): Size of the dataset in bytes after post-processing, if any. dataset_size (int, optional): The combined size in bytes of the Arrow tables for all splits. size_in_bytes (int, optional): The combined size in bytes of all files associated with the dataset (downloaded files + Arrow files). task_templates (List[TaskTemplate], optional): The task templates to prepare the dataset for during training and evaluation. Each template casts the dataset's :class:`Features` to standardized column names and types as detailed in :py:mod:`datasets.tasks`. **config_kwargs (additional keyword arguments): Keyword arguments to be passed to the :class:`BuilderConfig` and used in the :class:`DatasetBuilder`. )default_factoryNcsjdk r&tjt r&tjj_jdk rLtjt rLtjj_jdk rtjt rtjtr~tj_ntjj_j dk rtj t  rt j j _ j dk rtj t  rtj ttfrt j _ nt fj _ jdk rptjttfr6ddjD}dd|D_n:tjtrPjg_n tj}|dk rj|gng_jdk rtj_jdk rfddjD_dS)NcSs"g|]}t|tr|nt|qSr)r%r r)r,templaterrr sz-DatasetInfo.__post_init__..cSsg|]}|dk r|qS)Nr)r,r;rrrr<scsg|]}|jjqSr)Zalign_with_featuresr$)r,r;)r'rrr<s)r$r%r r&post_processedr#versionrrsplitsr Zfrom_split_dictsupervised_keysrtuplelisttask_templatesr r)r'Z templatesr;r)r'rr(s6        zDatasetInfo.__post_init__cCstjj|tjS)N)ospathjoinr LICENSE_FILENAME)r'dataset_info_dirrrr _license_pathszDatasetInfo._license_pathFcCsfttjj|tjd}|j||dWdQRX|jrbttjj|tjd}|j |WdQRXdS)aWrite `DatasetInfo` and license (if present) as JSON files to `dataset_info_dir`. Args: dataset_info_dir (str): Destination directory. pretty_print (bool, default ``False``): If True, the JSON will be pretty-printed with the indent level of 4. Example: ```py >>> from datasets import load_dataset >>> ds = load_dataset("rotten_tomatoes", split="validation") >>> ds.info.write_to_directory("/path/to/directory/") ``` wb) pretty_printN) openrDrErFr DATASET_INFO_FILENAME _dump_infolicenserG _dump_license)r'rHrKr-rrrwrite_to_directorys zDatasetInfo.write_to_directorycCs*|jtjt||rdnddjddS)zQDump info in `file` file-like object open in bytes mode (to support remote files)N)indentzutf-8)writejsondumpsrencode)r'filerKrrrrNszDatasetInfo._dump_infocCs|j|jjddS)zTDump license in `file` file-like object open in bytes mode (to support remote files)zutf-8N)rTrOrW)r'rXrrrrPszDatasetInfo._dump_license) dataset_infosc Csdd|D}djtdd|Dj}djtdd|Dj}djtdd|Dj}djtdd|Dj}d}d}d}d d|D} t| d krtt| d j| d d}nt| rtt| d }|r|nd}||||||||d S) NcSsg|]}|dk r|jqS)N)copy)r, dset_inforrrr<sz*DatasetInfo.from_merge..z css|] }|jVqdS)N) description)r,inforrr sz)DatasetInfo.from_merge..css|] }|jVqdS)N)citation)r,r]rrrr^scss|] }|jVqdS)N)homepage)r,r]rrrr^scss|] }|jVqdS)N)rO)r,r]rrrr^scSsg|]}|jdk r|jqS)N)rC)r,r]rrrr<srr)r\r_r`rOr$r@rC)rFrstriplenrBset intersection) r6rYr\r_r`rOr$r@rCZall_task_templatesrrr from_merges,   zDatasetInfo.from_merge)rHr*c CsTtjd||stdttjj|tjdd}t j |}WdQRX|j |S)aXCreate DatasetInfo from the JSON file in `dataset_info_dir`. This function updates all the dynamically generated fields (num_examples, hash, time of creation,...) of the DatasetInfo. This will overwrite all previous metadata. Args: dataset_info_dir (`str`): The directory containing the metadata file. This should be the root directory of a specific dataset version. Example: ```py >>> from datasets import DatasetInfo >>> ds_info = DatasetInfo.from_directory("/path/to/directory/") ``` zLoading Dataset info from zECalling DatasetInfo.from_directory() with undefined dataset_info_dir.zutf-8)encodingN) loggerr] ValueErrorrLrDrErFr rMrUloadr&)r6rHr-dataset_info_dictrrrfrom_directorys zDatasetInfo.from_directory)rjr*cs0ddtj|D|ffdd|jDS)NcSsh|] }|jqSr)r+)r,r-rrrr.sz(DatasetInfo.from_dict..csi|]\}}|kr||qSrr)r,r/r0)r1rrr2sz)DatasetInfo.from_dict..)r3r4r5)r6rjr)r1rr& szDatasetInfo.from_dictT)other_dataset_infocs*|j}|jffdd|jjDdS)Ncs*i|]"\}}|dk s rtj||qS)N)rZdeepcopy)r,r/r0) ignore_nonerrr2sz&DatasetInfo.update..)__dict__updater5)r'rlrnZ self_dictr)rnrrps zDatasetInfo.update)r*cCs|jfdd|jjDS)NcSsi|]\}}tj||qSr)rZrm)r,r/r0rrrr2sz$DatasetInfo.copy..) __class__ror5)r'rrrrZszDatasetInfo.copy)F)F)T),rrrr!rrr\r_r`rOr$rr r=r#r@rrCrr Z builder_name config_namer>rrr?r7Zdownload_checksums download_sizeintZpost_processing_sizeZ dataset_sizeZ size_in_bytesr(rIrQrNrPr8rerkr&rprZrrrrr9Vs>            )   r9c@s"eZdZdddZeddZdS)DatasetInfosDictFc Csi}tjj|tj}tjj|rD| rDtjd|d|j|}ntjd||j |t |ddd,}t j dd|j D||rd ndd WdQRXdS) Nz Dataset Infos already exists in z. Completing it with new infos.zWriting new Dataset Infos in wzutf-8)rfcSsi|]\}}t||qSr)r)r,rrr[rrrr2,sz7DatasetInfosDict.write_to_directory..rR)rS)rDrErFr DATASETDICT_INFOS_FILENAMEexistsrgr]rkrprLrUdumpr5)r'dataset_infos_dir overwriterKZtotal_dataset_infosZdataset_infos_pathr-rrrrQ!s  z#DatasetInfosDict.write_to_directoryc CsVtjd|ttjj|tjdd}ddtj |j D}WdQRX|f|S)NzLoading Dataset Infos from zutf-8)rfcSsi|]\}}tj||qSr)r9r&)r,rrrjrrrr25sz3DatasetInfosDict.from_directory..) rgr]rLrDrErFr rwrUrir5)r6rzr-Zdataset_infos_dictrrrrk1s zDatasetInfosDict.from_directoryN)FF)rrrrQr8rkrrrrru s ruc@seZdZUdZeeee edZ e e edZ e e edZ e e e dZeee e dZeedZedZeedZeedZeedZeeddZdddZedd d d Zeedd d dZdS) MetricInfoaInformation about a metric. `MetricInfo` documents a metric, including its name, version, and features. See the constructor arguments and properties for a full list. Note: Not all fields are known on construction and may be updated later. )r:FNcCsH|jdk rDx8|jjD]*\}}t|tstd|d|jjqWdS)NzSWhen using 'numpy' format, all features should be a `datasets.Value` feature. Here z is an instance of )formatr$r5r%r rhrqr)r'rrrrrr(Ws   zMetricInfo.__post_init__cCs~ttjj|tjddd"}tjt|||r0dnddWdQRX|j rzttjj|tj ddd}|j |j WdQRXdS)aWrite `MetricInfo` as JSON to `metric_info_dir`. Also save the license separately in LICENCE. If `pretty_print` is True, the JSON will be pretty-printed with the indent level of 4. Example: ```py >>> from datasets import load_metric >>> metric = load_metric("accuracy") >>> metric.info.write_to_directory("/path/to/directory/") ``` rvzutf-8)rfrRN)rS) rLrDrErFr METRIC_INFO_FILENAMErUryrrOrGrT)r'metric_info_dirrKr-rrrrQ`s &zMetricInfo.write_to_directory)r*c CsTtjd||stdttjj|tjdd}t j |}WdQRX|j |S)aCreate MetricInfo from the JSON file in `metric_info_dir`. Args: metric_info_dir: `str` The directory containing the metadata file. This should be the root directory of a specific dataset version. Example: ```py >>> from datasets import MetricInfo >>> metric_info = MetricInfo.from_directory("/path/to/directory/") ``` zLoading Metric info from zCCalling MetricInfo.from_directory() with undefined metric_info_dir.zutf-8)rfN) rgr]rhrLrDrErFr r~rUrir&)r6rr-metric_info_dictrrrrkts zMetricInfo.from_directory)rr*cs0ddtj|D|ffdd|jDS)NcSsh|] }|jqSr)r+)r,r-rrrr.sz'MetricInfo.from_dict..csi|]\}}|kr||qSrr)r,r/r0)r1rrr2sz(MetricInfo.from_dict..)r3r4r5)r6rr)r1rr&szMetricInfo.from_dict)F)rrrr!rr\r_r r$rZinputs_descriptionr`rOrBZ codebase_urlsrZreference_urlsZ streamableboolr}rZ metric_namerrZ experiment_idr(rQr8rkr7r&rrrrr|<s(      r|))r!rZr3rUrDrrtypingrrrrrr r$r r r?r tasksr rutilsrZ utils.loggingrZutils.py_utilsrrrrgrr Exceptionr r"r#r9rrur|rrrrs.    K