Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

validation.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. import logging
  17. import sys
  18. def python_version_validation():
  19. # Check python version
  20. required_python_version = (3, 10)
  21. if sys.version_info < required_python_version:
  22. logging.info(
  23. f"Required Python: >= {required_python_version[0]}.{required_python_version[1]}. Current Python version: {sys.version_info[0]}.{sys.version_info[1]}."
  24. )
  25. sys.exit(1)
  26. else:
  27. logging.info(f"Python version: {sys.version_info[0]}.{sys.version_info[1]}")
  28. python_version_validation()
  29. # Download nltk data
  30. def download_nltk_data():
  31. import nltk
  32. nltk.download('wordnet', halt_on_error=False, quiet=True)
  33. nltk.download('punkt_tab', halt_on_error=False, quiet=True)
  34. try:
  35. from multiprocessing import Pool
  36. pool = Pool(processes=1)
  37. thread = pool.apply_async(download_nltk_data)
  38. binary = thread.get(timeout=60)
  39. except Exception:
  40. print('\x1b[6;37;41m WARNING \x1b[0m' + "Downloading NLTK data failure.", flush=True)