| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  | # | 
					
						
							|  |  |  | #  Copyright 2024 The InfiniFlow Authors. All Rights Reserved. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #  Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  | #  you may not use this file except in compliance with the License. | 
					
						
							|  |  |  | #  You may obtain a copy of the License at | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #      http://www.apache.org/licenses/LICENSE-2.0 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #  Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  | #  distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  | #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  | #  See the License for the specific language governing permissions and | 
					
						
							|  |  |  | #  limitations under the License. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-14 17:13:48 +08:00
										 |  |  | import logging | 
					
						
							| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  | import sys | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-14 13:20:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  | def python_version_validation(): | 
					
						
							|  |  |  |     # Check python version | 
					
						
							|  |  |  |     required_python_version = (3, 10) | 
					
						
							|  |  |  |     if sys.version_info < required_python_version: | 
					
						
							| 
									
										
										
										
											2024-11-14 17:13:48 +08:00
										 |  |  |         logging.info( | 
					
						
							| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  |             f"Required Python: >= {required_python_version[0]}.{required_python_version[1]}. Current Python version: {sys.version_info[0]}.{sys.version_info[1]}." | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         sys.exit(1) | 
					
						
							|  |  |  |     else: | 
					
						
							| 
									
										
										
										
											2024-11-14 17:13:48 +08:00
										 |  |  |         logging.info(f"Python version: {sys.version_info[0]}.{sys.version_info[1]}") | 
					
						
							| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | python_version_validation() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-14 16:28:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-14 11:01:08 +08:00
										 |  |  | # Download nltk data | 
					
						
							| 
									
										
										
										
											2024-11-14 16:28:10 +08:00
										 |  |  | def download_nltk_data(): | 
					
						
							|  |  |  |     import nltk | 
					
						
							|  |  |  |     nltk.download('wordnet', halt_on_error=False, quiet=True) | 
					
						
							|  |  |  |     nltk.download('punkt_tab', halt_on_error=False, quiet=True) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | try: | 
					
						
							|  |  |  |     from multiprocessing import Pool | 
					
						
							|  |  |  |     pool = Pool(processes=1) | 
					
						
							| 
									
										
											  
											
												Print configs when startup RAGFlow server (#3414)
### What problem does this PR solve?
Print configs at the RAGFlow startup phase.
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
```
2024-11-14 21:27:53,090 INFO     962231 Current configs, from /home/weilongma/Documents/development/ragflow/conf/service_conf.yaml:
2024-11-14 21:27:53,090 INFO     962231 ragflow: {'host': '0.0.0.0', 'http_port': 9380}
2024-11-14 21:27:53,090 INFO     962231 mysql: {'name': 'rag_flow', 'user': 'root', 'password': 'infini_rag_flow', 'host': 'mysql', 'port': 5455, 'max_connections': 100, 'stale_timeout': 30}
2024-11-14 21:27:53,090 INFO     962231 minio: {'user': 'rag_flow', 'password': 'infini_rag_flow', 'host': 'minio:9000'}
2024-11-14 21:27:53,090 INFO     962231 es: {'hosts': 'http://es01:1200', 'username': 'elastic', 'password': 'infini_rag_flow'}
2024-11-14 21:27:53,090 INFO     962231 redis: {'db': 1, 'password': 'infini_rag_flow', 'host': 'redis:6379'}
```
Signed-off-by: jinhai <haijin.chn@gmail.com>
											
										 
											2024-11-15 09:29:40 +08:00
										 |  |  |     thread = pool.apply_async(download_nltk_data) | 
					
						
							|  |  |  |     binary = thread.get(timeout=60) | 
					
						
							| 
									
										
										
										
											2024-12-08 14:21:12 +08:00
										 |  |  | except Exception: | 
					
						
							| 
									
										
										
										
											2024-11-14 16:28:10 +08:00
										 |  |  |     print('\x1b[6;37;41m WARNING \x1b[0m' + "Downloading NLTK data failure.", flush=True) |