atmos.emulator
The atmos.emulator function runs atmos emulator through the current Atmos executable. Use it to start,
reset, and stop local cloud-API emulator components and to run commands inside them from automation.
Also available as atmos.emu.
Usage
atmos.emulator(
*positionals,
flags = {},
args = [],
working_directory = ...,
env = ...,
output = "stream",
check = True,
)
Subcommands
Pass the subcommand and any positional arguments as strings before the keyword arguments. The call
atmos.emulator("up", "aws", flags = {"stack": "local"}) runs atmos emulator up aws --stack=local.
| Subcommand | Purpose |
|---|---|
up | Start the emulator container. |
down | Stop and remove the emulator container. |
reset | Stop the emulator and wipe its persisted state. |
exec | Run a command in the emulator container. |
logs | Show the emulator container logs. |
ps | List configured running emulators. |
list | List emulators and their status. Also available as ls. |
See the atmos emulator command reference for the complete list of subcommands and
flags.
The emulator command is experimental, so each call prints the experimental notice. Starting an emulator needs a
container runtime, either Docker or Podman, on the machine running the script. The reset subcommand asks for
confirmation unless the force flag is set, so pass it when no terminal is available.
Arguments
*positionals(Optional) Strings placed on the command line right after
emulator, in order: the subcommand and its positional arguments, such as the emulator component name. Every value must be a string.flags(Optional) A dictionary of command-line options; see flag translation. The
stackkey becomes--stack(shorthands). Other keys includeephemeralforup,forceforreset, andruntimeforlistandps.args- (Optional) A list or tuple of strings appended after the flags.
working_directory,env,output,check(Optional) See
atmos.runfor process options and defaults.
Options other than the positionals are keyword-only.
Returns
A result with stdout, stderr, and exit_code. See atmos.run for output and error behavior.
Examples
Start an emulator for a test run
atmos.emulator("up", "aws", flags = {"stack": "local"})
Start without persisting state
atmos.emulator("up", "aws", flags = {"stack": "local", "ephemeral": True})
The ephemeral key becomes the bare flag --ephemeral, so data is discarded when the emulator goes down.
Wipe state without a prompt
atmos.emulator("reset", "aws", flags = {"stack": "local", "force": True})
Always stop the emulator after a job
def run_checks():
# Replace with your project's integration test command.
return exec.run(["go", "test", "./tests/integration/..."], check = False)
atmos.emulator("up", "aws", flags = {"stack": "local"})
outcome = run_checks()
atmos.emulator("down", "aws", flags = {"stack": "local"})
if outcome.exit_code != 0:
fail("Integration tests failed.")
Related
atmos.runruns any Atmos command from an argument list.atmos emulatordocuments every subcommand and flag.- Atmos Automation Language and the script step