Andrchest commited on
Commit
9aa281e
·
1 Parent(s): 4f1adfd

final try 9

Browse files
Files changed (6) hide show
  1. .idea/misc.xml +1 -1
  2. .idea/test.iml +1 -1
  3. Dockerfile +10 -5
  4. app/initializer.py +34 -0
  5. app/main.py +4 -29
  6. initialize.sh +2 -0
.idea/misc.xml CHANGED
@@ -3,5 +3,5 @@
3
  <component name="Black">
4
  <option name="sdkName" value="Python 3.10 (test) (2)" />
5
  </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (test) (2)" project-jdk-type="Python SDK" />
7
  </project>
 
3
  <component name="Black">
4
  <option name="sdkName" value="Python 3.10 (test) (2)" />
5
  </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (The-Ultimate-RAG)" project-jdk-type="Python SDK" />
7
  </project>
.idea/test.iml CHANGED
@@ -4,7 +4,7 @@
4
  <content url="file://$MODULE_DIR$">
5
  <excludeFolder url="file://$MODULE_DIR$/.venv" />
6
  </content>
7
- <orderEntry type="jdk" jdkName="Python 3.10 (test) (2)" jdkType="Python SDK" />
8
  <orderEntry type="sourceFolder" forTests="false" />
9
  </component>
10
  </module>
 
4
  <content url="file://$MODULE_DIR$">
5
  <excludeFolder url="file://$MODULE_DIR$/.venv" />
6
  </content>
7
+ <orderEntry type="jdk" jdkName="Python 3.12 (The-Ultimate-RAG)" jdkType="Python SDK" />
8
  <orderEntry type="sourceFolder" forTests="false" />
9
  </component>
10
  </module>
Dockerfile CHANGED
@@ -26,6 +26,11 @@ RUN apt-get update \
26
  COPY app/requirements.txt /app/requirements.txt
27
  RUN pip install --upgrade --no-cache-dir pip
28
  RUN pip install --no-cache-dir -r /app/requirements.txt
 
 
 
 
 
29
  # download Qdrant binary
30
  RUN wget https://github.com/qdrant/qdrant/releases/download/v1.11.5/qdrant-x86_64-unknown-linux-gnu.tar.gz \
31
  && tar -xzf qdrant-x86_64-unknown-linux-gnu.tar.gz \
@@ -40,13 +45,13 @@ COPY start.sh /app/start.sh
40
  RUN chmod +x /app/start.sh
41
 
42
  # where SQLite DB and temp files will live (persisted by HF)
43
- RUN mkdir -p /mnt/data/app_database /mnt/data/temp_storage
44
-
45
- # expose HF-standard port
46
- EXPOSE 7860
47
 
48
  # env var for SQLAlchemy
49
- ENV DATABASE_URL="sqlite:////mnt/data/app_database/app.db"
50
 
51
  # launch both Qdrant and Uvicorn
52
  CMD ["./start.sh"]
 
26
  COPY app/requirements.txt /app/requirements.txt
27
  RUN pip install --upgrade --no-cache-dir pip
28
  RUN pip install --no-cache-dir -r /app/requirements.txt
29
+
30
+ # initializing some directiores
31
+ CMD ["python", "-m", "app.initializer"]
32
+
33
+
34
  # download Qdrant binary
35
  RUN wget https://github.com/qdrant/qdrant/releases/download/v1.11.5/qdrant-x86_64-unknown-linux-gnu.tar.gz \
36
  && tar -xzf qdrant-x86_64-unknown-linux-gnu.tar.gz \
 
45
  RUN chmod +x /app/start.sh
46
 
47
  # where SQLite DB and temp files will live (persisted by HF)
48
+ #RUN mkdir -p /mnt/data/app_database /mnt/data/temp_storage
49
+ #
50
+ ## expose HF-standard port
51
+ #EXPOSE 7860
52
 
53
  # env var for SQLAlchemy
54
+ #ENV DATABASE_URL="sqlite:////mnt/data/app_database/app.db"
55
 
56
  # launch both Qdrant and Uvicorn
57
  CMD ["./start.sh"]
app/initializer.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from app.backend.models.db_service import automigrate
4
+ from app.settings import base_path
5
+
6
+
7
+ def initialize_system() -> bool:
8
+ success = True
9
+ path = os.path.dirname(base_path)
10
+ temp_storage_path = os.path.join(path, os.path.join("app", "temp_storage"))
11
+ temp_storage_path_pdf = os.path.join(path, os.path.join("app", "temp_storage", "pdfs"))
12
+ database_path = os.path.join(path, "database")
13
+
14
+ try:
15
+ os.makedirs(temp_storage_path, exist_ok=True)
16
+ os.makedirs(database_path, exist_ok=True)
17
+ os.makedirs(temp_storage_path_pdf, exist_ok=True)
18
+ except Exception:
19
+ success = False
20
+ print("Not all required directories were initialized")
21
+
22
+ try:
23
+ # os.system(f"pip install -r {os.path.join(base_path, 'requirements.txt')}")
24
+ pass
25
+ except Exception:
26
+ success = False
27
+ print("Not all package were downloaded")
28
+
29
+ return success
30
+
31
+
32
+ if __name__ == '__main__':
33
+ initialize_system()
34
+ automigrate()
app/main.py CHANGED
@@ -1,37 +1,12 @@
1
- from app.settings import api_config, base_path
2
  import uvicorn
3
- import os
4
- from app.backend.models.db_service import automigrate
5
 
6
- def initialize_system() -> bool:
7
- success = True
8
- path = os.path.dirname(base_path)
9
- temp_storage_path = os.path.join(path, os.path.join("app", "temp_storage"))
10
- temp_storage_path_pdf = os.path.join(path, os.path.join("app", "temp_storage", "pdfs"))
11
- database_path = os.path.join(path, "database")
12
-
13
- try:
14
- os.makedirs(temp_storage_path, exist_ok=True)
15
- os.makedirs(database_path, exist_ok=True)
16
- os.makedirs(temp_storage_path_pdf, exist_ok=True)
17
- except Exception:
18
- success = False
19
- print("Not all required directories were initialized")
20
-
21
- try:
22
- # os.system(f"pip install -r {os.path.join(base_path, 'requirements.txt')}")
23
- pass
24
- except Exception:
25
- success = False
26
- print("Not all package were downloaded")
27
-
28
- return success
29
 
30
 
31
  def main():
32
- if not initialize_system():
33
- return
34
- automigrate() # Note: it will drop all existing dbs and create a new ones
35
  uvicorn.run(**api_config)
36
 
37
 
 
 
1
  import uvicorn
 
 
2
 
3
+ from app.settings import api_config
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
  def main():
7
+ # if not initialize_system():
8
+ # return
9
+ # automigrate() # Note: it will drop all existing dbs and create a new ones
10
  uvicorn.run(**api_config)
11
 
12
 
initialize.sh ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #!/usr/bin/env sh
2
+ exec python -m app.initializer