Configuration
config ¶
Assembly: Jimi
Filename: Config.py
Author: Terry D. Eppler
Created: 05-31-2022
Last Modified By: Terry D. Eppler
Last Modified On: 05-01-2025
Jimi is a df analysis tool integrating GenAI, GptText Processing, and Machine-Learning
algorithms for federal analysts.
Copyright © 2022 Terry Eppler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov
throw_if ¶
Raise an exception when a required value is empty.
Purpose
Provides the shared validation guard used by Jimi configuration helpers and provider wrappers. The function raises a ValueError when a required argument or setting is falsy so callers can fail early before using incomplete runtime configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the argument or configuration value being validated. |
required |
value
|
object
|
Value to validate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when value is falsy. |
Source code in config.py
get_bool ¶
Read a Boolean environment variable.
Purpose
Reads optional Boolean configuration from the environment while preserving safe module import behavior. Missing variables return the supplied default, and recognized true values allow deployment settings to control feature flags without changing source code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
bool
|
Value returned when the environment variable is missing or invalid. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Parsed Boolean value or the supplied default. |
Source code in config.py
get_int ¶
Read an integer environment variable.
Purpose
Parses optional integer configuration from the environment while keeping Jimi imports stable when deployment variables are missing, empty, or malformed. The helper supports runtime settings such as token limits, thread counts, and other numeric controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
int
|
Integer value returned when parsing is not possible. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Parsed integer value or the supplied default. |
Source code in config.py
get_float ¶
Read a floating-point environment variable.
Purpose
Parses optional floating-point configuration from the environment while preserving safe defaults for incomplete deployments. The helper supports model sampling, penalty, and threshold settings that may be supplied outside the source tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
float
|
Floating-point value returned when parsing is not possible. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Parsed floating-point value or the supplied default. |
Source code in config.py
get_path ¶
Read a filesystem path environment variable.
Purpose
Resolves optional filesystem configuration from the environment for paths such as logging locations, storage directories, and external assets. Missing or invalid values fall back to the resolved default path so imports remain stable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
Path
|
Default path used when the environment variable is missing or invalid. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Resolved environment path or resolved default path. |
Source code in config.py
get_text ¶
Read a text environment variable.
Purpose
Returns optional text configuration from the environment while preserving the supplied default for missing or empty variables. The helper centralizes simple text settings used by paths, labels, table names, and provider configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
str
|
Text value returned when the environment variable is missing or empty. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Environment value or supplied default. |