kapllan commited on
Commit
570d236
1 Parent(s): 6881af9

Update prepare_everything.py

Browse files
Files changed (1) hide show
  1. prepare_everything.py +0 -52
prepare_everything.py CHANGED
@@ -1,14 +1,5 @@
1
- import os
2
- import subprocess
3
- import sys
4
- from pathlib import Path
5
-
6
  import requests
7
 
8
- from parltopic.utils.helper import get_main_config
9
-
10
- config = get_main_config()
11
-
12
 
13
  def download_model(url, save_path):
14
  # Send a GET request to the URL
@@ -26,46 +17,3 @@ def download_model(url, save_path):
26
  # Print an error message if the request was not successful
27
  print(f"Failed to download model. Status code: {response.status_code}")
28
 
29
-
30
- def set_tokenizers_parallelism(value):
31
- """Set the TOKENIZERS_PARALLELISM environment variable."""
32
- os.environ["TOKENIZERS_PARALLELISM"] = "true" if value else "false"
33
- print(f"TOKENIZERS_PARALLELISM set to {os.environ['TOKENIZERS_PARALLELISM']}")
34
-
35
-
36
- def install_requirements():
37
- """Install packages listed in requirements.txt"""
38
- try:
39
- subprocess.check_call(
40
- [sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]
41
- )
42
- print("All packages from requirements.txt installed successfully.")
43
- except subprocess.CalledProcessError as e:
44
- print(f"Failed to install packages from requirements.txt: {e}")
45
- sys.exit(1)
46
-
47
-
48
- def install_spacy_model(model_name):
49
- """Install a specific spaCy model"""
50
- try:
51
- subprocess.check_call([sys.executable, "-m", "spacy", "download", model_name])
52
- print(f"spaCy model '{model_name}' installed successfully.")
53
- except subprocess.CalledProcessError as e:
54
- print(f"Failed to install spaCy model '{model_name}': {e}")
55
- sys.exit(1)
56
-
57
-
58
- if __name__ == "__main__":
59
-
60
- for name, path in config["paths"].items():
61
- Path(path).mkdir(exist_ok=True)
62
-
63
- download_model(
64
- "https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin",
65
- Path(config["paths"]["resources"]) / "lid.176.bin",
66
- )
67
-
68
- install_spacy_model("de_core_news_lg")
69
- install_spacy_model("fr_core_news_lg")
70
- install_spacy_model("it_core_news_lg")
71
- set_tokenizers_parallelism(True)
 
 
 
 
 
 
1
  import requests
2
 
 
 
 
 
3
 
4
  def download_model(url, save_path):
5
  # Send a GET request to the URL
 
17
  # Print an error message if the request was not successful
18
  print(f"Failed to download model. Status code: {response.status_code}")
19