environment_parent
Classes¶
EnvironmentConfig
dataclass
¶
Worker environment configuration.
This configuration is applied in the worker before importing/using brms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_home
|
str or None
|
Override for |
None
|
startup_scripts
|
list[str]
|
R code snippets executed in the worker after initialization. |
list()
|
environment_name
|
str
|
brmspy environment name (used to determine |
'default'
|
runtime_path
|
str or None
|
Path to a brmspy runtime bundle to activate in the worker. |
None
|
env
|
dict[str, str]
|
Extra environment variables applied when spawning the worker. |
dict()
|
Source code in brmspy/types/session.py
Attributes¶
r_home = None
class-attribute
instance-attribute
¶
startup_scripts = field(default_factory=list)
class-attribute
instance-attribute
¶
environment_name = 'default'
class-attribute
instance-attribute
¶
runtime_path = None
class-attribute
instance-attribute
¶
env = field(default_factory=dict)
class-attribute
instance-attribute
¶
Functions¶
to_dict()
¶
Serialize configuration for persistence to JSON.
Source code in brmspy/types/session.py
from_dict(obj)
classmethod
¶
Deserialize configuration from a JSON object.
Source code in brmspy/types/session.py
from_obj(obj)
classmethod
¶
Normalize None | dict | EnvironmentConfig into an EnvironmentConfig.
Source code in brmspy/types/session.py
__init__(r_home=None, startup_scripts=list(), environment_name='default', runtime_path=None, env=dict())
¶
Functions¶
get_environment_base_dir()
¶
Return the base directory for brmspy environments, creating it if needed.
Returns:
| Type | Description |
|---|---|
Path
|
|
Source code in brmspy/_session/environment.py
get_environment_userlibs_dir(name)
¶
get_environments_state_path()
¶
Return the path to environment_state.json (stores last active environment name).
save(env_conf)
¶
Persist an environment configuration and ensure the directory structure exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_conf
|
EnvironmentConfig
|
Environment configuration to write. |
required |
Source code in brmspy/_session/environment_parent.py
save_as_state(env_conf)
¶
Record the active environment name in environment_state.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_conf
|
EnvironmentConfig
|
Environment configuration whose name should be recorded. |
required |