The simulacat.orchestration module provides low-level control over the GitHub
API simulator process.
Starting the Simulator
from pathlib import Path
from simulacat.orchestration import start_sim_process, stop_sim_process
config = {
"users": [{"login": "testuser", "organizations": []}],
"organizations": [],
"repositories": [
{
"owner": "testuser",
"name": "my-repo",
}
],
"branches": [],
"blobs": [],
}
proc, port = start_sim_process(config, Path("/tmp/sim-workdir"))
print(f"Simulator listening on port {port}")
Stopping the Simulator
stop_sim_process(proc)
By default, stop_sim_process waits up to 5 seconds for the process to exit
before sending kill(). You can adjust the timeout by passing timeout=....
Empty Configuration
When an empty dictionary is passed, simulacat provides a minimal valid configuration:
proc, port = start_sim_process({}, Path("/tmp/sim-workdir"))
Error Handling
If the simulator fails to start, a GitHubSimProcessError is raised with
details about the failure:
from simulacat.orchestration import GitHubSimProcessError
try:
proc, port = start_sim_process(config, tmpdir)
except GitHubSimProcessError as e:
print(f"Simulator failed: {e}")
Custom Bun Executable
By default, the orchestration uses the bun command from PATH or the BUN
environment variable. Specify a custom path via the bun_executable parameter:
proc, port = start_sim_process(
config,
tmpdir,
bun_executable="/custom/path/to/bun",
)