-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: Adgudime/python/serialization/settings #1312
Python: Adgudime/python/serialization/settings #1312
Conversation
New dependencies: - python-dotenv: Required for pydantic to support dotenv files. Breaking Changes: - .env file config keys have changed. See .env.example file for new keys - Env Var `OpenAI__ApiKey` is no longer used in tests. It needs to be replaced in GitHub secrets with `OPENAI_API_KEY` - Removed `semantic_kernel.utils.settings::openai_settings_from_dot_env` - Removed `get_oai_config` fixture from `tests/conftest.py` Other changes: - (OpenAI) Settings can be loaded from - yaml files, - env vars, and, - .env files (in the same order of precedence) - Added tests for -new functionality, and - to ensure (some of) the old functionality hasn't changed. Next steps: Repeat this PR for `AzureOpenAISettings`
def create_kernel(): | ||
kernel = sk.Kernel() | ||
return kernel | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
@pytest.fixture() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rationale for removing scope="session" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another thing I forgot to mention. Apologies. I wanted to ask you about this, and made this change so that I don't forget it.
Did you intend to use scope="session"
in the fixture? The default scope is "function"
which basically means that the fixture gets recreated for every test. Other fixture scopes, in my experience, cause issues down the line, once the number of tests increases. Since non-function scope fixtures are shared across multiple tests, if any one of those tests makes a change to the result returned by the fixture, downstream tests see the changed value. And since the order in which the tests are run is not fixed (especially across code changes), it sometimes leads to failures which are not easily reproducible either.
Fixtures with larger scopes are typically used when the object being constructed in the fixture is heavy and takes time to be created or if you need the shared property of the fixture. These fixtures don't seem to be satisfying either of these criteria, so I just wanted to check with you on them.
Updated the target branch to feature-pydantic |
@awharrison-28 I see some failing UTs. Shall we help out @AdityaGudimella by merging to the feature-pydantic branch, and fixing the last few problems there? |
Moving this to draft |
@AdityaGudimella @awharrison-28 Closing as I understand this PR is superseded by the new ones. Please confirm or reopen if this PR is still applicable. |
Motivation and Context
This PR is the first of the PRs to use Pydantic in SemanticKernel. Any class that is a subclass
of
pydantic.BaseModel
is json serializable. This will be used to serialize theKernel
class.Serialization of the
Kernel
is required forMLFlow
integration.Description
New dependencies:
Breaking Changes:
OpenAI__ApiKey
is no longer used in tests.It needs to be replaced in GitHub secrets with
OPENAI_API_KEY
semantic_kernel.utils.settings::openai_settings_from_dot_env
get_oai_config
fixture fromtests/conftest.py
Other changes:
(in the same order of precedence)
-new functionality, and
Next steps:
Repeat this PR for
AzureOpenAISettings
Contribution Checklist
dotnet format