versions.py


Overview

The versions.py file is responsible for determining and providing the current version information of the InfiniFlow project, specifically the "ragflow" component. It implements mechanisms to retrieve version data from multiple sources including a static VERSION file or dynamically from Git tags in the source repository. This allows the application to report accurate version info during runtime, which is essential for debugging, logging, and deployment tracking.


Detailed Explanation

Global Variables

RAGFLOW_VERSION_INFO : str


Functions

get_ragflow_version() -> str


get_closest_tag_and_count() -> str


Important Implementation Details


Interaction with Other System Components


Mermaid Class Diagram

The file contains only functions and a global variable and no classes. Thus, a flowchart of the main functions and their relationships is appropriate.

flowchart TD
    A[get_ragflow_version()] -->|Checks cache| B{RAGFLOW_VERSION_INFO != "unknown"?}
    B -- Yes --> C[Return cached version]
    B -- No --> D[Check for VERSION file]
    D -- Exists --> E[Read version from file]
    D -- Not Exists --> F[get_closest_tag_and_count()]
    F --> G[Read LIGHTEN env var]
    G --> H[Append " slim" or " full" suffix]
    E --> I[Set RAGFLOW_VERSION_INFO]
    H --> I
    I --> C
    F -.-> J[Subprocess git describe]
    J -.-> K[Return git version or "unknown"]

Summary