opensampl.config.base
Pydantic BaseSettings Object used to access and set the openSAMPL configuration options.
This module provides the main configuration class for openSAMPL, handling environment variables, configuration validation, and settings management.
BaseConfig
Bases: BaseSettings
Primary configuration settings for the opensampl cli.
Handles all configuration options including routing, database connections, logging, and API access settings.
Source code in opensampl/config/base.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
__init__(**kwargs)
Record the env file set in object creation before proceeding to super().init.
Required because the default pydantic-settings behavior is not to store the filepath in the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Any
|
Keyword arguments including env_file path configuration. |
{}
|
Source code in opensampl/config/base.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
check_routing_dependencies()
Ensure required URL (backend or database) is configured for routing option.
Returns:
Type | Description |
---|---|
BaseConfig
|
Self for method chaining. |
Raises:
Type | Description |
---|---|
ValueError
|
If required URLs are not configured for the current routing option. |
Source code in opensampl/config/base.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
convert_to_str(v)
Convert archive path to a string for serialization
Source code in opensampl/config/base.py
46 47 48 49 |
|
get_by_name(name)
Return the field info object for the given model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the configuration field. |
required |
Returns:
Type | Description |
---|---|
Field info object if found, None otherwise. |
Source code in opensampl/config/base.py
79 80 81 82 83 84 85 86 87 88 89 90 |
|
save_config(values=None)
Save the current env configuration.
If values are provided, it will only encode the ones listed. Otherwise, will save all of them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Optional[list[str]]
|
Optional list of setting names to save. If None, saves all settings. |
None
|
Source code in opensampl/config/base.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
set_by_name(name, value)
Set setting's value in the env file for current instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the configuration setting. |
required |
value
|
Any
|
Value to set for the setting. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the setting name is not found. |
Source code in opensampl/config/base.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|