Skip to content

Commit

Permalink
expedite handling
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Vagenas <35837085+vagenas@users.noreply.github.com>
  • Loading branch information
vagenas committed Oct 20, 2023
1 parent 6e0c9c2 commit 1424aca
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions deepsearch/core/client/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ def __init__(self) -> None:
except ValidationError:
paths_to_remove.append(file_path)

# handle any invalid profiles
if paths_to_remove:
for path_to_rem in paths_to_remove:
path_to_rem.unlink()
profile_names = ", ".join([f'"{p.stem}"' for p in paths_to_remove])
err_msg = f"Following profiles were invalid and have been removed: {profile_names}; if needed please re-add"
raise RuntimeError(err_msg)

# reset any stale active profile config
if (
self._main_settings.profile is not None
Expand All @@ -99,13 +107,6 @@ def __init__(self) -> None:

self._migrate_legacy_config()

if paths_to_remove:
for path_to_rem in paths_to_remove:
path_to_rem.unlink()
profile_names = ", ".join([f'"{p.stem}"' for p in paths_to_remove])
err_msg = f"Following profiles were invalid and have been removed: {profile_names}; if needed please re-add"
raise RuntimeError(err_msg)

def _migrate_legacy_config(self) -> None:
if self._main_settings.profile is None:
legacy_cfg_path = self.config_root_path / LEGACY_CFG_FILENAME
Expand Down

0 comments on commit 1424aca

Please sign in to comment.