
    i                         d Z ddlZddlmZmZ ddlmZmZmZm	Z	 ddl
mZmZmZmZmZmZmZ defdZe G d d	e             Zy)
z.Configuration for Python code execution nodes.    N)	dataclassfield)AnyDictListMapping)
BaseConfigConfigErrorConfigFieldSpecensure_listoptional_dictoptional_strrequire_mappingreturnc                  *    t         j                  xs dS )Npython3)sys
executable     N/Users/bowang/.openclaw/workspace/ChatDev/entity/configs/node/python_runner.py_default_interpreterr      s    >>&Y&r   c                   P   e Zd ZU  ee      Zeed<    ee      Z	e
e   ed<    ee      Zeeef   ed<   dZeed<   dZeed<   ed	eeef   d
edd fd       Z edddd e       dd       eddddg dd       eddddi dd       edddddd       eddddddd      dZy )!PythonRunnerConfig)default_factoryinterpreterargsenv<   timeout_secondsutf-8encodingdatapathr   c                &   t        ||      }t        |d|      xs
 t               }|j                  d      }|"t	        |      D cg c]  }t        |       c}ng }t        |d|      xs i }|j                  dd      }	t        |	t              r|	dk  rt        d| d      t        |d	|      xs d
}
|
st        d| d       | |||j                         D ci c]  \  }}t        |      t        |       c}}|	|
|      S c c}w c c}}w )Nr   r   r   r    r   r   z*timeout_seconds must be a positive integerz.timeout_secondsr"   r!   zencoding cannot be emptyz	.encoding)r   r   r   r    r"   r$   )r   r   r   getr   strr   
isinstanceintr
   items)clsr#   r$   mappingr   args_rawitemr   r   timeout_valuer"   keyvalues                r   	from_dictzPythonRunnerConfig.from_dict   s    !$-"7M4@ZDXDZ;;v&@H@Tk(&;<&;dD	&;<Z\GUD17R$5r:--!1CJtfTdLeffT:Eg8TF):LMM#8;		D*#uS3u:%D)
 	
 = Es   DDzPython Pathr'   FzDPython executable file path, defaults to current process interpreterT)namedisplay_name	type_hintrequireddefaultdescriptionadvancezStartup Parametersz	list[str]z)Parameter list appended after interpreterz Additional Environment Variableszdict[str, str]z@Additional environment variables, will override process defaultszTimeout (seconds)r)   z"Script execution timeout (seconds))r3   r4   r5   r6   r7   r8   zOutput Encodingz$Encoding used to parse stdout/stderr)r   r   r   r    r"   N)__name__
__module____qualname__r   r   r   r'   __annotations__listr   r   dictr   r   r    r)   r"   classmethodr   r   r2   r   FIELD_SPECSr   r   r   r   r      s$   -ABKBD1D$s)15Cc3h5OSHc
WS#X. 
 
AU 
 
, '&(*^
  -!C
 ;&Z
 +",<
 $*>
I-Kr   r   )__doc__r   dataclassesr   r   typingr   r   r   r   entity.configs.baser	   r
   r   r   r   r   r   r'   r   r   r   r   r   <module>rF      sM    4 
 ( + +  'c ' J J Jr   