Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm run build
run: pnpm run build
4 changes: 3 additions & 1 deletion .github/workflows/manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Move manager out
run: mv ./manager/* ./
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
Expand All @@ -20,4 +22,4 @@ jobs:
- name: Install dependencies
run: pdm install -Gtest
- name: Run tests
run: pdm run pytest
run: pdm test
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
manager_data/
.idea
33 changes: 0 additions & 33 deletions .pre-commit-config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion app/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
},
"javascript.format.semicolons": "remove",
"html.format.wrapLineLength": 98,
}
}
2 changes: 1 addition & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN pwd && ls -l && pnpm i && pnpm build
FROM nginx:alpine

COPY --from=0 /app/dist /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<script type="module" src="/src/main.js"></script>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion app/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ http {
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
}
}
}
}
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"unocss": "^0.53.0",
"vite": "^4.0.0"
}
}
}
2 changes: 1 addition & 1 deletion app/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ html.dark {
--er-primary-light: rgba(109, 40, 217);
--er-primary-dark: rgba(76, 29, 149);
--er-primary: rgba(91, 33, 182);
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
IMG_FOLDER_NAME: img
THUMBNAIL_FOLDER: thumbnail
THUMBNAIL_MAX_WIDTH: 600
command: /bin/sh -c "pdm create-tables --username admin --passowrd 123456 && gunicorn -w 4 src.app:app -b 0.0.0.0:5000"
command: /bin/sh -c "pdm create-tables --username admin --passowrd 123456 && gunicorn -w 4 fw_manager:app -b 0.0.0.0:5000"
volumes:
- ./manager_data/img:/manager/static/img
- ./manager_data/instance:/manager/instance
Expand All @@ -18,4 +18,4 @@ services:
ports:
- 80:80
depends_on:
- manager
- manager
2 changes: 2 additions & 0 deletions manager/.flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=src/app.py
FLASK_DEBUG=1
4 changes: 4 additions & 0 deletions manager/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ target/

# pyenv
.python-version
.pdm-python

# celery beat schedule file
celerybeat-schedule
Expand Down Expand Up @@ -108,3 +109,6 @@ ENV/

# Other
.DS_Store

fw_manager/static/*
!fw_manager/static/favicon.svg
12 changes: 4 additions & 8 deletions .pre-commit-config.yaml → manager/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
ci:
autoupdate_schedule: monthly

exclude: ^app/
repos:

# export python requirements
- repo: https://github.com/pdm-project/pdm
rev: 2.11.1
rev: 2.12.3
hooks:
- id: pdm-export
# command arguments, e.g.:
args: ['-o', 'requirements.txt', '--without-hashes']
files: ^pdm.lock$
files: pdm.lock
entry: bash -c "cd manager && pdm export -o requirements.txt --without-hashes"

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -21,7 +17,7 @@ repos:
- id: debug-statements

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.9'
rev: 'v0.2.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
Expand Down
4 changes: 2 additions & 2 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ COPY . /manager

WORKDIR /manager

RUN pip install pdm && pip install gunicorn
RUN pdm export > requirements.txt && pip install -r requirements.txt
RUN pip install gunicorn
RUN pip install -r requirements.txt
5 changes: 5 additions & 0 deletions manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Images manager for Fine Weather

- Upload image
- Edit image info (e.g. title, description)
- Generate and provide a JSON output of images
Empty file removed manager/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions manager/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fw_manager import create_app

app = create_app()
21 changes: 21 additions & 0 deletions manager/fw_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pathlib import Path

from flask_bootstrap import Bootstrap5
from flask import Flask
from flask_wtf import CSRFProtect

from . import commands, blueprints
from .models import db


def create_app():
app = Flask(__name__, instance_path=Path("./instance").absolute())
app.config.from_prefixed_env()

Bootstrap5(app)
CSRFProtect(app)
commands.init_app(app)
db.init_app(app)
blueprints.init_app(app)

return app
11 changes: 11 additions & 0 deletions manager/fw_manager/blueprints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask

from fw_manager.blueprints.manager import manager_bp
from fw_manager.blueprints.retriever import retriever_bp
from fw_manager.blueprints.error import error_bp


def init_app(app: Flask):
app.register_blueprint(manager_bp, url_prefix="/manager")
app.register_blueprint(retriever_bp, url_prefix="/images")
app.register_blueprint(error_bp)
31 changes: 31 additions & 0 deletions manager/fw_manager/blueprints/error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from flask import Blueprint

from fw_manager.utils import make_resp

from loguru import logger

error_bp = Blueprint("error", __name__)


@error_bp.app_errorhandler(400)
def bad_request(err):
logger.error(f"Bad request: {err!r}")
return make_resp(err_code="BAD_REQUEST", msg="Bad request"), 400


@error_bp.app_errorhandler(403)
def not_authorized(err):
logger.error(f"Not authorized: {err!r}")
return make_resp(err_code="NOT_AUTHORIZED", msg="Not authorized"), 403


@error_bp.app_errorhandler(404)
def not_found(err):
logger.error(f"Not found: {err!r}")
return make_resp(err_code="NOT_FOUND", msg="404 not found"), 404


@error_bp.app_errorhandler(500)
def internal_server_error(err):
logger.error(f"An error occurred: {err!r}")
return make_resp(err_code="INTERNAL_ERROR", msg="An error occurred"), 500
Loading