+
    QV-jŒ  ã                   óú   € ^ RI t ^ RIHt ^ RIHtHt ^RIHt ^RIH	t	H
t
HtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHt ^RI H!t! ^RI"H#t# ]!! ]$4      t%]'       d   ^RI&H't' RR	 R
 llt(R R lt)R# )é    N)Úwraps)ÚTYPE_CHECKINGÚOptional)ÚDownloadConfig)Ú	xbasenameÚxdirnameÚ	xet_parseÚxexistsÚxgetsizeÚxglobÚ
xgzip_openÚxisdirÚxisfileÚxjoinÚxlistdirÚxnumpy_loadÚxopenÚxpandas_read_csvÚxpandas_read_excelÚxPathÚxpyarrow_parquet_read_tableÚxrelpathÚxsio_loadmatÚxsplitÚ	xsplitextÚxwalkÚxxml_dom_minidom_parse)Ú
get_logger)Úpatch_submodule©ÚDatasetBuilderc                ó:   € V ^8„  d   QhR\         \        ,          /# )é   Údownload_config)r   r   )Úformats   "Úc/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/datasets/streaming.pyÚ__annotate__r'   *   s   € ÷ A4ñ A4¼hÄ~Õ>Vñ A4ó    c                óì  a€ \         P                  ! V 4      p\        VR4      '       dk   VP                  '       dY   \	        VP                  \
        4      '       d7   SP                  VP                  n        SP                  VP                  n        R# V3R lp\        VRV! \        4      4      P                  4        \        VRV! \        4      4      P                  4        \        VRV! \        4      4      P                  4        \        VRV! \        4      4      P                  4        \        VR\        4      P                  4        \        VR	\        4      P                  4        \        VR
\         4      P                  4        \        VR\"        4      P                  4        \        VR\$        4      P                  4        \        VR\&        4      P                  4        \        VRV! \(        4      4      P                  4        \        VRV! \*        4      4      P                  4        \        VRV! \,        4      4      P                  4        \        VRV! \.        4      4      P                  4        \        VR\0        4      P                  4        \        VRV! \2        4      4      P                  4        \        VRV! \4        4      4      P                  4        \        VRV! \6        4      R.R7      P                  4        \        VRV! \8        4      R.R7      P                  4        \        VRV! \:        4      R.R7      P                  4        \        VRV! \<        4      4      P                  4        \        VRV! \>        4      4      P                  4        VP@                  PC                  R4      '       g&   \        VRV! \D        4      4      P                  4        SVn        R# )a  Extend the module to support streaming.

We patch some functions in the module to use `fsspec` to support data streaming:
- We use `fsspec.open` to open and read remote files. We patch the module function:
  - `open`
- We use the "::" hop separator to join paths and navigate remote compressed/archive files. We patch the module
  functions:
  - `os.path.join`
  - `pathlib.Path.joinpath` and `pathlib.Path.__truediv__` (called when using the "/" operator)

The patched functions are replaced with custom functions defined to work with the
:class:`~download.streaming_download_manager.StreamingDownloadManager`.

Args:
    module_path: Path to the module to be extended.
    download_config: Mainly use `token` or `storage_options` to support different platforms and auth types.
