-
Notifications
You must be signed in to change notification settings - Fork 333
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
bug: azure settings no longer respected due to pydantic-settings==2.2.0
#857
Conversation
feel free to do something more proper and close this PR, really looking to understand why this is happening in some projects and not others |
ok wrong on two fronts -- in the project it was working, I had |
so at some point it seems |
still confused in that I can't find any commit where this seems to have changed |
hmmm I've noticed something fishy about can you try in case its helpful while sleuthing: https://github.com/pydantic/pydantic-settings/releases/tag/v2.2.0 |
I think you're on it -- this is the project where it works:
this is the project where it doesn't work:
edit: and downgrading in the latter project fixes it. looking through pydantic-setting's commits, I don't see anything obvious 🤷 but very glad we have a workaround this is also consistent w/ what others have seen, worked on their old environments and failing on one just created today (thus picking up the latest version) |
@lostmygithubaccount I'd like to figure this out can you be more specific about what you're seeing when things go wrong? I think I've noticed that things set in either that or the "bootlegged" settings (i.e. the ones that are accessible via |
yep so I have this in
then I import marvin and run a simple example: import marvin
result = marvin.classify(
"Marvin is so easy to use!",
labels=["positive", "negative"],
)
result and get this traceback:
which is happening because from rich import print
print(marvin.settings) gives (removing a bunch of stuff):
while in # --- Azure OpenAI
elif marvin.settings.provider == "azure_openai":
api_key = getattr(marvin.settings, "azure_openai_api_key", None)
api_version = getattr(marvin.settings, "azure_openai_api_version", None)
azure_endpoint = getattr(marvin.settings, "azure_openai_endpoint", None) and if I downgrade |
@lostmygithubaccount thank you! I'll see what I can figure out |
pydantic-settings==2.2.0
okay I think I have an MRE, now its just a matter of why 🙂
from pydantic_settings import BaseSettings, SettingsConfigDict
class FooSettings(BaseSettings):
model_config = SettingsConfigDict(
extra="allow",
env_file=".env",
env_prefix="foo_"
)
x: str
settings = FooSettings()
print(f'{getattr(settings, "y", None)=}')
print(f'{getattr(settings, "foo_y", None)=}')
on
|
opened a PR to fix on edit: this has been merged upstream and will likely go out with next release |
closing as the fix has been released upstream |
I am beyond confused and would appreciate any insights here. This bug shows up in one project I have, but not another, on the same computer. Others using Marivn have had a similar experience, where it works just fine in one environment but fails in another. I'm not sure what is going on.
I managed to fix it by inspecting the
marvin.settings
object and changing a few lines in the OpenAI provider, shown in the PRthis code doesn't seem to have changed in the last month. downgrading to older versions of Marvin does not fix this bug in the one project it's present in. I'm testing Marvin 2.1.2 - Marvin 2.1.5. I really can't figure it out