Przeglądaj źródła

Update version display on web UI (#3405)

### 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
Jin Hai 11 miesięcy temu
rodzic
commit
e4c4fdabbd
No account linked to committer's email address
4 zmienionych plików z 29 dodań i 31 usunięć
  1. 2
    2
      api/apps/system_app.py
  2. 2
    2
      api/db/runtime_config.py
  3. 4
    4
      api/ragflow_server.py
  4. 21
    23
      api/versions.py

+ 2
- 2
api/apps/system_app.py Wyświetl plik

server_error_response, server_error_response,
generate_confirmation_token, generate_confirmation_token,
) )
from api.versions import get_rag_version
from api.versions import get_ragflow_version
from api.settings import docStoreConn from api.settings import docStoreConn
from rag.utils.storage_factory import STORAGE_IMPL, STORAGE_IMPL_TYPE from rag.utils.storage_factory import STORAGE_IMPL, STORAGE_IMPL_TYPE
from timeit import default_timer as timer from timeit import default_timer as timer
type: string type: string
description: Version number. description: Version number.
""" """
return get_json_result(data=get_rag_version())
return get_json_result(data=get_ragflow_version())




@manager.route("/status", methods=["GET"]) @manager.route("/status", methods=["GET"])

+ 2
- 2
api/db/runtime_config.py Wyświetl plik

# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
from api.versions import get_versions
from api.versions import get_ragflow_version
from .reload_config_base import ReloadConfigBase from .reload_config_base import ReloadConfigBase






@classmethod @classmethod
def init_env(cls): def init_env(cls):
cls.ENV.update(get_versions())
cls.ENV.update({"version": get_ragflow_version()})


@classmethod @classmethod
def load_config_manager(cls): def load_config_manager(cls):

+ 4
- 4
api/ragflow_server.py Wyświetl plik



from api.db.db_models import init_database_tables as init_web_db from api.db.db_models import init_database_tables as init_web_db
from api.db.init_data import init_web_data 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(): def update_progress():


""") """)
logging.info( logging.info(
f'RAGFlow version: {RAGFLOW_VERSION_INFO}'
f'RAGFlow version: {get_ragflow_version()}'
) )
logging.info( logging.info(
f'project base: {utils.file_utils.get_project_base_directory()}' f'project base: {utils.file_utils.get_project_base_directory()}'
) )
args = parser.parse_args() args = parser.parse_args()
if args.version: if args.version:
print(get_versions())
print(get_ragflow_version())
sys.exit(0) sys.exit(0)


RuntimeConfig.DEBUG = args.debug RuntimeConfig.DEBUG = args.debug


# start http server # start http server
try: try:
logging.info("RAG Flow http server start...")
logging.info("RAGFlow HTTP server start...")
run_simple( run_simple(
hostname=HOST, hostname=HOST,
port=HTTP_PORT, port=HTTP_PORT,

+ 21
- 23
api/versions.py Wyświetl plik

import typing import typing
import subprocess 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" RAGFLOW_VERSION_INFO = "dev"




def get_closest_tag_and_count(): 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': if RAGFLOW_VERSION_INFO == 'dev':

Ładowanie…
Anuluj
Zapisz