### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [x] Refactoring --------- Signed-off-by: jinhai <haijin.chn@gmail.com>tags/v0.14.0
| @@ -30,7 +30,7 @@ from api.utils.api_utils import ( | |||
| server_error_response, | |||
| generate_confirmation_token, | |||
| ) | |||
| from api.versions import get_rag_version | |||
| from api.versions import get_ragflow_version | |||
| from api.settings import docStoreConn | |||
| from rag.utils.storage_factory import STORAGE_IMPL, STORAGE_IMPL_TYPE | |||
| from timeit import default_timer as timer | |||
| @@ -58,7 +58,7 @@ def version(): | |||
| type: string | |||
| description: Version number. | |||
| """ | |||
| return get_json_result(data=get_rag_version()) | |||
| return get_json_result(data=get_ragflow_version()) | |||
| @manager.route("/status", methods=["GET"]) | |||
| @@ -13,7 +13,7 @@ | |||
| # See the License for the specific language governing permissions and | |||
| # limitations under the License. | |||
| # | |||
| from api.versions import get_versions | |||
| from api.versions import get_ragflow_version | |||
| from .reload_config_base import ReloadConfigBase | |||
| @@ -35,7 +35,7 @@ class RuntimeConfig(ReloadConfigBase): | |||
| @classmethod | |||
| def init_env(cls): | |||
| cls.ENV.update(get_versions()) | |||
| cls.ENV.update({"version": get_ragflow_version()}) | |||
| @classmethod | |||
| def load_config_manager(cls): | |||
| @@ -44,7 +44,7 @@ from api import utils | |||
| from api.db.db_models import init_database_tables as init_web_db | |||
| from api.db.init_data import init_web_data | |||
| from api.versions import get_versions, RAGFLOW_VERSION_INFO | |||
| from api.versions import get_ragflow_version | |||
| def update_progress(): | |||
| @@ -66,7 +66,7 @@ if __name__ == '__main__': | |||
| """) | |||
| logging.info( | |||
| f'RAGFlow version: {RAGFLOW_VERSION_INFO}' | |||
| f'RAGFlow version: {get_ragflow_version()}' | |||
| ) | |||
| logging.info( | |||
| f'project base: {utils.file_utils.get_project_base_directory()}' | |||
| @@ -87,7 +87,7 @@ if __name__ == '__main__': | |||
| ) | |||
| args = parser.parse_args() | |||
| if args.version: | |||
| print(get_versions()) | |||
| print(get_ragflow_version()) | |||
| sys.exit(0) | |||
| RuntimeConfig.DEBUG = args.debug | |||
| @@ -103,7 +103,7 @@ if __name__ == '__main__': | |||
| # start http server | |||
| try: | |||
| logging.info("RAG Flow http server start...") | |||
| logging.info("RAGFlow HTTP server start...") | |||
| run_simple( | |||
| hostname=HOST, | |||
| port=HTTP_PORT, | |||
| @@ -17,35 +17,33 @@ import dotenv | |||
| import typing | |||
| import subprocess | |||
| def get_versions() -> typing.Mapping[str, typing.Any]: | |||
| dotenv.load_dotenv(dotenv.find_dotenv()) | |||
| return dotenv.dotenv_values() | |||
| def get_rag_version() -> typing.Optional[str]: | |||
| return get_versions().get("RAGFLOW_IMAGE", "infiniflow/ragflow:dev").split(":")[-1] | |||
| def get_ragflow_version() -> typing.Optional[str]: | |||
| return RAGFLOW_VERSION_INFO | |||
| RAGFLOW_VERSION_INFO = "dev" | |||
| def get_closest_tag_and_count(): | |||
| # Get the current commit hash | |||
| commit_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8') | |||
| # Get the closest tag | |||
| closest_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8') | |||
| # Get the commit hash of the closest tag | |||
| closest_tag_commit = subprocess.check_output(['git', 'rev-list', '-n', '1', closest_tag]).strip().decode('utf-8') | |||
| # Get the commit count since the closest tag | |||
| process = subprocess.Popen(['git', 'rev-list', '--count', f'{closest_tag}..HEAD'], stdout=subprocess.PIPE) | |||
| commits_count, _ = process.communicate() | |||
| commits_count = int(commits_count.strip()) | |||
| if commits_count == 0: | |||
| return closest_tag | |||
| else: | |||
| return f"{commit_id}({closest_tag}~{commits_count})" | |||
| try: | |||
| # Get the current commit hash | |||
| commit_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8') | |||
| # Get the closest tag | |||
| closest_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8') | |||
| # Get the commit hash of the closest tag | |||
| closest_tag_commit = subprocess.check_output(['git', 'rev-list', '-n', '1', closest_tag]).strip().decode( | |||
| 'utf-8') | |||
| # Get the commit count since the closest tag | |||
| process = subprocess.Popen(['git', 'rev-list', '--count', f'{closest_tag}..HEAD'], stdout=subprocess.PIPE) | |||
| commits_count, _ = process.communicate() | |||
| commits_count = int(commits_count.strip()) | |||
| if commits_count == 0: | |||
| return closest_tag | |||
| else: | |||
| return f"{commit_id}({closest_tag}~{commits_count})" | |||
| except Exception as e: | |||
| return 'unknown' | |||
| if RAGFLOW_VERSION_INFO == 'dev': | |||