Attention
This project is still in an early phase of development.
The python API is not yet stable, and some aspects of the schema for the blueprint and workplan will likely evolve. Therefore whilst you are welcome to try out using the package, we cannot yet guarantee backwards compatibility. We expect to reach a more stable version in 2026.
CStarEnvironment#
- class cstar.system.environment.CStarEnvironment(system_name: str, mpi_exec_prefix: str, compiler: str)#
Bases:
objectEncapsulates the configuration and management of a computing environment for a specific system, including compilers, job schedulers, memory, and core settings.
This class uses properties to avoid attribute modification after initialization.
This class also provides utilities for interacting with Linux Environment Modules (Lmod) and dynamically setting up the environment based on user and system configurations.
- system_name#
The name of the system (e.g., “expanse”, “perlmutter”).
- Type:
str
- mpi_exec_prefix#
The prefix command used for launching MPI jobs.
- Type:
str
- compiler#
The compiler to be used in the environment (e.g., “intel”, “gnu”).
- Type:
str
- uses_lmod#
True if this system uses Linux Environment Modules for environment management
- Type:
bool
- load_lmod_modules(lmod_file: str) None#
Loads the necessary Lmod modules for the current system based on a .lmod configuration file.
- _call_lmod(*args) None#
Executes a Linux Environment Modules command with specified arguments.
- Raises:
EnvironmentError – Raised when required resources, modules, or configurations are missing or incompatible.
RuntimeError – Raised when a command or operation fails during execution.
Examples
>>> env = CStarEnvironment( ... system_name="expanse", ... mpi_exec_prefix="srun --mpi=pmi2", ... compiler="intel", ... ) >>> print(env) CStarEnvironment(...)
Methods
CStarEnvironment.load_lmod_modules(lmod_file)Loads necessary modules for this machine using Linux Environment Modules.
CStarEnvironment.set_env_var(key, value)Set value of an environment variable.
Attributes
Get the compiler used when building in the environment.
CStarEnvironment.environment_variablesReturn the environment variables that were loaded from .env files.
CStarEnvironment.lmod_pathIdentify the expected path to a .lmod file for the current system.
Get the MPI prefix used when calling mpiexec in the environment.
CStarEnvironment.package_rootReturn the root directory of the top-level package.
CStarEnvironment.system_env_pathIdentify the expected path to a .env file for the current system.
CStarEnvironment.template_rootThe root directory containing CStar templates.
Checks if the system uses Linux Environment Modules (Lmod) based on OS type and presence of LMOD_DIR in environment variables.