Skip to content

Commit

Permalink
Move get_version to algo/util.py; fix version to 0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkRx committed Dec 17, 2024
1 parent 75a1209 commit 452abe2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pr_agent/algo/ai_handlers/litellm_ai_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from tenacity import retry, retry_if_exception_type, stop_after_attempt

from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler
from pr_agent.algo.utils import get_version
from pr_agent.config_loader import get_settings
from pr_agent.log import get_logger
from pr_agent.version import get_version

OPENAI_RETRIES = 5

Expand Down
23 changes: 23 additions & 0 deletions pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import json
import os
import re
import sys
import textwrap
import time
import traceback
from datetime import datetime
from enum import Enum
from importlib.metadata import PackageNotFoundError, version
from typing import Any, List, Tuple

import html2text
Expand Down Expand Up @@ -1106,3 +1108,24 @@ def process_description(description_full: str) -> Tuple[str, List]:
get_logger().exception(f"Failed to process description: {e}")

return base_description_str, files

def get_version() -> str:
# First check pyproject.toml if running directly out of repository
if os.path.exists("pyproject.toml"):
if sys.version_info >= (3, 11):
import tomllib
with open("pyproject.toml", "rb") as f:
data = tomllib.load(f)
if "project" in data and "version" in data["project"]:
return data["project"]["version"]
else:
get_logger().warning("Version not found in pyproject.toml")
else:
get_logger().warning("Unable to determine local version from pyproject.toml")

# Otherwise get the installed pip package version
try:
return version('pr-agent')
except PackageNotFoundError:
get_logger().warning("Unable to find package named 'pr-agent'")
return "unknown"
2 changes: 1 addition & 1 deletion pr_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os

from pr_agent.agent.pr_agent import PRAgent, commands
from pr_agent.algo.utils import get_version
from pr_agent.config_loader import get_settings
from pr_agent.log import get_logger, setup_logger
from pr_agent.version import get_version

log_level = os.environ.get("LOG_LEVEL", "INFO")
setup_logger(log_level)
Expand Down
23 changes: 0 additions & 23 deletions pr_agent/version.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pr-agent"
version = "0.2.6"
version = "0.2.5"

authors = [{ name = "CodiumAI", email = "[email protected]" }]

Expand Down

0 comments on commit 452abe2

Please sign in to comment.