Skip to content

Commit

Permalink
Merge pull request #105 from quaternionmedia/pytest-qm
Browse files Browse the repository at this point in the history
🏹 QM Pytest
  • Loading branch information
mrharpo authored Jul 20, 2023
2 parents 7f77a39 + 99dc55b commit 02cc251
Show file tree
Hide file tree
Showing 15 changed files with 752 additions and 830 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ on: [push, pull_request]
jobs:
api_tests:
name: 🐢 API tests
uses: ./.github/workflows/nox.yml
with:
args: coverage
uses: quaternionmedia/.github/.github/workflows/pytest.yml@main
secrets: inherit

lint:
name: 👖 Linter
Expand Down
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# project based
node_modules
*/dist/*
alfred/dist/*
website/dist/*
/dist/*
.cache
package-lock.json
Expand Down Expand Up @@ -80,4 +81,7 @@ alfred/logs/

# PDM
.pdm-python
build/
build/

# Data
data/
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
FROM python

WORKDIR /app

RUN mkdir -p data

COPY pyproject.toml README.md ./
COPY alfred alfred

RUN pip3 install -e alfred/otto
RUN BEZIER_NO_EXTENSION=true pip3 install -e alfred/otto[render]
RUN pip3 install -e . uvicorn

RUN rm /etc/ImageMagick-6/policy.xml
Expand Down
111 changes: 57 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
# alfred
> *"Drama is life with all the dull bits cut out."*
>
> ~ Alfred Hitchcock
Alfred is a video editor that works even without a server, designed for quick editing from anywhere, including mobile devices!

Demo at [alfred.quaternion.media](https://alfred.quaternion.media)

## clone
`git clone --recurse-submodules [email protected]:quaternionmedia/alfred.git`


### Common commands:
#### init
Install website dependencies

`./al init`

#### dev
`./al dev`

then open http://localhost:8000

#### rebuild docker images:
`./al dev --build`

#### install package
`./al install` [package name]
`npm i` [package name]

When run with no arguments, it will reinstall npm dependencies, which might be needed if package.json has been edited or changed.

#### demo
To download the demo media (into `videos/`):

`./al demo`

Then you can render the `demo.csv` project locally.

#### documentation
To build the documentation locally with [mkdocs](https://www.mkdocs.org/)
##### install dependencies
`pip install -r requirements-docs.txt`

##### rebuild docs
`mkdocs serve`

Optional: specify a different host address with `-a`. For example:

`mkdocs serve -a 0.0.0.0:4000` will serve the documentation on all available network hosts, at port `4000`.
#### production
`./al prod`
Assumes a [traefik](https://containo.us/traefik/) instance is already running.
# alfred
> *"Drama is life with all the dull bits cut out."*
>
> ~ Alfred Hitchcock
Alfred is a video editor that works even without a server, designed for quick editing from anywhere, including mobile devices!

Demo at [alfred.quaternion.media](https://alfred.quaternion.media)

## clone
`git clone --recurse-submodules [email protected]:quaternionmedia/alfred.git`


### Common commands:
#### init
Install website dependencies

`./al init`

#### dev
`./al dev`

then open http://localhost:8000

#### rebuild docker images:
`./al dev --build`

#### install package
`./al install` [package name]
`npm i` [package name]

When run with no arguments, it will reinstall npm dependencies, which might be needed if package.json has been edited or changed.

#### demo
To download the demo media (into `videos/`):

`./al demo`

Then you can render the `demo.csv` project locally.

#### nox
`./al nox`

#### documentation
To build the documentation locally with [mkdocs](https://www.mkdocs.org/)
##### install dependencies
`pip install -r requirements-docs.txt`

##### rebuild docs
`mkdocs serve`

Optional: specify a different host address with `-a`. For example:

`mkdocs serve -a 0.0.0.0:4000` will serve the documentation on all available network hosts, at port `4000`.
#### production
`./al prod`
Assumes a [traefik](https://containo.us/traefik/) instance is already running.
4 changes: 2 additions & 2 deletions al
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ elif [ $1 = "w" -o $1 = "worker" ]; then
# . operator used in place of source
. ./.cred
# DB_URL=mongodb://$1:27017 CELERY_BROKER=$DB_URL/celery CELERY_BACKEND=$CELERY_BROKER celery -A tasks:renderer --workdir alfred/ -b $CELERY_BROKER --result-backend $CELERY_BACKEND worker --concurrency=4
# DB_URL=mongodb://$1:27017 DB_NAME=alfred CELERY_BROKER=$DB_URL/celery CELERY_BACKEND=$CELERY_BROKER celery -A alfred.core.utils:renderer --workdir alfred/ worker --concurrency=4
docker compose -f docker-compose.yml -f dev.yml run -it --entrypoint "celery -A alfred.core.utils.tasks:renderer --workdir /app/ -b mongodb://$1:27017/celery --result-backend mongodb://$1:27017/celery worker --loglevel=info --concurrency=1" renderer
DB_URL=mongodb://$1:27017 DB_NAME=alfred CELERY_BROKER=$DB_URL/celery CELERY_BACKEND=$CELERY_BROKER celery -A alfred.core.utils:renderer --workdir alfred/ worker --concurrency=4
# docker compose -f docker-compose.yml -f dev.yml run -it --entrypoint "celery -A alfred.core.utils.tasks:renderer --workdir /app/alfred -b mongodb://$1:27017/celery --result-backend mongodb://$1:27017/celery worker --loglevel=debug --concurrency=1" renderer

elif [ $1 = "dump" ]; then
shift
Expand Down
2 changes: 1 addition & 1 deletion alfred/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.0'
__version__ = '0.2.1'
3 changes: 3 additions & 0 deletions alfred/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

SECRET_KEY = environ.get('ALFRED_SECRET_KEY')

DATA_DIR = environ.get('DATA_DIR', 'data')
STATIC_DIR = environ.get('STATIC_DIR', 'dist')

DB_URL = environ.get('DB_URL')
DB_NAME = environ.get('DB_NAME', 'db')

Expand Down
6 changes: 3 additions & 3 deletions alfred/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from alfred.core.models.users import UserRead, UserUpdate
from alfred.core.utils.db import User
from alfred import docs
from alfred.config import DATA_DIR, STATIC_DIR


app = FastAPI(
Expand Down Expand Up @@ -111,11 +112,10 @@ async def checkFonts():
)
# note: we can't secure the /data route because the otto preview is rendered into the
# <img> tag in the browser. Should find a workaround for this, but it is not critical.
app.mount('/data', StaticFiles(directory='data', html=True), name='data')
app.mount('/docs', StaticFiles(directory='site', html=True), name='docs')
app.mount('/data', StaticFiles(directory=DATA_DIR, html=True), name='data')

# if request does not match the above api, try to return a StaticFiles match
app.mount('/', StaticFiles(directory='dist', html=True), name='static')
app.mount('/', StaticFiles(directory=STATIC_DIR, html=True), name='dist')


@app.on_event("startup")
Expand Down
Empty file added data/.gitignore
Empty file.
7 changes: 4 additions & 3 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ services:
- 8000:80
volumes:
- ./alfred/otto:/otto/
- ./alfred/otto/fonts:/usr/share/fonts/truetype/

renderer:
build:
context: .
dockerfile: ./Dockerfile
image: alfred_worker
entrypoint: celery -A alfred.core.utils.tasks:renderer --workdir /app/ -b mongodb://db:27017/celery --result-backend mongodb://db:27017/celery worker --loglevel=info
entrypoint: celery -A alfred.core.utils.tasks:renderer --workdir /app/alfred -b mongodb://db:27017/celery --result-backend mongodb://db:27017/celery worker --loglevel=info
networks:
- alfred_isolated
volumes:
- ./alfred/:/app/
- ./alfred/otto:/otto/
- ./alfred/:/app/alfred/
- ./alfred/otto/fonts:/usr/share/fonts/truetype/
- ./cred.json:/cred.json
depends_on:
- 'db'
Expand Down
Loading

0 comments on commit 02cc251

Please sign in to comment.