Commit
·
d7fa9e2
1
Parent(s):
6873540
Print version when RAGFlow server startup (#3393)
Browse files### What problem does this PR solve?
Print version when RAGFlow server startup
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
---------
Signed-off-by: jinhai <[email protected]>
Co-authored-by: Kevin Hu <[email protected]>
- .github/workflows/tests.yml +2 -2
- README.md +2 -2
- api/ragflow_server.py +4 -1
- api/versions.py +27 -1
- build_docker_image.sh +46 -0
- docker/update_version.sh +16 -0
.github/workflows/tests.yml
CHANGED
@@ -50,11 +50,11 @@ jobs:
|
|
50 |
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
|
51 |
cp -r ${RUNNER_WORKSPACE_PREFIX}/huggingface.co ${RUNNER_WORKSPACE_PREFIX}/nltk_data ${RUNNER_WORKSPACE_PREFIX}/libssl*.deb ${RUNNER_WORKSPACE_PREFIX}/tika-server*.jar* .
|
52 |
sudo docker pull ubuntu:24.04
|
53 |
-
sudo
|
54 |
|
55 |
- name: Build ragflow:dev
|
56 |
run: |
|
57 |
-
sudo
|
58 |
|
59 |
- name: Start ragflow:dev-slim
|
60 |
run: |
|
|
|
50 |
RUNNER_WORKSPACE_PREFIX=${RUNNER_WORKSPACE_PREFIX:-$HOME}
|
51 |
cp -r ${RUNNER_WORKSPACE_PREFIX}/huggingface.co ${RUNNER_WORKSPACE_PREFIX}/nltk_data ${RUNNER_WORKSPACE_PREFIX}/libssl*.deb ${RUNNER_WORKSPACE_PREFIX}/tika-server*.jar* .
|
52 |
sudo docker pull ubuntu:24.04
|
53 |
+
sudo ./build_docker_image.sh slim
|
54 |
|
55 |
- name: Build ragflow:dev
|
56 |
run: |
|
57 |
+
sudo ./build_docker_image.sh full
|
58 |
|
59 |
- name: Start ragflow:dev-slim
|
60 |
run: |
|
README.md
CHANGED
@@ -274,7 +274,7 @@ git clone https://github.com/infiniflow/ragflow.git
|
|
274 |
cd ragflow/
|
275 |
pip3 install huggingface-hub nltk
|
276 |
python3 download_deps.py
|
277 |
-
|
278 |
```
|
279 |
|
280 |
## 🔧 Build a Docker image including embedding models
|
@@ -286,7 +286,7 @@ git clone https://github.com/infiniflow/ragflow.git
|
|
286 |
cd ragflow/
|
287 |
pip3 install huggingface-hub nltk
|
288 |
python3 download_deps.py
|
289 |
-
|
290 |
```
|
291 |
|
292 |
## 🔨 Launch service from source for development
|
|
|
274 |
cd ragflow/
|
275 |
pip3 install huggingface-hub nltk
|
276 |
python3 download_deps.py
|
277 |
+
build_docker_image.sh slim
|
278 |
```
|
279 |
|
280 |
## 🔧 Build a Docker image including embedding models
|
|
|
286 |
cd ragflow/
|
287 |
pip3 install huggingface-hub nltk
|
288 |
python3 download_deps.py
|
289 |
+
build_docker_image.sh full
|
290 |
```
|
291 |
|
292 |
## 🔨 Launch service from source for development
|
api/ragflow_server.py
CHANGED
@@ -35,7 +35,7 @@ from api.utils.log_utils import logger
|
|
35 |
|
36 |
from api.db.db_models import init_database_tables as init_web_db
|
37 |
from api.db.init_data import init_web_data
|
38 |
-
from api.versions import get_versions
|
39 |
|
40 |
|
41 |
def update_progress():
|
@@ -56,6 +56,9 @@ if __name__ == '__main__':
|
|
56 |
/_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
|
57 |
|
58 |
""")
|
|
|
|
|
|
|
59 |
logger.info(
|
60 |
f'project base: {utils.file_utils.get_project_base_directory()}'
|
61 |
)
|
|
|
35 |
|
36 |
from api.db.db_models import init_database_tables as init_web_db
|
37 |
from api.db.init_data import init_web_data
|
38 |
+
from api.versions import get_versions, RAGFLOW_VERSION_INFO
|
39 |
|
40 |
|
41 |
def update_progress():
|
|
|
56 |
/_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
|
57 |
|
58 |
""")
|
59 |
+
logger.info(
|
60 |
+
f'RAGFlow version: {RAGFLOW_VERSION_INFO}'
|
61 |
+
)
|
62 |
logger.info(
|
63 |
f'project base: {utils.file_utils.get_project_base_directory()}'
|
64 |
)
|
api/versions.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15 |
#
|
16 |
import dotenv
|
17 |
import typing
|
|
|
18 |
|
19 |
|
20 |
def get_versions() -> typing.Mapping[str, typing.Any]:
|
@@ -23,4 +24,29 @@ def get_versions() -> typing.Mapping[str, typing.Any]:
|
|
23 |
|
24 |
|
25 |
def get_rag_version() -> typing.Optional[str]:
|
26 |
-
return get_versions().get("RAGFLOW_IMAGE", "infiniflow/ragflow:dev").split(":")[-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
#
|
16 |
import dotenv
|
17 |
import typing
|
18 |
+
import subprocess
|
19 |
|
20 |
|
21 |
def get_versions() -> typing.Mapping[str, typing.Any]:
|
|
|
24 |
|
25 |
|
26 |
def get_rag_version() -> typing.Optional[str]:
|
27 |
+
return get_versions().get("RAGFLOW_IMAGE", "infiniflow/ragflow:dev").split(":")[-1]
|
28 |
+
|
29 |
+
|
30 |
+
RAGFLOW_VERSION_INFO = "dev"
|
31 |
+
|
32 |
+
|
33 |
+
def get_closest_tag_and_count():
|
34 |
+
# Get the current commit hash
|
35 |
+
commit_id = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip().decode('utf-8')
|
36 |
+
# Get the closest tag
|
37 |
+
closest_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')
|
38 |
+
# Get the commit hash of the closest tag
|
39 |
+
closest_tag_commit = subprocess.check_output(['git', 'rev-list', '-n', '1', closest_tag]).strip().decode('utf-8')
|
40 |
+
# Get the commit count since the closest tag
|
41 |
+
process = subprocess.Popen(['git', 'rev-list', '--count', f'{closest_tag}..HEAD'], stdout=subprocess.PIPE)
|
42 |
+
commits_count, _ = process.communicate()
|
43 |
+
commits_count = int(commits_count.strip())
|
44 |
+
|
45 |
+
if commits_count == 0:
|
46 |
+
return closest_tag
|
47 |
+
else:
|
48 |
+
return f"{commit_id}({closest_tag}~{commits_count})"
|
49 |
+
|
50 |
+
|
51 |
+
if RAGFLOW_VERSION_INFO == 'dev':
|
52 |
+
RAGFLOW_VERSION_INFO = get_closest_tag_and_count()
|
build_docker_image.sh
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
print_help() {
|
4 |
+
echo "Usage: $0 <option>"
|
5 |
+
echo " full, build full image"
|
6 |
+
echo " slim, build slim image"
|
7 |
+
exit 1
|
8 |
+
}
|
9 |
+
|
10 |
+
if [ "$#" -ne 1 ]; then
|
11 |
+
print_help
|
12 |
+
fi
|
13 |
+
|
14 |
+
docker_version="full"
|
15 |
+
if [ "$1" == "full" ]; then
|
16 |
+
docker_version="full"
|
17 |
+
elif [ "$1" == "slim" ]; then
|
18 |
+
docker_version="slim"
|
19 |
+
else
|
20 |
+
print_help
|
21 |
+
fi
|
22 |
+
|
23 |
+
# update RAGFlow version
|
24 |
+
# Get the latest tag
|
25 |
+
last_tag=$(git describe --tags --abbrev=0)
|
26 |
+
# Get the number of commits from the last tag
|
27 |
+
commit_count=$(git rev-list --count "$last_tag..HEAD")
|
28 |
+
# Get the short commit id
|
29 |
+
last_commit=$(git rev-parse --short HEAD)
|
30 |
+
|
31 |
+
version_info=""
|
32 |
+
if [ "$commit_count" -eq 0 ]; then
|
33 |
+
version_info=$last_tag
|
34 |
+
else
|
35 |
+
printf -v version_info "%s(%s~%d)" "$last_commit" "$last_tag" $commit_count
|
36 |
+
fi
|
37 |
+
# Replace the version in the versions.py file
|
38 |
+
sed -i "s/\"dev\"/\"$version_info\"/" api/versions.py
|
39 |
+
|
40 |
+
if [ "$docker_version" == "full" ]; then
|
41 |
+
docker build -f Dockerfile -t infiniflow/ragflow:dev .
|
42 |
+
else
|
43 |
+
docker build -f Dockerfile.slim -t infiniflow/ragflow:dev-slim .
|
44 |
+
fi
|
45 |
+
|
46 |
+
git restore api/versions.py
|
docker/update_version.sh
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# update RAGFlow version
|
2 |
+
# Get the latest tag
|
3 |
+
last_tag=$(git describe --tags --abbrev=0)
|
4 |
+
# Get the number of commits from the last tag
|
5 |
+
commit_count=$(git rev-list --count "$last_tag..HEAD")
|
6 |
+
# Get the short commit id
|
7 |
+
last_commit=$(git rev-parse --short HEAD)
|
8 |
+
|
9 |
+
version_info=""
|
10 |
+
if [ "$commit_count" -eq 0 ]; then
|
11 |
+
version_info=$last_tag
|
12 |
+
else
|
13 |
+
printf -v version_info "%s(%s~%d)" "$last_commit" "$last_tag" $commit_count
|
14 |
+
fi
|
15 |
+
# Replace the version in the versions.py file
|
16 |
+
sed -i "s/\"dev\"/\"$version_info\"/" api/versions.py
|