Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VocExcel web UI #3

Merged
merged 33 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2c09a0a
Run poetry update
edmondchuc Jul 3, 2023
6e9d490
Apply black formatting
edmondchuc Jul 3, 2023
90beee5
Add vocexcel web service
edmondchuc Jul 3, 2023
cc2bbef
Apply black formatting
edmondchuc Jul 3, 2023
6313e91
Add cors allow all to api
edmondchuc Jul 3, 2023
e7c95f3
Add working VocExcel UI
edmondchuc Jul 3, 2023
9904958
Remove webbrowser
edmondchuc Jul 5, 2023
6047092
Add tree view
edmondchuc Jul 6, 2023
e9d333f
Fix typing and sync async issues
edmondchuc Jul 6, 2023
d87eb9e
Add link to VocExcel template
edmondchuc Jul 6, 2023
37d188b
Add progress spinner
edmondchuc Jul 6, 2023
2a69b44
Disable file upload preview
edmondchuc Jul 6, 2023
00ecd45
Add Dockerfile to serve web api server with ui as static assets
edmondchuc Jul 8, 2023
666dc5a
Add vite proxy for dev
edmondchuc Jul 8, 2023
f189464
Add uvicorn factory flag to true
edmondchuc Jul 9, 2023
28436ac
Move index.html and styles.css into web
edmondchuc Jul 9, 2023
f3abac9
Move static assets to vocexcel/web/static
edmondchuc Jul 9, 2023
9f19fa1
Add handling of versioning.
edmondchuc Jul 9, 2023
4dc8727
Add response text as error message. Set life of toast to 5 seconds
edmondchuc Jul 10, 2023
de0b296
Add old failing tests as xfail
edmondchuc Jul 10, 2023
7384eb1
Add web tests
edmondchuc Jul 10, 2023
4345cec
Add description for each API endpoint
edmondchuc Jul 10, 2023
e85dd69
Add test gh action
edmondchuc Jul 10, 2023
1383525
Add Taskfile and add ruff
edmondchuc Jul 10, 2023
43b484a
Run black and ruff formatting
edmondchuc Jul 10, 2023
01aaec4
Add format check to test workflow
edmondchuc Jul 10, 2023
b34b37d
Add pytest pythonpath
edmondchuc Jul 10, 2023
e8b8886
Rename test workflow
edmondchuc Jul 10, 2023
43e2c1a
Add release workflow
edmondchuc Jul 10, 2023
0ef4c9c
Remove workflow_dispatch
edmondchuc Jul 10, 2023
e8df57e
Add python and poetry setup to release workflow
edmondchuc Jul 10, 2023
1664475
Add task run commands
edmondchuc Jul 10, 2023
ddd5e45
Add response_class for /api/v1/construct-query
edmondchuc Jul 10, 2023
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
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
release:
types:
- published

env:
IMAGE_NAME: ghcr.io/rdflib/vocexcel
PYTHON_VERSION: "3.11"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up and use Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: latest
cache: npm

- name: Set up Git user
uses: fregante/setup-git-user@v2

- name: Get release version
id: version
run: echo "VALUE=$(npx --yes semver ${{ github.event.release.tag_name }})" >> "$GITHUB_OUTPUT"

- name: Update project version
run: |
poetry version ${{ steps.version.outputs.VALUE }}
git add pyproject.toml
git commit -m "chore: release ${{ steps.version.outputs.VALUE }}"
git push

- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.metadata.outputs.tags }}
# Set provenance to false due to issue documented here: https://github.com/docker/build-push-action/issues/778
provenance: false
platforms: linux/amd64,linux/arm64
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run tests and checks

on:
# Make workflow callable.
workflow_call:
pull_request:
types: [opened, synchronize, reopened]

env:
PYTHON_VERSION: "3.11"

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout the repo
uses: actions/checkout@v3

- name: Use Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install Task
uses: arduino/setup-task@v1

- name: Install Python dependencies
run: task install

- name: Run Pytest
run: task test

- name: Run formatters in check mode
run: task format:check
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# base
FROM python:3.11-alpine3.17 AS base

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1

WORKDIR /app

RUN apk add --no-cache \
gcc \
libffi-dev \
musl-dev

# node-builder
FROM node:18-alpine3.17 AS node-builder

WORKDIR /app

COPY vocexcel-ui/ .

RUN npm ci
RUN npm run build

# python-builder
FROM base AS python-builder

ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1

RUN pip install poetry

ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --with web | pip install -r /dev/stdin

COPY . .
COPY --from=node-builder /app/dist /app/vocexcel/web/static
RUN poetry build && pip install dist/*.whl

# final
FROM base as final

COPY --from=node-builder /app/dist /vocexcel-ui
COPY --from=python-builder /opt/venv /opt/venv

ENV VIRTUALENV=/opt/venv \
PATH=/opt/venv/bin:${PATH} \
VOCEXCEL_WEB_STATIC_DIR=/opt/venv/lib/python3.11/site-packages/vocexcel/web/static

RUN apk --no-cache add bash

USER 1000

CMD [ "uvicorn", "vocexcel.web.app:create_app", "--host=0.0.0.0", "--port=8000", "--proxy-headers" ]
36 changes: 36 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# https://taskfile.dev

version: "3"

tasks:
install:
desc: Install project and dependencies.
cmds:
- poetry install --no-interaction --no-root

format:
desc: Format Python code.
cmds:
- poetry run ruff check --fix vocexcel tests
- poetry run black vocexcel tests

format:check:
desc: Run formatters in check mode. Does not apply formatting.
cmds:
- poetry run ruff check vocexcel tests
- poetry run black --check vocexcel tests

test:
desc: Run tests
cmds:
- poetry run pytest

run:
desc: Run Python dev server
cmds:
- poetry run python main.py

run:ui:
desc: Run Vite dev server
cmds:
- npm --prefix vocexcel-ui run dev
11 changes: 11 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import uvicorn


if __name__ == "__main__":
uvicorn.run(
"vocexcel.web.app:create_app",
host="0.0.0.0",
port=8000,
reload=True,
factory=True,
)
Loading