File size: 1,517 Bytes
03fbd26
 
 
 
069a75c
03fbd26
e730de6
 
 
069a75c
 
 
 
 
 
 
 
 
 
 
 
0a9c507
069a75c
 
 
 
 
e730de6
 
03fbd26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
import time

import shutil

if os.environ.get('INSIDEDOCKER'):
    db_file = os.path.join(os.getcwd(), "db.sqlite3")

    if os.path.exists(db_file) and (time.time() - os.path.getmtime(db_file) < 300):
        print("db.sqlite3 exists and is recent. Skipping download.")
    else:
        from huggingface_hub import hf_hub_download
        custom_cache_dir = os.path.expanduser("/app/.cache/huggingface")

        file_path = hf_hub_download(
            repo_id="SushantGautam/BridgeMentor",
            filename="db.sqlite3",
            repo_type="dataset",
            cache_dir=custom_cache_dir
        )
        print(f"Downloaded to: {file_path}")
        destination_path = os.path.join(os.getcwd(), "db.sqlite3")
        shutil.copy(file_path, destination_path)
        print(f"db.sqlite3 Copied to current directory: {destination_path}")


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'BridgeMentor.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()