yaml_workflow.tasks.shell_tasks¶
yaml_workflow.tasks.shell_tasks
¶
Shell operation tasks for executing commands and managing processes.
Classes¶
Functions¶
check_command(command: Union[str, List[str]], cwd: Optional[str] = None, env: Optional[Dict[str, str]] = None, shell: bool = False, timeout: Optional[float] = None) -> str
¶
Run a command and raise an error if it fails.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
Union[str, List[str]]
|
Command to run (string or list of arguments) |
required |
cwd
|
Optional[str]
|
Working directory for the command |
None
|
env
|
Optional[Dict[str, str]]
|
Environment variables to set |
None
|
shell
|
bool
|
Whether to run command through shell |
False
|
timeout
|
Optional[float]
|
Timeout in seconds |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Command output (stdout) |
Raises:
Type | Description |
---|---|
CalledProcessError
|
If command returns non-zero exit code |
Source code in src/yaml_workflow/tasks/shell_tasks.py
get_environment() -> Dict[str, str]
¶
Get current environment variables.
Returns:
Type | Description |
---|---|
Dict[str, str]
|
Dict[str, str]: Dictionary of environment variables |
process_command(command: str, context: Dict[str, Any]) -> str
¶
Process a shell command template with the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
str
|
Shell command template |
required |
context
|
Dict[str, Any]
|
Template context |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Processed shell command |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If template resolution fails (via handle_task_error) |
Source code in src/yaml_workflow/tasks/shell_tasks.py
run_command(command: Union[str, List[str]], cwd: Optional[str] = None, env: Optional[Dict[str, str]] = None, shell: bool = False, timeout: Optional[float] = None) -> Tuple[int, str, str]
¶
Run a shell command and return its output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
Union[str, List[str]]
|
Command to run (string or list of arguments) |
required |
cwd
|
Optional[str]
|
Working directory for the command |
None
|
env
|
Optional[Dict[str, str]]
|
Environment variables to set |
None
|
shell
|
bool
|
Whether to run command through shell |
False
|
timeout
|
Optional[float]
|
Timeout in seconds |
None
|
Returns:
Type | Description |
---|---|
Tuple[int, str, str]
|
Tuple[int, str, str]: Return code, stdout, and stderr |
Source code in src/yaml_workflow/tasks/shell_tasks.py
set_environment(env_vars: Dict[str, str]) -> Dict[str, str]
¶
Set environment variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env_vars
|
Dict[str, str]
|
Dictionary of environment variables to set |
required |
Returns:
Type | Description |
---|---|
Dict[str, str]
|
Dict[str, str]: Updated environment variables |
Source code in src/yaml_workflow/tasks/shell_tasks.py
shell_task(config: TaskConfig) -> Dict[str, Any]
¶
Run a shell command with namespace support.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
TaskConfig
|
Task configuration with namespace support |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Command execution results |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If command execution fails or template resolution fails |
Source code in src/yaml_workflow/tasks/shell_tasks.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|