
    mit                         d Z ddlZddlmZ ddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ  eed      Zd Zd	 Zd
efdZd
efdZy)z|
Allow to export and import XP hyper-params using base64 encoded string.
This allows easy sharing through paste, mails etc.
    N)partial   )DecoratedMain)fatal
simple_logzExport:c                     t        j                  t        j                  |       j	                               }t        j                  |      }t        j                  |j                               S )N)
zlibcompressjsondumpsencodebase64	b64encodetextwrapfilldecode)valuebitsb64s      D/var/www/stems/demucs_env/lib/python3.12/site-packages/dora/share.pydumpr      sG    ==E*1134D


4
 C==&&    c                    dj                  | j                  d      D cg c]  }|j                          c}      } t        j                  |       }t        j                  |      }t        j                  |j                               S c c}w )N 
)
joinsplitstripr   	b64decoder	   
decompressr   loadsr   )r   liner   jsoneds       r   loadr$       sa    
''CIIdO<D4::<<
=CC D__T"F::fmmo&& =s   B
mainc           	      P   g }| j                   D ]/  }	 |j                  |      }|j                  j                         1 t                t        t        |             t                t                y # t        $ r(}t        d| d|j                  d           Y d }~|d }~ww xY w)NzError loading XP : r   )	sigsget_xp_from_sigRuntimeErrorr   argsappendargvprintr   )r+   r%   all_argvsigxperrors         r   export_actionr3   '   s    Hyy !	>%%c*B 	 ! 
G	$x.	G	G  	>%cU"UZZ]O<==	>s   A44	B%=B  B%c                 d   g }t         j                  D ],  }|j                         }|s|r n|s|j                  |       . t	        dj                  |            }|D ]P  }|j                  |      }|j                  |       |j                  |      }t        d|j                   d|        R y )Nr   zImported XP r'   )sysstdinr   r,   r$   r   get_xpinit_xpget_namelogr0   )r+   r%   bufferr"   r/   r-   r1   names           r   import_actionr=   5   s    F		  zz|MM$  BGGFO$H -[[R}}R l266("TF+,	-r   )__doc__r   	functoolsr   r   r5   r   typingtpr	   r%   r   r:   r   r   r   r$   r3   r=    r   r   <module>rC      sW       
      "j)$''m -m -r   