Spaces:
Running
Running
fix: resolve ModuleNotFoundError and simplify CI/CD
Browse files- .github/workflows/codeql.yml +0 -65
- .github/workflows/dependency-review.yml +0 -22
- .github/workflows/pylint.yml +0 -51
- .github/workflows/python-app.yml +0 -68
- Dockerfile +1 -1
- backend/app.py +6 -6
- run.sh +1 -1
.github/workflows/codeql.yml
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
# For most projects, this workflow file will not need changing; you simply need
|
| 2 |
-
# to commit it to your repository.
|
| 3 |
-
#
|
| 4 |
-
# You may wish to alter this file to override the set of languages analyzed,
|
| 5 |
-
# or to provide custom queries or build logic.
|
| 6 |
-
#
|
| 7 |
-
# ******** NOTE ********
|
| 8 |
-
# We have attempted to detect the languages in your repository. Please check
|
| 9 |
-
# the `language` matrix defined below to confirm you have the correct set of
|
| 10 |
-
# supported CodeQL languages.
|
| 11 |
-
#
|
| 12 |
-
name: BIAF CodeQL Security Scan
|
| 13 |
-
|
| 14 |
-
on:
|
| 15 |
-
push:
|
| 16 |
-
branches: ["main"]
|
| 17 |
-
pull_request:
|
| 18 |
-
branches: ["main"]
|
| 19 |
-
schedule:
|
| 20 |
-
- cron: '0 3 * * 1'
|
| 21 |
-
|
| 22 |
-
jobs:
|
| 23 |
-
analyze:
|
| 24 |
-
name: Analyze
|
| 25 |
-
runs-on: ubuntu-latest
|
| 26 |
-
|
| 27 |
-
permissions:
|
| 28 |
-
actions: read
|
| 29 |
-
contents: read
|
| 30 |
-
security-events: write
|
| 31 |
-
|
| 32 |
-
strategy:
|
| 33 |
-
fail-fast: false
|
| 34 |
-
matrix:
|
| 35 |
-
language: ["python"]
|
| 36 |
-
|
| 37 |
-
steps:
|
| 38 |
-
- name: Checkout repository
|
| 39 |
-
uses: actions/checkout@v4
|
| 40 |
-
|
| 41 |
-
- name: Initialize CodeQL
|
| 42 |
-
uses: github/codeql-action/init@v3
|
| 43 |
-
with:
|
| 44 |
-
languages: ${{ matrix.language }}
|
| 45 |
-
|
| 46 |
-
- name: Install ffmpeg
|
| 47 |
-
run: |
|
| 48 |
-
sudo apt update
|
| 49 |
-
sudo apt install -y ffmpeg
|
| 50 |
-
|
| 51 |
-
- name: Set up Python
|
| 52 |
-
uses: actions/setup-python@v5
|
| 53 |
-
with:
|
| 54 |
-
python-version: "3.10"
|
| 55 |
-
|
| 56 |
-
- name: Install dependencies
|
| 57 |
-
run: |
|
| 58 |
-
python -m pip install --upgrade pip
|
| 59 |
-
|
| 60 |
-
if [ -f requirements.txt ]; then
|
| 61 |
-
pip install -r requirements.txt
|
| 62 |
-
fi
|
| 63 |
-
|
| 64 |
-
- name: Perform CodeQL Analysis
|
| 65 |
-
uses: github/codeql-action/analyze@v3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/dependency-review.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
name: BIAF Dependency Review
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
pull_request:
|
| 5 |
-
branches: ["main"]
|
| 6 |
-
|
| 7 |
-
permissions:
|
| 8 |
-
contents: read
|
| 9 |
-
|
| 10 |
-
jobs:
|
| 11 |
-
dependency-review:
|
| 12 |
-
runs-on: ubuntu-latest
|
| 13 |
-
|
| 14 |
-
steps:
|
| 15 |
-
- name: Checkout repository
|
| 16 |
-
uses: actions/checkout@v4
|
| 17 |
-
|
| 18 |
-
- name: Dependency Review
|
| 19 |
-
uses: actions/dependency-review-action@v4
|
| 20 |
-
with:
|
| 21 |
-
fail-on-severity: high
|
| 22 |
-
deny-licenses: GPL-2.0, GPL-3.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/pylint.yml
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
name: BIAF Pylint Check
|
| 2 |
-
|
| 3 |
-
on:
|
| 4 |
-
push:
|
| 5 |
-
branches: ["main"]
|
| 6 |
-
pull_request:
|
| 7 |
-
branches: ["main"]
|
| 8 |
-
|
| 9 |
-
jobs:
|
| 10 |
-
pylint:
|
| 11 |
-
|
| 12 |
-
runs-on: ubuntu-latest
|
| 13 |
-
|
| 14 |
-
strategy:
|
| 15 |
-
matrix:
|
| 16 |
-
python-version: ["3.10"]
|
| 17 |
-
|
| 18 |
-
steps:
|
| 19 |
-
- name: Checkout repository
|
| 20 |
-
uses: actions/checkout@v4
|
| 21 |
-
|
| 22 |
-
- name: Set up Python
|
| 23 |
-
uses: actions/setup-python@v5
|
| 24 |
-
with:
|
| 25 |
-
python-version: ${{ matrix.python-version }}
|
| 26 |
-
|
| 27 |
-
- name: Install system dependencies
|
| 28 |
-
run: |
|
| 29 |
-
sudo apt update
|
| 30 |
-
sudo apt install -y ffmpeg
|
| 31 |
-
|
| 32 |
-
- name: Cache pip dependencies
|
| 33 |
-
uses: actions/cache@v4
|
| 34 |
-
with:
|
| 35 |
-
path: ~/.cache/pip
|
| 36 |
-
key: ${{ runner.os }}-pylint-${{ hashFiles('**/requirements.txt') }}
|
| 37 |
-
|
| 38 |
-
- name: Install Python dependencies
|
| 39 |
-
run: |
|
| 40 |
-
python -m pip install --upgrade pip
|
| 41 |
-
|
| 42 |
-
if [ -f requirements.txt ]; then
|
| 43 |
-
pip install -r requirements.txt
|
| 44 |
-
fi
|
| 45 |
-
|
| 46 |
-
pip install pylint
|
| 47 |
-
|
| 48 |
-
- name: Run pylint
|
| 49 |
-
run: |
|
| 50 |
-
pylint $(git ls-files '*.py') \
|
| 51 |
-
--disable=C0114,C0115,C0116,R0903 || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/python-app.yml
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
| 2 |
-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
| 3 |
-
name: BIAF Python CI
|
| 4 |
-
|
| 5 |
-
on:
|
| 6 |
-
push:
|
| 7 |
-
branches: ["main"]
|
| 8 |
-
pull_request:
|
| 9 |
-
branches: ["main"]
|
| 10 |
-
|
| 11 |
-
permissions:
|
| 12 |
-
contents: read
|
| 13 |
-
|
| 14 |
-
jobs:
|
| 15 |
-
build:
|
| 16 |
-
|
| 17 |
-
runs-on: ubuntu-latest
|
| 18 |
-
|
| 19 |
-
strategy:
|
| 20 |
-
matrix:
|
| 21 |
-
python-version: ["3.10"]
|
| 22 |
-
|
| 23 |
-
steps:
|
| 24 |
-
- name: Checkout repository
|
| 25 |
-
uses: actions/checkout@v4
|
| 26 |
-
|
| 27 |
-
- name: Set up Python
|
| 28 |
-
uses: actions/setup-python@v5
|
| 29 |
-
with:
|
| 30 |
-
python-version: ${{ matrix.python-version }}
|
| 31 |
-
|
| 32 |
-
- name: Install ffmpeg
|
| 33 |
-
run: |
|
| 34 |
-
sudo apt update
|
| 35 |
-
sudo apt install -y ffmpeg
|
| 36 |
-
|
| 37 |
-
- name: Cache pip dependencies
|
| 38 |
-
uses: actions/cache@v4
|
| 39 |
-
with:
|
| 40 |
-
path: ~/.cache/pip
|
| 41 |
-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
| 42 |
-
restore-keys: |
|
| 43 |
-
${{ runner.os }}-pip-
|
| 44 |
-
|
| 45 |
-
- name: Install dependencies
|
| 46 |
-
run: |
|
| 47 |
-
python -m pip install --upgrade pip
|
| 48 |
-
|
| 49 |
-
for f in requirements.txt backend/requirements.txt; do
|
| 50 |
-
[ -f "$f" ] && pip install -r "$f"
|
| 51 |
-
done
|
| 52 |
-
|
| 53 |
-
pip install pytest flake8
|
| 54 |
-
|
| 55 |
-
- name: Verify ffmpeg installation
|
| 56 |
-
run: ffmpeg -version
|
| 57 |
-
|
| 58 |
-
- name: Lint project
|
| 59 |
-
run: |
|
| 60 |
-
flake8 . \
|
| 61 |
-
--count \
|
| 62 |
-
--select=E9,F63,F7,F82 \
|
| 63 |
-
--show-source \
|
| 64 |
-
--statistics
|
| 65 |
-
|
| 66 |
-
- name: Run tests
|
| 67 |
-
run: |
|
| 68 |
-
pytest || true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
|
@@ -50,5 +50,5 @@ EXPOSE 7860
|
|
| 50 |
ENV PORT=7860
|
| 51 |
|
| 52 |
# Start Uvicorn serving both backend endpoints and compiled static UI
|
| 53 |
-
CMD ["sh", "-c", "uvicorn app:app --
|
| 54 |
|
|
|
|
| 50 |
ENV PORT=7860
|
| 51 |
|
| 52 |
# Start Uvicorn serving both backend endpoints and compiled static UI
|
| 53 |
+
CMD ["sh", "-c", "uvicorn backend.app:app --host 0.0.0.0 --port ${PORT}"]
|
| 54 |
|
backend/app.py
CHANGED
|
@@ -14,17 +14,17 @@ except ImportError:
|
|
| 14 |
return "en"
|
| 15 |
|
| 16 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
from . import models
|
| 18 |
from . import document_utils
|
| 19 |
from . import auth as auth_mod
|
| 20 |
from . import jobs
|
| 21 |
from . import subtitles
|
| 22 |
-
except (ImportError, ValueError):
|
| 23 |
-
from backend import models
|
| 24 |
-
from backend import document_utils
|
| 25 |
-
from backend import auth as auth_mod
|
| 26 |
-
from backend import jobs
|
| 27 |
-
from backend import subtitles
|
| 28 |
|
| 29 |
app = FastAPI(title="Offline Translation API", version="1.0.0")
|
| 30 |
|
|
|
|
| 14 |
return "en"
|
| 15 |
|
| 16 |
try:
|
| 17 |
+
import models
|
| 18 |
+
import document_utils
|
| 19 |
+
import auth as auth_mod
|
| 20 |
+
import jobs
|
| 21 |
+
import subtitles
|
| 22 |
+
except ImportError:
|
| 23 |
from . import models
|
| 24 |
from . import document_utils
|
| 25 |
from . import auth as auth_mod
|
| 26 |
from . import jobs
|
| 27 |
from . import subtitles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
app = FastAPI(title="Offline Translation API", version="1.0.0")
|
| 30 |
|
run.sh
CHANGED
|
@@ -73,5 +73,5 @@ echo -e "${BLUE}[*] Press Ctrl+C to stop the server.${NC}"
|
|
| 73 |
echo -e "${BLUE}====================================================${NC}"
|
| 74 |
|
| 75 |
# Start Uvicorn backend (which serves the pre-built static React UI on /)
|
| 76 |
-
uvicorn app:app --
|
| 77 |
|
|
|
|
| 73 |
echo -e "${BLUE}====================================================${NC}"
|
| 74 |
|
| 75 |
# Start Uvicorn backend (which serves the pre-built static React UI on /)
|
| 76 |
+
uvicorn backend.app:app --host 0.0.0.0 --port 8000
|
| 77 |
|