gws_core

Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version

CondaShellProxy

Shell task proxy.

This class is a proxy to Shell commandes. It allow running commands in a shell and get the output and stdout.

Attributes
CONFIG_FILE_NAME: strenv_file_path: strenv_hash: strenv_name: strworking_dir: str
Functions
__init__

summary

env_file_path : Union
path to the env file. This file must contained dependencies for the virtual env and will be used to create the env. If the env file has changed, the env will be recreated and previous env will be deleted.
env_name : str
Name of the environment. This name will be shown in the env list. If not provided, a name is generated
working_dir : str
working directory for the shell (all command will be executed from this dir). If not provided, an new temp directory is created. defaults to None
message_dispatcher : MessageDispatcher
if provided, the output of the command will be redirected to the dispatcher. Can be useful to log command outputs in task's logs. defaults to None
attach_observer

Attach a custom observer to the shell proxy. The logs of the proxy will be dispatch to the observer

observer : MessageObserver
attach_progress_bar

Attach a progress_bar to the shell proxy. The logs of the proxy will be dispatch to the progress_bar logs

progress_bar : ProgressBar
build_os_env

Creates the OS environment variables that are passed to the shell command

Return type : dict
check_output

Run a command in a shell and return the output. There logs of the command are ignored.

cmd : Union
command to run
env : dict
environment variables to pass to the shell
shell_mode : bool - False
if True, the command is run in a shell
text : bool - True
if True, the output is returned as a string
Return type : Any
clean_working_dir
create_env_dir

Create the env dir.

Return type : Path
dispatch_waiting_messages
env_is_installed

Returns True if the virtual env is installed. False otherwise

Return type : bool
format_command

Format the user command. If the command is a list, must return a list.

user_cmd : Union
Return type : Union
get_config_file_path

Returns the path of the config file used to create the env

Return type : str
get_env_dir_path

Returns the absolute path for the env dir base on a dir name. All env are in the global env dir.

Return type : str
get_message_dispatcher

Get the message dispatcher

Return type : MessageDispatcher
get_venv_dir_path
Return type : str
install_env

Install the virtual env. Return True if the env was installed, False if it was already installed, or an error occured.

Return type : bool
log_error_message

Log an error message using the dispatcher

message : str
log_info_message

Log an info message using the dispatcher

message : str
log_warning_message

Log a warining message using the dispatcher

message : str
read_env_file

Read the env file and return its content.

Return type : str
run

Run a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.

cmd : Union
command to run
env : dict
environment variables to pass to the shell
shell_mode : bool - False
if True, the command is run in a shell
dispatch_stdout : bool - False
if True, the stdout of the command is dispatched to the message dispatcher. ⚠️ Warning ⚠️ Do not set to True if the command generates a lot of logs, because logs are stored in database
dispatch_stderr : bool - True
if True, the stderr of the command is dispatched to the message dispatcher. ⚠️ Warning ⚠️ Do not set to True if the command generates a lot of logs, because logs are stored in database
Return type : int
run_in_new_thread

Run a command in a shell without blocking the thread. There logs of the command are ignored.

cmd : Union
command to run
env : dict
environment variables to pass to the shell
shell_mode : bool - False
if True, the command is run in a shell
Return type : SysProc
to_dto
Return type : ShellProxyDTO
uninstall_env

Uninstall the virtual env. Return true if the env was uninstalled, False if it was already uninstalled or an error occured.

Return type : bool
classname @classmethod

Returns the name of the class

slugify : bool - False
True to slugify the class name if True
snakefy : bool - False
True to snakefy the class name if True
replace_uppercase : bool - False
Replace upper cases by "-" if True
Return type : str
folder_is_env @classmethod

return true if the folder is a valid env folder

folder_path : str
Return type : bool
from_env_str @classmethod

Create the virtual environment from a string containing the environment definition.

The env dir name is generated from an hash of the env_str. So if the env_str is the same, the env dir name will be the same.

env_str : str
message_dispatcher : MessageDispatcher
Return type : BaseEnvShell
full_classname @classmethod

Returns the full name of the class

slugify : bool - False
Slugify the returned class name if True
snakefy : bool - False
Snakefy the returned class name if True
Return type : str
get_creation_info @classmethod

Returns the json info file content

folder_path : str
Return type : VEnvCreationInfo
get_env_type @classmethod

Returns the type of the env

Return type : Literal
get_human_name @classmethod

Get the human name of the resource

Return type : str
get_short_description @classmethod

Get the short description of the resource

Return type : str
get_style @classmethod

Get the style of the resource

Return type : TypingStyle
get_typing_name @classmethod

Get the typing name of the resource

Return type : str
hash_env_str @classmethod

Create a hash from the env_str to generate a unique env dir name.

env_str : str
Return type : str
inheritors @classmethod

Get all the classes that inherit this class

Return type : List