o
    mi(                     @   sV   d dl Z d dlZd dlZd dlZd dlmZmZ ddlmZ	 dee
ef fddZdS )    N)AnyDict   )filesreturnc                  C   s   i } t jtjrVt jtjrVt d| d< ttj2}t	|
 D ]"\}}|d}td|r8t|}n
td|rBt|}|| |< q$W d   n1 sQw   Y  dt jv r}zi | tt jd } W | S  tjy|   tjdd	d
 Y | S w | S )a  Parses SageMaker configuration.

    Returns:
        A dictionary of SageMaker config keys/values
        or an empty dict if not found.
        SM_TRAINING_ENV is a json string of the
        training environment variables set by SageMaker
        and is only available when running in SageMaker,
        but not in local mode.
        SM_TRAINING_ENV is set by the SageMaker container and
        contains arguments such as hyperparameters
        and arguments passed to the training job.
    TRAINING_JOB_NAMEsagemaker_training_job_name"z	^-?[\d]+$z
^-?[.\d]+$NSM_TRAINING_ENVz5Failed to parse SM_TRAINING_ENV not valid JSON string   )
stacklevel)ospathexistssm_filesSM_PARAM_CONFIGSM_RESOURCE_CONFIGgetenvopenjsonloaditemsstriprematchintfloatenvironloadsJSONDecodeErrorwarningswarn)conffidkeyvalcast r'   `/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/wandb/integration/sagemaker/config.pyparse_sm_config
   s4   



	r)   )r   r   r   r    typingr   r    r   r   strr)   r'   r'   r'   r(   <module>   s    