diff --git a/.github/workflows/Prod.yml b/.github/workflows/Prod.yml new file mode 100644 index 0000000..79b3920 --- /dev/null +++ b/.github/workflows/Prod.yml @@ -0,0 +1,60 @@ +name: PROD DEPLOYMENT + +on: + push: + branches: [ all-1.0-prod ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Load .env from GitHub Secret + run: echo "${{ secrets.MY_ENV_VARS_PROD }}" > .env + + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }} + env: + MY_ENV_VARS: ${{ secrets.MY_ENV_VARS_PROD }} + deploy: + runs-on: ubuntu-latest + timeout-minutes: 15 + needs: [build] + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Deploy Stack + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_PROD }} + username: ${{ secrets.USERNAME_PROD }} + key: ${{ secrets.SSH_PRIVATE_KEY_PROD }} + port: ${{ secrets.PORT }} + script: | + + docker login + + docker container stop ${{ secrets.CONTAINER_NAME }} + + docker rm ${{ secrets.CONTAINER_NAME }} + docker rmi ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }} + docker pull ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }} + + docker run -d --name ${{ secrets.CONTAINER_NAME }} --network ${{ secrets.NETWORK }} -p ${{ secrets.CONTAINER_PORT }} -t ${{ secrets.CONTAINER_REGISTRY_PROD }}:${{ secrets.IMAGE_TAG }} diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..5d5eeac --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,62 @@ +name: DEV DEPLOYMENT + +on: + push: + branches: [ all-1.0 ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Load .env from GitHub Secret + run: echo "${{ secrets.MY_ENV_VARS }}" > .env + + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }} + env: + MY_ENV_VARS: ${{ secrets.MY_ENV_VARS }} + deploy: + runs-on: ubuntu-latest + timeout-minutes: 15 + needs: [build] + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Deploy Stack + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: ${{ secrets.PORT }} + script: | + + docker login + + docker container stop ${{ secrets.CONTAINER_NAME }} + + docker rm ${{ secrets.CONTAINER_NAME }} + + docker rmi ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }} + + docker pull ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }} + + docker run -d --name ${{ secrets.CONTAINER_NAME }} --network ${{ secrets.NETWORK }} -p ${{ secrets.CONTAINER_PORT }} -t ${{ secrets.CONTAINER_REGISTRY }}:${{ secrets.IMAGE_TAG }} diff --git a/Dockerfile b/Dockerfile index 73c1305..0d6670b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN pip install -r requirements.txt COPY . . # Expose the port that the app runs on -EXPOSE 5000 +EXPOSE $PORT # Command to run the Flask application CMD ["python", "app.py","--host","0.0.0.0"] diff --git a/README.md b/README.md index f480903..03d28a5 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# all-learner-text-eval +# all-learner-text-eval. diff --git a/app.py b/app.py index b6d7d3f..26588ae 100644 --- a/app.py +++ b/app.py @@ -218,6 +218,8 @@ def split_into_phonemes(token): return ph_list def identify_missing_tokens(orig_text, resp_text): + if resp_text == None: + resp_text = "" orig_word_list = orig_text.split() resp_word_list = resp_text.split() construct_word_list =[] @@ -230,10 +232,10 @@ def identify_missing_tokens(orig_text, resp_text): for word in orig_word_list: #use similarity algo euclidean distance and add them, if there is no direct match closest_match, similarity_score = find_closest_match(word, resp_text) - #print(f"word:{word}: closest match: {closest_match}: sim score:{similarity_score}") + print(f"word:{word}: closest match: {closest_match}: sim score:{similarity_score}") p_word = p.convert(word) print(f"word - {word}:: phonemes - {p_word}")#p_word = split_into_phonemes(p_word) - if similarity_score > 80: + if closest_match != None and (similarity_score > 80 or len(orig_word_list) == 1): #print("matched word") construct_word_list.append(closest_match) p_closest_match = p.convert(closest_match) @@ -256,6 +258,16 @@ def identify_missing_tokens(orig_text, resp_text): missing_flatList = list(set(missing_flatList)) construct_flatList = list(set(construct_flatList)) + #For words like pew and few, we are adding to construct word and + # we just need to eliminate the matching phonemes and + # add missing phonemes into missing list + for m in orig_flatList: + print(m, " in construct phonemelist") + if m not in construct_flatList: + missing_flatList.append(m) + print('adding to missing list', m) + missing_flatList = list(set(missing_flatList)) + print(f"orig Text: {orig_text}") print(f"Resp Text: {resp_text}") print(f"construct Text: {construct_text}") @@ -265,8 +277,8 @@ def identify_missing_tokens(orig_text, resp_text): print(f"Construct phonemes: {construct_phoneme_list}") #print(f"flat Construct phonemes: {construct_flatList}") - print(f"missing phonemes: {missing_phoneme_list}") - #print(f"flat missing phonemes: {missing_flatList}") + #print(f"missing phonemes: {missing_phoneme_list}") + print(f"flat missing phonemes: {missing_flatList}") return construct_flatList, missing_flatList,construct_text def processLP(orig_text, resp_text): @@ -331,10 +343,9 @@ def get_phonemes(): text = data.get('text') phonemesList = split_into_phonemes(p.convert(text)) - uniquePhonemesList = list(dict.fromkeys(phonemesList)) return jsonify({ - "phonemes": uniquePhonemesList + "phonemes": phonemesList }) if __name__ == '__main__': diff --git a/docker-compose.yml b/docker-compose.yml index eedecc2..4f0a712 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,5 +3,9 @@ services: ALL-TEXT_EVAL: image: all-text-eval-app ports: - - '5001:5001' + - '0.0.0.0:5000:5000' restart: always + +networks: + ai-network: + driver: bridge