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()
Metadata
Release files for aissemble-universal-config-loader 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aissemble_universal_config_loader-0.1.0.tar.gz | 8.0 kB | Without provenance | Details for aissemble_universal_config_loader-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aissemble_universal_config_loader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for aissemble_universal_config_loader-0.1.0-py3-none-any.whl |
Total release size: 18.0 kB
Release files / aissemble_universal_config_loader-0.1.0.tar.gz
| Download URL | aissemble_universal_config_loader-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bda0e69811a336d923784f3fe6db56e82a944b4c08b74f682f959ca5e0c9758b
|
|
BLAKE2b-256 checksum How to use checksums |
e51dabee6a06b6c2e82d5b503e12d841213e1b1c47a42eb2651e275f22b3ebe4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.9 Darwin/24.5.0
|
Release files / aissemble_universal_config_loader-0.1.0-py3-none-any.whl
| Download URL | aissemble_universal_config_loader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32ae0b9fdad21c265da9458fe018c47c5611ab7ec16599dbf8156154ab5f8d9a
|
|
BLAKE2b-256 checksum How to use checksums |
d09fd85c59f5790f51bc820611391fee63e661504965b527383c7fe81c9ab6b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.9 Darwin/24.5.0
|
Security for aissemble-universal-config-loader 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.