
    7Thr                         S SK r S SKJrJr  S SKJr  S SKJr  S SKJ	r	J
r
  S SKJr  S rS r " S	 S
\
5      r " S S\	5      rg)    N)Client_get_global_client)Worker)
filesystem)AbstractBufferedFileAbstractFileSysteminfer_storage_optionsc                 `    U c
  [        5       $ [        U [        5      (       a  U $ [        U 5      $ N)r   
isinstancer   )clients    S/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/implementations/dask.py_get_clientr   
   s.    ~!##	FF	#	# f~    c                  4    [        [        R                  5      $ r   )boolr   
_instances r   r   
_in_workerr      s    !!""r   c                   ~   ^  \ rS rSrSr SU 4S jjr\S 5       rS rS r	S r
S rS	 rS
 r    SS jrS rSrU =r$ )DaskWorkerFileSystem   a  View files accessible to a worker as any other remote file-system

When instances are run on the worker, uses the real filesystem. When
run on the client, they call the worker to provide information or data.

**Warning** this implementation is experimental, and read-only for now.
c                    > [         TU ]  " S0 UD6  US L US L -  (       d  [        S5      eXl        X l        S U l        X@l        X0l        U R                  5         g )NzKPlease provide one of filesystem instance (fs) or target_protocol, not bothr   )	super__init__
ValueErrortarget_protocoltarget_optionsworkerr   fs_determine_worker)selfr   r   r!   r   kwargs	__class__s         r   r   DaskWorkerFileSystem.__init__!   sc     	"6"d
$67-   /, r   c                 R    [        U 5      nSU;   a  SU;   a  SUS    SUS    30$ 0 $ )Nhostportr   :r	   )pathsos     r   _get_kwargs_from_urls*DaskWorkerFileSystem._get_kwargs_from_urls1   s<    "4(R<FbLFAbj\:;;Ir   c                 "   [        5       (       aD  SU l        U R                  c/  [        U R                  40 U R
                  =(       d    0 D6U l        g g SU l        [        U R                  5      U l        [        R                  " U 5      U l
        g )NTF)r   r    r!   r   r   r   r   r   daskdelayedrfsr#   s    r   r"   &DaskWorkerFileSystem._determine_worker9   so    <<DKww$((-1-@-@-FB 
  DK%dkk2DK||D)DHr   c                     U R                   (       a  U R                  R                  " U0 UD6  g U R                  R                  " U0 UD6R	                  5         g r   )r    r!   mkdirr2   computer#   argsr$   s      r   r6   DaskWorkerFileSystem.mkdirE   s<    ;;GGMM4*6*HHNND+F+335r   c                     U R                   (       a  U R                  R                  " U0 UD6  g U R                  R                  " U0 UD6R	                  5         g r   )r    r!   rmr2   r7   r8   s      r   r<   DaskWorkerFileSystem.rmK   <    ;;GGJJ''HHKK((002r   c                     U R                   (       a  U R                  R                  " U0 UD6  g U R                  R                  " U0 UD6R	                  5         g r   )r    r!   copyr2   r7   r8   s      r   r@   DaskWorkerFileSystem.copyQ   s<    ;;GGLL$)&)HHMM4*6*224r   c                     U R                   (       a  U R                  R                  " U0 UD6  g U R                  R                  " U0 UD6R	                  5         g r   )r    r!   mvr2   r7   r8   s      r   rC   DaskWorkerFileSystem.mvW   r>   r   c                     U R                   (       a  U R                  R                  " U0 UD6$ U R                  R                  " U0 UD6R	                  5       $ r   )r    r!   lsr2   r7   r8   s      r   rF   DaskWorkerFileSystem.ls]   sB    ;;77::t.v..88;;//7799r   c           
          U R                   (       a"  U R                  R                  " U4UUUUS.UD6$ [        SU UUUUUS.UD6$ )N)mode
block_size
autocommitcache_options)r!   r+   rI   rJ   rK   rL   r   )r    r!   _openDaskFile)r#   r+   rI   rJ   rK   rL   r$   s          r   rM   DaskWorkerFileSystem._openc   sn     ;;77==%%+    %%+  r   c                    U R                   (       a?  U R                  X5       nUR                  U5        UR                  XC-
  5      sS S S 5        $ U R                  R                  XX45      R                  5       $ ! , (       d  f       g = fr   )r    rM   seekreadr2   fetch_ranger7   )r#   r+   rI   startendfs         r   rS    DaskWorkerFileSystem.fetch_range   sc    ;;D'1uvvck* (' 88''E?GGII	 ('s   $A;;
B	)r   r!   r2   r   r   r    )NNNN)rbNTN)__name__
__module____qualname____firstlineno____doc__r   staticmethodr-   r"   r6   r<   r@   rC   rF   rM   rS   __static_attributes____classcell__r%   s   @r   r   r      se     JN!   
*6353: :J Jr   r   c                   B   ^  \ rS rSrSU 4S jjrSS jrS rS rSrU =r	$ )	rN      c                 H   > US:w  a  [        S5      e[        TU ]  " S0 UD6  g )NrX   z1Remote dask files can only be opened in "rb" moder   )r   r   r   )r#   rI   r$   r%   s      r   r   DaskFile.__init__   s&    4<PQQ"6"r   c                     g r   r   )r#   finals     r   _upload_chunkDaskFile._upload_chunk   s    r   c                     g)zCreate remote file/uploadNr   r3   s    r   _initiate_uploadDaskFile._initiate_upload   s    r   c                 d    U R                   R                  U R                  U R                  X5      $ )z*Get the specified set of bytes from remote)r!   rS   r+   rI   )r#   rT   rU   s      r   _fetch_rangeDaskFile._fetch_range   s#    ww""499diiDDr   r   )rX   )F)
rY   rZ   r[   r\   r   rh   rk   rn   r_   r`   ra   s   @r   rN   rN      s    #
E Er   rN   )r0   distributed.clientr   r   distributed.workerr   fsspecr   fsspec.specr   r   fsspec.utilsr
   r   r   r   rN   r   r   r   <module>ru      sB     9 %  @ .#nJ- nJbE# Er   