_activation
Runtime activation/deactivation. Mutates R environment ONLY. Does NOT touch config - that's the caller's responsibility.
Attributes¶
MANAGED_PACKAGES = ('brms', 'cmdstanr', 'rstan', 'StanHeaders', 'tibble', 'pkgconfig')
module-attribute
¶
Functions¶
log(*msg, method_name=None, level=logging.INFO)
¶
Log a message with automatic method name detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
The message to log |
()
|
method_name
|
str
|
The name of the method/function. If None, will auto-detect from call stack. |
None
|
level
|
int
|
Logging level (default: logging.INFO) |
INFO
|
Source code in brmspy/helpers/log.py
log_warning(msg, method_name=None)
¶
Log a warning message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
The warning message to log |
required |
method_name
|
str
|
The name of the method/function. If None, will auto-detect from call stack. |
None
|
Source code in brmspy/helpers/log.py
activate(runtime_path)
¶
Activate runtime by mutating R environment.
Steps: 1. Parse and validate manifest 2. Store original R environment (if not already stored) 3. Unload managed packages if loaded 4. Set .libPaths() to runtime's Rlib/ 5. Set cmdstan path to runtime's cmdstan/ 6. Verify packages are loadable 7. Invalidate package singletons
Does NOT save to config. Caller handles that.
On failure, attempts to restore original environment.
Source code in brmspy/_runtime/_activation.py
deactivate()
¶
Deactivate runtime by restoring original R environment.
Does NOT clear config. Caller handles that.
Raises: RuntimeError: If no stored environment to restore.
Source code in brmspy/_runtime/_activation.py
_unload_managed_packages()
¶
Unload brms, cmdstanr, rstan if loaded.
Source code in brmspy/_runtime/_activation.py
_remove_managed_packages()
¶
removes brms, cmdstanr, rstan if loaded.
Source code in brmspy/_runtime/_activation.py
_verify_runtime_loadable()
¶
_rollback_to_stored_env()
¶
Restore original env on activation failure.