Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
lazy import gitpython (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeknnDestroy authored Oct 20, 2023
1 parent 07cdf01 commit b48fa0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions autollm/utils/git_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import logging
from pathlib import Path

from git import Repo

logger = logging.getLogger(__name__)


Expand All @@ -14,6 +12,14 @@ def clone_or_pull_repository(git_url: str, local_path: Path) -> None:
git_url (str): The URL of the Git repository.
local_path (Path): The local path where the repository will be cloned or updated.
"""
# Lazy import to avoid dependency on GitPython
try:
from git import Repo
except ImportError:
logger.error(
'GitPython is not installed. Please "pip install gitpython==3.1.37" to use this feature.')
raise

if local_path.exists():
logger.info(f'Updating existing repository at {local_path}')
repo = Repo(str(local_path))
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
llama-index==0.8.46
litellm==0.8.4
gitpython==3.1.37
uvicorn==0.23.2
fastapi==0.103.2
python-dotenv
Expand Down

0 comments on commit b48fa0e

Please sign in to comment.