os.setenv
The os.setenv function sets a string environment variable for subsequent execution in the current script. It does not modify the host Atmos process or other script invocations.
Usage
os.setenv(name, value)
Arguments
name- Required. A nonempty string without
=or null bytes. Names are case-insensitive on Windows. value- Required. A string without null bytes.
""sets an empty value; it does not remove the variable.
Returns None. Subsequent os.getenv() and os.environ() calls see the change. It also reaches exec.run,
atmos.*, component.exec (including previously resolved handles), and steps.* calls. It overrides inherited,
component, and declared step values; an explicit per-call env= override takes precedence. Pinned tool directories
remain prepended to PATH. The declared env dictionary is unchanged.
Call this function only in the script's main thread. Parallel tasks inherit the changes already made by their parent;
calling os.setenv inside a parallel task raises an error, even with max_concurrency=1.
Use per-call env= for different values in different branches. Changes last until the script invocation ends.
Examples
os.setenv("REGION", "us-east-1")
exec.run(["my-tool", "deploy"])
exec.run(["my-tool", "inspect"], env={"REGION": "us-west-2"})
print(os.getenv("REGION")) # us-east-1
Related
os.getenvreads a variable.os.environtakes a frozen snapshot.