CondaShellProxy
Shell proxy for managing Conda virtual environments.
This class manages Python virtual environments using Conda, which uses environment.yml files for dependency specification. It provides:
- Automatic Conda environment creation from environment.yml
- Command execution within the Conda environment using
conda activate - Environment cleanup and management
The conda_command attribute can be overridden by subclasses (e.g., MambaShellProxy)
to use alternative package managers like Mamba for faster installation.
CONFIG_FILE_NAME: strenv_file_path: strenv_hash: strenv_name: strworking_dir: strInitialize a BaseEnvShell instance.
pathlib.Path | strstr | Nonestr | Nonegws_core.core.classes.observer.message_dispatcher.MessageDispatcher | NoneAttach a custom observer to the shell proxy.
The logs of the proxy will be dispatched to the observer.
MessageObserverAttach a progress bar to the shell proxy.
The logs of the proxy will be dispatched to the progress bar logs.
ProgressBarRun a command in a shell and return the output. There logs of the command are ignored.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | Nonebool - TrueAnyDelete the working directory and all its contents.
Create the environment directory if it doesn't exist.
PathForce the message dispatcher to send all buffered messages immediately.
Check if the virtual environment is installed.
boolFormat the user command to run within the Conda environment.
Prepends conda activate to the user command to ensure it executes within
the virtual environment context. Always uses conda (not mamba) for activation.
list | strlist | strGet the path to the environment.yml configuration file.
strGet default environment variables for Conda execution.
Sets PYTHONUNBUFFERED to force unbuffered Python output for real-time logging when used with conda activate.
dictGet the absolute path for the environment directory.
All environments are stored in the global env directory, with subdirectories named by their environment hash.
strGet the message dispatcher instance.
MessageDispatcherGet the path to the .venv subdirectory containing the Conda environment.
strInstall the virtual env. Return True if the env was installed, False if it was already installed, or an error occured.
boolList all installed packages with their versions in the virtual environment.
Returns a dictionary where keys are package names and values are version strings. Only works if the environment is installed.
dictLog an error message using the dispatcher.
strLog an info message using the dispatcher.
strLog a warning message using the dispatcher.
strRead the environment configuration file and return its content.
strRun a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | Nonebool - Falsebool - TrueintRun a command in a shell without blocking the thread. There logs of the command are ignored.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | NoneSysProcConvert the ShellProxy instance to a data transfer object.
ShellProxyDTOUninstall the virtual env. Return true if the env was uninstalled, False if it was already uninstalled or an error occured.
boolReturns the name of the class
bool - Falsebool - Falsebool - FalsestrCheck if a folder is a valid Conda/Mamba environment folder.
Validates that the folder contains an environment.yml, .venv directory, and has the correct environment type (conda or mamba) in its metadata.
strboolCreate a virtual environment from a string containing the environment definition.
The environment directory name is generated from a hash of the env_str, so identical environment strings will share the same environment directory.
strgws_core.core.classes.observer.message_dispatcher.MessageDispatcher | NoneBaseEnvShellTypeReturns the full name of the class
bool - Falsebool - FalsestrstrVersionGet the environment creation information from the metadata file.
strVEnvCreationInfoGet the environment type identifier.
LiteralGet the human name of the object
strGet the short description of the object
strGet the style of the object
TypingStyleGet the typing name of the object Ex: 'RESOURCE.gws_core.Table'
strTypingNameObjCreate an MD5 hash from the environment string.
Removes whitespace and newlines before hashing to ensure consistent hashes for equivalent environment definitions.
strstrGet all the classes that inherit this class
list