aiSSEMBLE Universal Config Loader
Project description
aiSSEMBLE Universal Config Loader
aiSSEMBLE Universal Config Loader uses Krausening to provide features to read the configuration from property file and load the configuration to environment variables or to global variables. For the notebook user, it also providers a helper class to extract their notebooks global variables into the property file to set up the configuration for the first time.
Getting Started
Notebook User
For the notebook user, to have an easy start, config helper provides a feature to extract the string type or int type global variables into the configuration property file. The configuration file will be created if it doesn't exist.
Example of Extract variables to the property file
The Following example shows how a notebook user can extract the variables from a cell to the property file
# a notebook cell
import os
# variables
test_var1="value_1"
test_var2="value_2"
test_var3="value_3"
test_var4=[1, 2, 3] # the list variable will not be extracted to property file
test_var5={"a":"b", "c":"d"} # the dict variable will not be extract to property file
os.environ['PROJECT_ID'] = "test-final"
os.environ['ISSUE_ID']="1"
# install the aissemble-universal-config-loader module
!pip install aissemble-universal-config-loader
# register the `aissemble_universal_config_loader.ipython.config_helper` ipython extension
%load_ext aissemble_universal_config_loader.ipython.config_helper
#extract the `int` type or `string` type global variables to the configuration file
%extract_vars_to_property_file
Output
After run above cell, expect the next steps printed in the cell output:
The next step contains:
- The function to load property values as global variables
- The configuration file location and what variables have been saved
****************************************************************************************
Next Steps:
****************************************************************************************
1: Required
----------------------------------------------------------------------------------------
To load property values as global variables, add the below code snippets to a new cell and run the cell:
"""
# import the ConfigLoader module
from aissemble_universal_config_loader.config_loader import ConfigLoader
# set configuration file directory, this is for bootstrapping the library
os.environ['KRAUSENING_BASE'] = '/path-to-project-directory/configurations/base'
# load property values as global variables
ConfigLoader().load_as_global()
"""
Note: Use `ConfigLoader().load_as_env()` to load property values as environment variable.
----------------------------------------------------------------------------------------
2: Optional
----------------------------------------------------------------------------------------
The variables have been extracted to /Users/csun/bah/tests/aissemble-lite-test/test-4306-3/backend/configurations/base/configuration.properties.
You can remove the following variables from your notebook and load them via the ConfigLoader:
['test_var1=value_1', 'test_var2=value_2', 'test_var3=value_3']
Property file
If there is no existing property file, by default, the configuration.properties will be generated at the *.ipynb file's sibling directory configurations/base with the below content
test_var1=value_1
test_var2=value_2
test_var3=value_3
Python Project User
Installation
Add the aissemble-universal-config-loader package to your project
Load Property
To load the property, ensure the configuration.properties file is already generated. The loader uses Krausening to read properties from a properties file into either global variables or environment variables. The default Krausening base location is configurations/base and the default properties file is configuration.properties
Add import Statement
from aissemble_universal_config_loader.config_loader import ConfigLoader
Set Krausening_Base environment variable
Krausening is useful for defining different configurations per execution environment. For simple local usage, you can simply set KRAUSENING_BASE to the directory that contains your configuration file(s). For more detail: https://github.com/TechnologyBrewery/krausening/tree/dev/krausening#krausening-in-one-pint-learn-krausening-in-2-minutes
os.environ['KRAUSENING_BASE']="path-to-property-directory"
Load Property to Global Variables
ConfigLoader().load_as_global()
Load Property to Environment Variables
ConfigLoader().load_as_env()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aissemble_universal_config_loader-0.1.0.tar.gz.
File metadata
- Download URL: aissemble_universal_config_loader-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.9 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda0e69811a336d923784f3fe6db56e82a944b4c08b74f682f959ca5e0c9758b
|
|
| MD5 |
f32fe1a44c470fad73c7b4c5dca28e1d
|
|
| BLAKE2b-256 |
e51dabee6a06b6c2e82d5b503e12d841213e1b1c47a42eb2651e275f22b3ebe4
|
File details
Details for the file aissemble_universal_config_loader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aissemble_universal_config_loader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.9 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32ae0b9fdad21c265da9458fe018c47c5611ab7ec16599dbf8156154ab5f8d9a
|
|
| MD5 |
99eeb2d514c9a588f0e1abb5611903ee
|
|
| BLAKE2b-256 |
d09fd85c59f5790f51bc820611391fee63e661504965b527383c7fe81c9ab6b1
|