From ed5877ff00090f9c3937198897569f94d040b4f8 Mon Sep 17 00:00:00 2001 From: Stefano Cossu <4306733+scossu@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:43:35 -0400 Subject: [PATCH] Merge test (#125) * Yiddish transliteration via submodules. * Update checkout workflow. * Change refs for Yiddish submodules. * Fix WORKDIR in Dockerfile * Do not remove yiddish module. * Manually add yiddish submodules. * Use git clone instead of submodule. * Move ext checkout to github actions. * Chinese numerals (#97) * WIP Parse Chinese numerals. * WIP complete number parsing. * Complete Chinese numerals: * Use standard table override instead of pre-config hooks. * Add few test strings. * Complete numerals: * Transliterate all numeric examples correctly * Modify hook return logic for consistency * WIP partial spacing fix. * Some cleanup; upgrade docker OS. * Add dependency for uwsgi. * Squashed commit of the following: (#98) commit 30859a52b9cc325c323b414133856d0af3ffc2a6 Author: scossu Date: Wed Feb 28 22:17:36 2024 -0500 Move ext checkout to github actions. commit 6d8da6df68ac764f90deb15861089095043fd4ba Author: scossu Date: Wed Feb 28 21:45:01 2024 -0500 Use git clone instead of submodule. commit ade9da589179870d331b703ff526d7fff33e88bb Author: scossu Date: Wed Feb 28 21:42:45 2024 -0500 Manually add yiddish submodules. commit 77cb9ef2959f611d0220cc405e0b584ece71147c Author: scossu Date: Wed Feb 28 21:23:37 2024 -0500 Do not remove yiddish module. commit e405b3605dd2629ed5557ccc5fdd5fe8812799ed Author: scossu Date: Wed Feb 28 09:11:41 2024 -0500 Fix WORKDIR in Dockerfile commit 95445ba642163e28b94df6736ad6946ad7dc76c0 Author: scossu Date: Wed Feb 28 09:07:50 2024 -0500 Change refs for Yiddish submodules. commit 208ea095e792195981f644497ccd5fcd55e15c1b Author: scossu Date: Wed Feb 28 08:45:58 2024 -0500 Update checkout workflow. * Add debug output to /trans response. * Split docker files and requirements. * Add bad request debug handler. * Adjust CI workflows. * Fix image name typo. * Refine triggers. * Fix typo on test workflow trigger. * Use JSON in POST body. * Also use JSON in feedback request; update docs. * Return json data in 400 debug. * Update Aksharamukha. * Add new set of languages; separate pre and post options in Aksharamukha. (#102) * Add all remaining Devanagari scripts. (#107) * Add R2S for Kurdish, Persian, Pushto, Urdu, and bidirectional Divehi. * Add R2S for Kurdish, Persian, Pushto, Urdu, and bidirectional Divehi. (#108) * Fix YAML syntax errors. * P3 legacy mappings (#109) * Add R2S for Kurdish, Persian, Pushto, Urdu, and bidirectional Divehi. * Fix YAML syntax errors. * Fix table section for Divehi. * P3 legacy mappings (#110) * Add R2S for Kurdish, Persian, Pushto, Urdu, and bidirectional Divehi. * Fix YAML syntax errors. * Fix table section for Divehi. * Fix mapping for Divehi. * Add Thai from Randy's table * Fix YAML errors in Thai alt. * Fix Tamil YAML. * Fix Malayalam config. * Fix Greek numerals logic; add test strings. * Add Malayalam to index. * Better exception handling. * Add CORS to all routes. * Add MARC codes to language index. * Fix Greek S2R table. * Tolerate and normalize nested tokens. * Add Assamese table. * Fix char index misalignment after ignoring. * Yiddish (#123) * Use yiddish package from pypi; add loshn_koydesh override. * Remove yiddish submodule update from build automation. * Add lk override path to example.env. * Fix some CI issues. * Test CI. * test. * Add git fetch --tags. * Fix syntax. * Add --always. * Mirror config updates in push-app-image action. * Add git info to home page. --- .github/workflows/push-app-image.yml | 8 +++++++- .github/workflows/push-test-image.yml | 7 ++++++- .gitignore | 1 + Dockerfile | 2 +- deps.txt | 4 +--- requirements.txt | 1 + scriptshifter/__init__.py | 5 +++++ scriptshifter/rest_api.py | 6 +++++- scriptshifter/templates/layout.html | 4 ++++ 9 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push-app-image.yml b/.github/workflows/push-app-image.yml index 610703a..55e85f1 100644 --- a/.github/workflows/push-app-image.yml +++ b/.github/workflows/push-app-image.yml @@ -6,7 +6,7 @@ on: tags: - "v*.*.[1-9]*" workflow_run: - workflows: + workflows: - "Push base image" types: - "completed" @@ -25,6 +25,12 @@ jobs: with: submodules: recursive + - name: update version info + run: | + git fetch --tags + git describe --tags --always >| VERSION + git rev-parse HEAD >> VERSION + - name: Build the Docker image run: > docker build -f Dockerfile . diff --git a/.github/workflows/push-test-image.yml b/.github/workflows/push-test-image.yml index 93cb36f..10e8dbd 100644 --- a/.github/workflows/push-test-image.yml +++ b/.github/workflows/push-test-image.yml @@ -18,6 +18,12 @@ jobs: with: submodules: recursive + - name: update version info + run: | + git fetch --tags + git describe --tags --always >| VERSION + git rev-parse HEAD >> VERSION + - name: Build the Docker image run: > docker build -f Dockerfile . @@ -32,4 +38,3 @@ jobs: - name: Push to Docker Hub run: docker push $DOCKER_USER/$REPO_NAME:test - diff --git a/.gitignore b/.gitignore index 2555d35..6543906 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,4 @@ tags.temp # Local ext/arabic_rom/data !.keep +VERSION diff --git a/Dockerfile b/Dockerfile index 779cfe4..fc6eace 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ ARG WORKROOT "/usr/local/scriptshifter/src" # Copy core application files. WORKDIR ${WORKROOT} -COPY entrypoint.sh uwsgi.ini wsgi.py ./ +COPY entrypoint.sh uwsgi.ini wsgi.py VERSION ./ COPY scriptshifter ./scriptshifter/ COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt diff --git a/deps.txt b/deps.txt index 7e0d8e1..8bf3f68 100644 --- a/deps.txt +++ b/deps.txt @@ -1,7 +1,5 @@ -# External dependencies. -aksharamukha>=2.2,<3 +# Base image dependencies. camel-tools>=1.5 funcy>=1.15,<2 pymarc>=4.0,<5 repackage>=0.7.3 -./ext/yiddish diff --git a/requirements.txt b/requirements.txt index 386de14..4e85565 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ # Core application dependencies. +aksharamukha>=2.2,<3 flask>=2.3,<3 flask-cors>=4.0,<5 python-dotenv>=1.0,<2 diff --git a/scriptshifter/__init__.py b/scriptshifter/__init__.py index 8f324f5..ea34ebd 100644 --- a/scriptshifter/__init__.py +++ b/scriptshifter/__init__.py @@ -18,6 +18,11 @@ """ SMTP_HOST = environ.get("TXL_SMTP_HOST") +with open(path.join(path.dirname(APP_ROOT), "VERSION")) as fh: + version_info = fh.readlines() +GIT_TAG = version_info[0].strip() +GIT_COMMIT = version_info[1].strip() + logging.basicConfig( # filename=environ.get("TXL_LOGFILE", "/dev/stdout"), level=environ.get("TXL_LOGLEVEL", logging.WARN)) diff --git a/scriptshifter/rest_api.py b/scriptshifter/rest_api.py index fd6d119..0d77d11 100644 --- a/scriptshifter/rest_api.py +++ b/scriptshifter/rest_api.py @@ -10,7 +10,10 @@ from flask import Flask, jsonify, render_template, request from flask_cors import CORS -from scriptshifter import EMAIL_FROM, EMAIL_TO, SMTP_HOST, SMTP_PORT +from scriptshifter import ( + EMAIL_FROM, EMAIL_TO, + GIT_COMMIT, GIT_TAG, + SMTP_HOST, SMTP_PORT) from scriptshifter.exceptions import ApiError from scriptshifter.tables import list_tables, load_table from scriptshifter.trans import transliterate @@ -69,6 +72,7 @@ def index(): return render_template( "index.html", languages=list_tables(), + version_info=(GIT_TAG, GIT_COMMIT), feedback_form=SMTP_HOST is not None) diff --git a/scriptshifter/templates/layout.html b/scriptshifter/templates/layout.html index 83f317a..8da00e8 100644 --- a/scriptshifter/templates/layout.html +++ b/scriptshifter/templates/layout.html @@ -21,5 +21,9 @@

{{ title }}

+