Skip to content

Commit

Permalink
fix: support env-only profile config instantiation (#125)
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <[email protected]>
  • Loading branch information
vagenas authored Aug 7, 2023
1 parent 0491ed4 commit 85f5793
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions deepsearch/core/client/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Dict, Optional

import platformdirs
from pydantic import ValidationError

from deepsearch.core.cli.profile_utils import (
MSG_AMBIGUOUS_SUCCESSOR,
Expand Down Expand Up @@ -111,10 +112,13 @@ def get_profile_settings(
) -> ProfileSettings:
prfl_name = profile_name or self.get_active_profile()
if prfl_name is None:
if len(self._profile_cache) == 0:
raise RuntimeError(MSG_NO_PROFILES_DEFINED)
else:
raise RuntimeError(MSG_NO_PROFILE_SELECTED)
try: # try to instantiate from environment alone
return ProfileSettings()
except ValidationError:
if len(self._profile_cache) == 0:
raise RuntimeError(MSG_NO_PROFILES_DEFINED)
else:
raise RuntimeError(MSG_NO_PROFILE_SELECTED)
else:
return self._safe_get_profile_entry(profile_name=prfl_name).settings

Expand Down

0 comments on commit 85f5793

Please sign in to comment.