tomoya 2 gadi atpakaļ
vecāks
revīzija
47f0333fd2
4 mainītis faili ar 13 papildinājumiem un 98 dzēšanām
  1. 4 0
      .env
  2. 0 92
      README.md
  3. 5 5
      backend/app/app/api/api_v1/endpoints/videos.py
  4. 4 1
      backend/app/app/core/config.py

+ 4 - 0
.env

@@ -52,6 +52,10 @@ PGADMIN_DEFAULT_PASSWORD=password
 MEMBERSHIP_STATUS=["normal", "infinite"]
 PROGRESS_STATE=["waiting", "processing", "completed"]
 
+# local storage
+LOCAL_ZIP_STORAGE=local_storage/zips
+LOCAL_VIDEO_STORAGE=local_storage/videos
+
 # celery
 CELERY_ZIP_STORAGE=celery_storage/zips
 CELERY_VIDEO_STORAGE=celery_storage/videos

+ 0 - 92
README.md

@@ -1,95 +1,3 @@
-RUN ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-36m-x86_64-linux-gnu.so 
-RUN ln -s /usr/lib/python3/dist-packages/gi/_gi.cpython-36m-x86_64-linux-gnu.so
-RUN apt-get install -y software-properties-common
-
-#RUN python3.6 /usr/bin/apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
-RUN git clone https://github.com/OpenShot/libopenshot.git
-RUN git clone https://github.com/OpenShot/libopenshot-audio.git
-RUN python3.6 /usr/bin/add-apt-repository ppa:openshot.developers/libopenshot-daily
-
-RUN apt-get install -y \
-    cmake \
-    pkg-config \
-    libopenshot-audio-dev \
-    libx11-dev \
-    libfreetype6-dev \
-    libasound2-dev \
-    libavcodec-dev \
-    libavformat-dev \
-    libavutil-dev \
-    libswresample-dev \
-    libswscale-dev \
-    libpostproc-dev \
-    libfdk-aac-dev \
-    libjsoncpp-dev \
-    libzmq3-dev \
-    qtbase5-dev \
-    libqt5svg5-dev \
-    libbabl-dev \
-    libopencv-dev \
-    libprotobuf-dev \
-    protobuf-compiler \
-    python3-dev \
-    swig \
-    libmagick++-dev
-
-RUN ls
-RUN cd libopenshot-audio
-WORKDIR /app/libopenshot-audio
-RUN cmake -B build -S .
-RUN cmake --build build
-RUN cmake --install build
-
-RUN cd ../libopenshot
-WORKDIR /app/libopenshot
-RUN cmake -B build -S .
-RUN cmake --build build
-
-RUN cd ..
-WORKDIR /app/
-
-# Install Poetry
-RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python3 && \
-    cd /usr/local/bin && \
-    ln -s /opt/poetry/bin/poetry && \
-    poetry config virtualenvs.create false
-
-# Copy poetry.lock* in case it doesn't exist in the repo
-COPY ./app/gpuproject.toml /app/pyproject.toml
-# COPY ./app/poetry.lock* /app/
-
-# Allow installing dev dependencies to run tests
-ARG INSTALL_DEV=false
-RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
-
-# For development, Jupyter remote kernel, Hydrogen
-# Using inside the container:
-# jupyter lab --ip=0.0.0.0 --allow-root --NotebookApp.custom_display_url=http://127.0.0.1:8888
-ARG INSTALL_JUPYTER=false
-RUN bash -c "if [ $INSTALL_JUPYTER == 'true' ] ; then pip install jupyterlab ; fi"
-
-ENV C_FORCE_ROOT=1
-
-COPY ./app /app
-WORKDIR /app
-COPY /${CELERY_ZIP_STORAGE} /app/${CELERY_ZIP_STORAGE}
-COPY /${CELERY_ZIP_STORAGE} /app/${CELERY_ZIP_STORAGE}
-
-RUN apt-get install -y python3.10
-#ENV PYTHONPATH=/app
-
-
-RUN python --version
-RUN python3 --version
-RUN echo ${PYTHONPATH}
-
-
-COPY ./app/worker-start.sh /worker-start.sh
-
-RUN chmod +x /worker-start.sh
-
-CMD ["bash", "/worker-start.sh"]
-
 # AI anchor
 
 ## Backend Requirements

+ 5 - 5
backend/app/app/api/api_v1/endpoints/videos.py

@@ -16,8 +16,8 @@ from pathlib import Path
 
 from app.core.celery_app import celery_app
 
-ZIP_STORAGE = Path("/app").joinpath(settings.BACKEND_ZIP_STORAGE)
-VIDEO_STORAGE = Path("/app").joinpath(settings.BACKEND_VIDEO_STORAGE)
+BACKEND_ZIP_STORAGE = Path("/app").joinpath(settings.BACKEND_ZIP_STORAGE)
+LOCAL_ZIP_STORAGW = Path(settings.BACKEND_ZIP_STORAGE)
 
 
 router = APIRouter()
@@ -58,7 +58,7 @@ def upload_plot(
     video = crud.video.create_with_owner(db=db, obj_in=video_create, owner_id=current_user.id)
 
     try:
-        with open(str(Path(ZIP_STORAGE).joinpath(video.stored_file_name+".zip")), 'wb') as f:
+        with open(str(Path(BACKEND_ZIP_STORAGE).joinpath(video.stored_file_name+".zip")), 'wb') as f:
             while contents := upload_file.file.read(1024 * 1024):
                 f.write(contents)
     except Exception as e:
@@ -67,8 +67,8 @@ def upload_plot(
     finally:
         upload_file.file.close()
     zip_filename = video.stored_file_name+".zip"
-    print(str(ZIP_STORAGE/zip_filename))
-    subprocess.run(f'sshpass -p "choozmo9" scp {str(ZIP_STORAGE/zip_filename)}  root@172.104.93.163:{str(ZIP_STORAGE/zip_filename)}')
+    print(str(BACKEND_ZIP_STORAGE/zip_filename))
+    subprocess.run(f'sshpass -p "choozmo9" scp {str(BACKEND_ZIP_STORAGE/zip_filename)}  root@172.104.93.163:{str(LOCAL_ZIP_STORAGW/zip_filename)}')
     celery_app.send_task("app.worker.make_video", args=[video.id, video.stored_file_name, current_user.id])
     return video
 

+ 4 - 1
backend/app/app/core/config.py

@@ -79,7 +79,7 @@ class Settings(BaseSettings):
     USERS_OPEN_REGISTRATION: bool = False
 
     MEMBERSHIP_STATUS : List[str] = ['normal', 'infinite']
-    PROGRESS_STATE: List[str] = ['waiting', 'processing', 'completed']
+    PROGRESS_STATE: List[str] = ['waiting', 'processing', 'completed', 'failed']
 
     SERVER_ADDRESS: AnyHttpUrl = "http://172.105.219.42:8080"
 
@@ -89,6 +89,9 @@ class Settings(BaseSettings):
     BACKEND_ZIP_STORAGE: str = "/backend_storage/zips"
     BACKEND_VIDEO_STORAGE: str = "/backend_storage/videos"
 
+    LOCAL_ZIP_STORAGE:str = 'local_storage/zips'
+    LOCAL_VIDEO_STORAGE:str = 'local_storage/videos'
+
     class Config:
         case_sensitive = True