Ú_patched_for_streamingNc                 óB   <a € \        S 4      VV 3R  l4       pRVn        V# )c                  ó   <€ S! V R S/VB # ©r$   © )ÚargsÚkwargsr$   Úfunctions   *,€€r&   ÚwrapperÚ?extend_module_for_streaming.<locals>.wrap_auth.<locals>.wrapperG   s   ø€ á˜TÐM°?ÐMÀfÑMÐMr(   Ú	wrap_auth)r   Ú_decorator_name_)r1   r2   r$   s   f €r&   r4   Ú.extend_module_for_streaming.<locals>.wrap_authF   s*   ù€ Ü	ˆx‹õ	Nó 
ð	Nð $/ˆÔ Øˆr(   Úopenz
os.listdirzos.walkz	glob.globzos.path.joinzos.path.dirnamezos.path.basenamezos.path.relpathzos.path.splitzos.path.splitextzos.path.existszos.path.isdirzos.path.isfilezos.path.getsizezpathlib.Pathz	gzip.openz
numpy.loadzpandas.read_csvÚ__version__)Úattrszpandas.read_excelzscipy.io.loadmatzxml.etree.ElementTree.parsezxml.dom.minidom.parsezdatasets.packaged_modules.zpyarrow.parquet.read_table)#Ú	importlibÚimport_moduleÚhasattrr*   Ú
isinstancer   ÚtokenÚstorage_optionsr   r   Ústartr   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r	   r   Ú__name__Ú
startswithr   )Úmodule_pathr$   Úmoduler4   s   &f  r&   Úextend_module_for_streamingrE   *   sè  ø€ ô& ×$Ò$ [Ó1€Fô ˆvÐ/×0Ò0°V×5R×5RÐ5RÜ�f×3Ñ3´^×DÒDØ2A×2GÑ2GˆF×)Ñ)Ô/Ø<K×<[Ñ<[ˆF×)Ñ)Ô9Ùõô �F˜F¡I¬eÓ$4Ó5×;Ñ;Ô=Ü�F˜L©)´HÓ*=Ó>×DÑDÔFÜ�F˜I¡y´Ó'7Ó8×>Ñ>Ô@Ü�F˜K©´5Ó)9Ó:×@Ñ@ÔBä�F˜N¬EÓ2×8Ñ8Ô:Ü�FÐ-¬xÓ8×>Ñ>Ô@Ü�FÐ.´	Ó:×@Ñ@ÔBÜ�FÐ-¬xÓ8×>Ñ>Ô@Ü�F˜O¬VÓ4×:Ñ:Ô<Ü�FÐ.´	Ó:×@Ñ@ÔBä�FÐ,©i¼Ó.@ÓA×GÑGÔIÜ�F˜O©Y´vÓ->Ó?×EÑEÔGÜ�FÐ,©i¼Ó.@ÓA×GÑGÔIÜ�FÐ-©y¼Ó/BÓC×IÑIÔKÜ�F˜N¬EÓ2×8Ñ8Ô:ä�F˜K©´:Ó)>Ó?×EÑEÔGÜ�F˜L©)´KÓ*@ÓA×GÑGÔIÜ�FÐ-©yÔ9IÓ/JÐS`ÐRaÔb×hÑhÔjÜ�FÐ/±Ô;MÓ1NÐWdÐVeÔf×lÑlÔnÜ�FÐ.±	¼,Ó0GÐP]ÈÔ_×eÑeÔgÜ�FÐ9¹9ÄYÓ;OÓP×VÑVÔXÜ�FÐ3±YÔ?UÓ5VÓW×]Ñ]Ô_à�?‰?×%Ñ%Ð&B×CÒCÜ˜Ð <¹iÔHcÓ>dÓe×kÑkÔmØ$3€FÖ!r(   c                ó   € V ^8„  d   QhRR/# )r#   Úbuilderr!   r.   )r%   s   "r&   r'   r'   n   s   € ÷ Mñ MÐ2Bñ Mr(   c                ó€  € \        V P                  V P                  R7      p\        V P                  VR7       ^RIHp \        V 4      P                  R,           Uu. uF?  p\        W24      '       g   K  VP                  VP                  8w  g   K3  VP                  NKA  	  ppV F  p\        WQR7       K  	  R# u upi )zŸExtend the dataset builder module and the modules imported by it to support streaming.

Args:
    builder (:class:`DatasetBuilder`): Dataset builder instance.
)r?   r>   r-   r    :é   NNN)
r   r?   r>   rE   Ú
__module__rG   r!   ÚtypeÚ__mro__Ú
issubclass)rG   r$   r!   ÚclsÚparent_builder_modulesrD   s   &     r&   Ú$extend_dataset_builder_for_streamingrP   n   s¡   € ô %°W×5LÑ5LÐT[×TaÑTaÔb€OÜ × 2Ñ 2ÀOÕTõ
 (ô ˜“=×(Ñ(¨Ö,óá,ˆCÜ�c×*ô 	à/2¯~©~À×AZÑAZÑ/Zô 	ˆ�ŒÙ,ð ð ó
 )ˆÜ# F×Ló )ùòs   ÁB;Á5B;ÂB;)N)*r:   Ú	functoolsr   Útypingr   r   Údownload.download_configr   Úutils.file_utilsr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úutils.loggingr   Úutils.patchingr   rA   ÚloggerrG   r!   rE   rP   r.   r(   r&   Ú<module>rX      s]   ðÛ Ý ß *å 4÷÷ ÷ ÷ ÷ ÷ ñ õ2 &Ý +ñ 
�HÓ	€÷ Ý'÷A4÷HMr(   