Skip to content

Commit

Permalink
update node and most poetry packages (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
benfoley committed Oct 20, 2022
1 parent 33095bb commit 80997da
Show file tree
Hide file tree
Showing 17 changed files with 3,595 additions and 5,886 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ RUN wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && \
chmod +x jq-linux64 && \
mv jq-linux64 /usr/local/bin/jq

# Add node 15, yarn and xml-js
RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get update && apt-get install -y nodejs build-essential && \
# Add node 18, yarn and xml-js
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && apt-get update && \
apt-get install -y nodejs build-essential && \
npm install -g npm \
hash -d npm \
npm install -g xml-js yarn
Expand Down Expand Up @@ -178,6 +179,7 @@ ADD http://www.random.org/strings/?num=10&len=8&digits=on&upperalpha=on&loweralp

WORKDIR /


RUN echo "===> Install Elpis"
# Remove `--single-branch` and replace with `--branch <your_branch_name>` below for development
RUN git clone --single-branch --depth=1 https://github.com/CoEDL/elpis.git
Expand Down Expand Up @@ -205,25 +207,23 @@ RUN ln -s /timit-elan /datasets/timit
########################## RUN THE APP ##########################

# ENV vars for interactive running
RUN echo "export FLASK_ENV=development" >> ~/.zshrc
RUN echo "export FLASK_APP=elpis" >> ~/.zshrc
RUN echo "export LC_ALL=C.UTF-8" >> ~/.zshrc
RUN echo "export LANG=C.UTF-8" >> ~/.zshrc
WORKDIR /elpis
RUN echo "export POETRY_PATH=$(poetry env info -p)" >> ~/.zshrc
RUN echo "export PATH=$PATH:${POETRY_PATH}/bin:/kaldi/src/bin/" >> ~/.zshrc
RUN echo "alias run=\"poetry run flask run --host=0.0.0.0 --port=5001\"" >> ~/.zshrc
RUN echo "alias run=\"poetry run flask --debug run --host=0.0.0.0 --port=5001\"" >> ~/.zshrc
RUN cat ~/.zshrc >> ~/.bashrc

# ENV vars for non-interactive running
ENV FLASK_ENV='development'
ENV FLASK_APP='elpis'
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

WORKDIR /elpis

ENTRYPOINT ["poetry", "run", "flask", "run", "--host", "0.0.0.0", "--port", "5001"]
ENTRYPOINT ["poetry", "run", "flask", "--debug", "run", "--host", "0.0.0.0", "--port", "5001"]

# 5001 is for the Flask server
EXPOSE 5001
Expand Down
12 changes: 4 additions & 8 deletions elpis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from flask import redirect
from . import endpoints
from .app import Flask
from flask import Flask
from elpis.engines import Interface
from pathlib import Path
from requests import get
Expand Down Expand Up @@ -32,7 +32,7 @@ def create_app(test_config=None):
else:
# Setup static resources
# create and configure the app
# auto detect for yarn watch or yarn build
# autodetect for yarn watch or yarn build
static_dir_watch = "/js"
static_dir_build = "/static"
if "js" in os.listdir(GUI_BUILD_DIR):
Expand All @@ -41,13 +41,9 @@ def create_app(test_config=None):
else:
static_dir = static_dir_build

# if os.environ.get('FLASK_ENV') == 'production':
# static_dir = static_dir_build
# else:
# static_dir = static_dir_watch
logger.info(f"using static_dir: {static_dir}")
# Create a custom Flask instance defined in the app.py file. Same as a
# normal Flask class but with a specialised blueprint function.

# Create a Flask instance.
app = Flask(
__name__,
instance_relative_config=True,
Expand Down
23 changes: 0 additions & 23 deletions elpis/app.py

This file was deleted.

198 changes: 0 additions & 198 deletions elpis/blueprint.py

This file was deleted.

2 changes: 1 addition & 1 deletion elpis/endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..blueprint import Blueprint
from flask import Blueprint
from . import config
from . import dataset
from . import model
Expand Down
6 changes: 1 addition & 5 deletions elpis/endpoints/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from ..blueprint import Blueprint
from flask import current_app as app, jsonify, request
from flask import Blueprint, current_app as app, jsonify, request
from elpis.engines import Interface, ENGINES
import shutil
import os
import glob

bp = Blueprint("config", __name__, url_prefix="/config")

Expand Down
4 changes: 1 addition & 3 deletions elpis/endpoints/dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from flask import request
from ..blueprint import Blueprint
from flask import current_app as app, jsonify
from flask import Blueprint, current_app as app, jsonify, request
from elpis.engines import Interface
from elpis.engines.common.objects.dataset import Dataset
from elpis.engines.common.errors import InterfaceError
Expand Down
4 changes: 1 addition & 3 deletions elpis/endpoints/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
from pathlib import Path
from typing import Callable, Dict

from flask import current_app as app
from flask import jsonify, request, send_file
from flask import Blueprint, current_app as app, jsonify, request, send_file
from loguru import logger
from werkzeug.utils import secure_filename

from elpis.blueprint import Blueprint
from elpis.engines import Interface, ENGINES
from elpis.engines.common.errors import InterfaceError
from elpis.engines.common.objects.model import Model
Expand Down
4 changes: 1 addition & 3 deletions elpis/endpoints/pron_dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from flask import request, make_response
from ..blueprint import Blueprint
from flask import current_app as app, jsonify
from flask import Blueprint, current_app as app, jsonify, request, make_response
from elpis.engines import Interface
from elpis.engines.common.objects.pron_dict import PronDict
from elpis.engines.common.errors import InterfaceError
Expand Down
7 changes: 2 additions & 5 deletions elpis/endpoints/transcription.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from flask import request, current_app as app, jsonify
from ..blueprint import Blueprint
from flask import Blueprint, current_app as app, jsonify, request
from loguru import logger

from elpis.engines import Interface
Expand All @@ -18,9 +17,7 @@ def new():
transcription.link(model)
app.config["CURRENT_TRANSCRIPTION"] = transcription
file = request.files["file"]
transcription.prepare_audio(
file, on_complete=lambda: logger.info("Prepared audio file!")
)
transcription.prepare_audio(file, on_complete=lambda: logger.info("Prepared audio file!"))
data = {"status": transcription.status, "originalFilename": file.filename}
return jsonify({"status": 200, "data": data})

Expand Down
1 change: 1 addition & 0 deletions elpis/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from elpis.engines.hft.objects.model import HFTModel
from elpis.engines.hft.objects.transcription import HFTTranscription


class Engine(ABC):
def __init__(self, model: Type[Model], transcription: Type[Transcription]):
self._model = model
Expand Down
4 changes: 1 addition & 3 deletions elpis/engines/common/input/make_wordlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def extract_additional_words(file_name: str) -> List[str]:
new_words = line.strip().split(" ")
words += [word for word in new_words]
else:
logger.warning(
f"Additional word list file at {file_name} does not exist, skipping!"
)
logger.warning(f"Additional word list file at {file_name} does not exist, skipping!")
return words


Expand Down

0 comments on commit 80997da

Please sign in to comment.