/usr/local/lib/python3.6/site-packages/datasets/io/__pycache__
NameSizeModeActions
abc.cpython-36.pyc12060644editdlrm
csv.cpython-36.pyc39960644editdlrm
json.cpython-36.pyc45970644editdlrm
parquet.cpython-36.pyc33190644editdlrm
text.cpython-36.pyc14930644editdlrm
__init__.cpython-36.pyc1450644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/datasets/io/__pycache__/json.cpython-36.pyc (4597B)
3 <%Ega@sddlZddlZddlmZmZmZddlZddlmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZmZd d lmZGd d d eZGd ddZdS)N)BinaryIOOptionalUnion)DatasetFeatures NamedSplitconfig) query_table)Json)logging)NestedDataStructureLikePathLike)AbstractDatasetReadercsFeZdZdeeeeeeee eedfdd Z ddZ Z S) JsonDatasetReaderNF) path_or_pathssplitfeatures cache_dirkeep_in_memoryfieldc sZtj|f||||d|||_t|tr2|n|j|i}tf||||d||_dS)N)rrrr)r data_filesrr)super__init__r isinstancedictrr builder)selfrrrrrrkwargs) __class__:/usr/local/lib/python3.6/site-packages/datasets/io/json.pyrs zJsonDatasetReader.__init__cCsJd}d}d}d}d}d}|jj||||||d|jj|j||jd}|S)NTF)download_config download_modeignore_verificationstry_from_hf_gcs base_pathuse_auth_token)rr%Z in_memory)rZdownload_and_prepareZ as_datasetrr)rr#r$r%r&r(r'datasetr!r!r"read's zJsonDatasetReader.read)NNNFN) __name__ __module__ __qualname__r rrrrstrboolrr* __classcell__r!r!)r r"rs .rc@sXeZdZd eeeefeeeedddZ edddZ dd Z eed d d Z dS)JsonDatasetWriterN)r) path_or_buf batch_sizenum_proccKsR|dk r |dkr td|d||_||_|r4|ntj|_||_d|_||_dS)Nrz num_proc z must be an integer > 0.zutf-8) ValueErrorr)r2r ZDEFAULT_MAX_BATCH_SIZEr3r4encodingto_json_kwargs)rr)r2r3r4r7r!r!r"r@szJsonDatasetWriter.__init__)returnc Cs|jjdd}|jjdd}|jjdd}|jjdd}|dkrPtd |d t|jtttjfrt j |jd |d }|j f|||d|j}WdQRXn0|rtd|d|j f|j||d|j}|S)Nr2orientrecordslinesT compressioninfergzipbz2xzz&`datasets` currently does not support z compressionwb)r<)file_objr9r;zUThe compression parameter is not supported when writing to a buffer, but compression=z1 was passed. Please provide a local path instead.)Nr=r>r?r@) r7popNotImplementedErrorrr2r.bytesosrfsspecopen_write)r_r9r;r<bufferwrittenr!r!r"writeRs&zJsonDatasetWriter.writecCsh|\}}}}t|jjt|||j|jjd}|jjfd||d|}|jds\|d7}|j |j S)N)tablekeyindices)r2r9r; ) r r)dataslicer3Z_indicesZ to_pandasto_jsonendswithencoder6)rargsoffsetr9r;r7batchjson_strr!r!r" _batch_jsongs   zJsonDatasetWriter._batch_json)rBr8c  sd}|jdks|jdkrlxtjtdt|j|jdtj ddD]$}|j|f}||j |7}qBWnt|j|j}} t j |jt} xltj| j |jfddtd|| D|| r|| dn|| dtj dd D]}||j |7}qWWdQRX|S) zWrites the pyarrow table as JSON lines to a binary file handle. Caller is responsible for opening and closing the handle. rNrbazCreating json from Arrow format)unitdisabledesccsg|]}|fqSr!r!).0rX)r;r9r7r!r" sz,JsonDatasetWriter._write..)totalr]r^r_) r4r Ztqdmrangelenr)r3Zis_progress_bar_enabledr[rMmultiprocessingPoolimap) rrBr9r;r7rLrXrZZnum_rowsr3poolr!)r;r9r7r"rIts*   zJsonDatasetWriter._write)NN) r+r,r-rrrrrintrrMr[rIr!r!r!r"r1?s & r1)rerFtypingrrrrGrrrr Z formattingr Zpackaged_modules.json.jsonr utilsr Z utils.typingr rabcrrr1r!r!r!r"s    0