uripper commited on
Commit
ccbd581
·
1 Parent(s): 70cdff9

attempting to consolidate

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -0
  2. app/download_models.py +60 -0
  3. requirements.txt +2 -1
Dockerfile CHANGED
@@ -11,6 +11,8 @@ COPY . /app
11
  # Install any needed packages specified in requirements.txt
12
  RUN pip install --no-cache-dir -r /app/requirements.txt
13
 
 
 
14
  # Make port 7860 available to the world outside this container
15
  EXPOSE 7860
16
 
 
11
  # Install any needed packages specified in requirements.txt
12
  RUN pip install --no-cache-dir -r /app/requirements.txt
13
 
14
+ RUN python /app/download_model.py
15
+
16
  # Make port 7860 available to the world outside this container
17
  EXPOSE 7860
18
 
app/download_models.py CHANGED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import hf_hub_download
3
+
4
+
5
+ def create_directory(dir_path):
6
+ """
7
+ Create the directory if it doesn't exist.
8
+ """
9
+ if not os.path.exists(dir_path):
10
+ os.makedirs(dir_path)
11
+ print(f"Directory {dir_path} created.")
12
+ else:
13
+ print(f"Directory {dir_path} already exists.")
14
+
15
+
16
+ def download_model(repo_id, filename, destination_dir):
17
+ """
18
+ Download the model from Hugging Face and move it to the destination directory.
19
+ """
20
+ # Create destination directory if it doesn't exist
21
+ create_directory(destination_dir)
22
+
23
+ # Download the file from the Hugging Face Hub
24
+ model_path = hf_hub_download(repo_id=repo_id, filename=filename)
25
+
26
+ # Move the downloaded file to the destination directory
27
+ destination_path = os.path.join(destination_dir, filename)
28
+ os.rename(model_path, destination_path)
29
+
30
+ # Print the full path of the downloaded file
31
+ full_path = os.path.abspath(destination_path)
32
+ print(f"Downloaded {filename} and moved to: {full_path}")
33
+ return full_path
34
+
35
+
36
+ if __name__ == "__main__":
37
+ # Define the repositories and filenames
38
+ magic_gnn_repo = "uripper/magic-gnn"
39
+ oracle_cards_graph_repo = "uripper/oracle_cards_graph"
40
+
41
+ # Define the files to download and their destination directories
42
+ card_graph_file = "card_graph.pkl"
43
+ oracle_cards_graph_file = "oracle_cards_graph.pkl"
44
+
45
+ # Destination directories where the files will be stored
46
+ card_graph_dir = "./models/magic-gnn"
47
+ oracle_cards_graph_dir = "./data/oracle_cards_graph"
48
+
49
+ # Download the card_graph.pkl from uripper/magic-gnn
50
+ card_graph_path = download_model(magic_gnn_repo, card_graph_file, card_graph_dir)
51
+
52
+ # Download the oracle_cards_graph.pkl from uripper/oracle_cards_graph
53
+ oracle_cards_graph_path = download_model(
54
+ oracle_cards_graph_repo, oracle_cards_graph_file, oracle_cards_graph_dir
55
+ )
56
+
57
+ # Print final message with full paths
58
+ print("\nDownload complete:")
59
+ print(f"Card Graph: {card_graph_path}")
60
+ print(f"Oracle Cards Graph: {oracle_cards_graph_path}")
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  Flask
2
  pandas
3
  Flask-Cors
4
- networkx
 
 
1
  Flask
2
  pandas
3
  Flask-Cors
4
+ networkx
5
+ huggingface-hub