astra.config module¶
ASTRA Core Global Configuration.
This module houses all process-global feature flags for the engine.
Centralising flags here prevents scattered os.environ.get(...) calls
from spreading across modules and becoming impossible to test or override.
Flags¶
ASTRA_STRICT_MODEControls the dual-profile mode (Relaxed vs Flight-Grade). In strict mode every missing or low-fidelity data source raises a typed error instead of silently substituting a heuristic fallback.
SPACEBOOK_ENABLEDControls whether any Spacebook (COMSPOC) network calls are allowed. Set the
ASTRA_SPACEBOOK_ENABLED=falseenvironment variable before importingastrato permanently disable all Spacebook I/O, or useset_spacebook_enabled()at runtime (useful in tests / CI).
Thread safety¶
Both flags are process-global. Direct mutation is safe for single-threaded
scripts. For multi-threaded applications, use the provided set_*
functions which acquire the module-level RLock before updating the flag,
preventing races during concurrent reads/writes.
- astra.config.set_strict_mode(enabled)[source]¶
Thread-safe setter for
ASTRA_STRICT_MODE.Acquires the module lock before updating the flag, which is required when toggling strict mode from a different thread than physics workers.
- Parameters:
enabled –
Truefor flight-grade strict mode,Falsefor beginner-friendly relaxed mode.
- astra.config.set_spacebook_enabled(enabled)[source]¶
Thread-safe setter for
SPACEBOOK_ENABLED.Allows tests and CLI tools to enable or disable Spacebook calls without restarting the process. The change takes effect immediately for all subsequent calls to any Spacebook-guarded function.
- Parameters:
enabled –
Trueto allow Spacebook network I/O (default),Falseto disable all Spacebook calls and force fallback to CelesTrak or raiseSpacebookErrorwhere applicable.
Example:
import astra.config as cfg cfg.set_spacebook_enabled(False) # disable for offline tests # ... run tests ... cfg.set_spacebook_enabled(True) # restore