-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: Refactor environment variable naming for clarity and consistency #5686
Conversation
- Updated environment variable names to use single underscores for better readability and to avoid potential confusion. - Modified `service_configurator.py` to align with the updated environment variable naming convention. - Updated `.env.example` to reflect the new environment variable names, ensuring consistency across the project. - Added error handling and improved error messages in `service_configurator.py` for better debugging and maintainability.
HI, I've noticed that this PR hasn't been approved yet. Are there any issues, or is there anything else I should add? Please let me know :) |
Thanks for following up. Just need one more approval from @eavanvalkenburg or @juliomenendez. |
Thank you for your contribution, @bx-h. |
…ncy (microsoft#5686) ### Summary of Changes - Updated environment variable names to use single underscores for better readability and to avoid potential confusion. - Modified `service_configurator.py` to align with the updated environment variable naming convention. - Updated `.env.example` to reflect the new environment variable names, ensuring consistency across the project. - Added error handling and improved error messages in `service_configurator.py` for better debugging and maintainability. ### Motivation and Context The motivation for these changes is to address a bug where the `service_configurator.py` script is unable to read the `GLOBAL_LLM_SERVICE` environment variable due to inconsistent naming conventions. Additionally, the Azure service configuration variables were not being utilized, which could potentially lead to misconfigurations in certain deployment scenarios. - **Why is this change required?** To fix existing bugs related to environment variable handling and improve code maintainability and readability. - **What problem does it solve?** Ensures reliable loading of environment variables and correct configuration of AI services, thereby preventing runtime errors. - **What scenario does it contribute to?** Enhances the stability and reliability of the AI service configuration process within the semantic-kernel project. ### Description This PR addresses the issue where the environment variable `GLOBAL_LLM_SERVICE` was not consistently read due to a mismatch in the expected naming convention. The problem was identified in the `service_configurator.py` script where the variable was referenced with two underscores instead of one. Additionally, Azure service deployment names were not being used, leading to potential misconfigurations. - Modified the naming convention from double to single underscores for all environment variables in `service_configurator.py` and `.env.example`. - Ensured that Azure service deployment names are correctly utilized in the service configuration logic. - Improved error handling in the script to provide clearer and more actionable feedback. For more context, here's a link to the buggy code: [Link to the code](https://github.com/microsoft/semantic-kernel/blob/main/python/samples/documentation_examples/service_configurator.py#L27), [Link to the code](https://github.com/microsoft/semantic-kernel/blob/main/python/samples/documentation_examples/.env.example#L1) ![1](https://github.com/microsoft/semantic-kernel/assets/22412942/4bd00119-c2d6-41ee-9bbf-67e6e99e8536) ![2](https://github.com/microsoft/semantic-kernel/assets/22412942/ac6c0f56-c4bd-4383-99da-61f728ae931f) ### Contribution Checklist - [x] The code builds clean without any errors or warnings. - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations. - [x] All unit tests pass, and I have added new tests where possible. - [x] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com> Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
Summary of Changes
service_configurator.py
to align with the updated environment variable naming convention..env.example
to reflect the new environment variable names, ensuring consistency across the project.service_configurator.py
for better debugging and maintainability.Motivation and Context
The motivation for these changes is to address a bug where the
service_configurator.py
script is unable to read theGLOBAL_LLM_SERVICE
environment variable due to inconsistent naming conventions. Additionally, the Azure service configuration variables were not being utilized, which could potentially lead to misconfigurations in certain deployment scenarios.Description
This PR addresses the issue where the environment variable
GLOBAL_LLM_SERVICE
was not consistently read due to a mismatch in the expected naming convention. The problem was identified in theservice_configurator.py
script where the variable was referenced with two underscores instead of one. Additionally, Azure service deployment names were not being used, leading to potential misconfigurations.service_configurator.py
and.env.example
.For more context, here's a link to the buggy code: Link to the code, Link to the code
Contribution Checklist