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_MODE

Controls 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_ENABLED

Controls whether any Spacebook (COMSPOC) network calls are allowed. Set the ASTRA_SPACEBOOK_ENABLED=false environment variable before importing astra to permanently disable all Spacebook I/O, or use set_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:

enabledTrue for flight-grade strict mode, False for 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:

enabledTrue to allow Spacebook network I/O (default), False to disable all Spacebook calls and force fallback to CelesTrak or raise SpacebookError where applicable.

Example:

import astra.config as cfg
cfg.set_spacebook_enabled(False)   # disable for offline tests
# ... run tests ...
cfg.set_spacebook_enabled(True)    # restore
astra.config.get_max_workers(default)[source]

Return configured worker count or a caller-provided default.

Parameters:

default – Fallback worker count when ASTRA_MAX_WORKERS is unset.

Returns:

Positive worker count suitable for thread-pool construction.

astra.config.set_max_workers(value)[source]

Thread-safe setter for ASTRA_MAX_WORKERS.

Parameters:

value – Positive worker count, or None to restore caller defaults.