CStarEnvironment

Contents

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, system_settings_klass: type[EnvSettingsBase] | None = None)#

Bases: object

Encapsulates 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.

Examples

>>> env = CStarEnvironment(
...     system_name="expanse",
...     mpi_exec_prefix="srun --mpi=pmi2",
...     compiler="intel",
... )
>>> print(env)
CStarEnvironment(...)

Methods

CStarEnvironment.load_lmod_modules()

Loads necessary modules for this machine using Linux Environment Modules.

CStarEnvironment.set_env_var(key, value)

Set value of an environment variable.

Attributes

CStarEnvironment.compiler

Get the compiler used when building in the environment.

CStarEnvironment.environment_variables

Return the environment variables that were loaded from .env files.

CStarEnvironment.lmod_path

Identify the expected path to a .lmod file for the current system.

CStarEnvironment.mpi_exec_prefix

Get the MPI prefix used when calling mpiexec in the environment.

CStarEnvironment.package_root

Return the root directory of the top-level package.

CStarEnvironment.settings_klass

Return the type that will load and validate the system settings.

CStarEnvironment.system_env_path

Identify the expected path to a .env file for the current system.

CStarEnvironment.template_root

The root directory containing CStar templates.

CStarEnvironment.uses_lmod

Checks if the system uses Linux Environment Modules (Lmod) based on OS type and presence of LMOD_DIR in environment variables.